strange behavior on overridden method

Help
2007-09-16
2013-04-17
  • Werner Ackerl
    Werner Ackerl
    2007-09-16

    for example, i have added a template for the equals method (in order before the 'returns other' template):

    <template kind="3" name="Method.equals method" default="false" signature="true">
        <regex>boolean equals\(.*\)</regex>
        <example>boolean equals(Object obj)</example>
        <text>/**
    * Indicates whether some other object is "equal to" this one.
    *
    * @return &lt;code&gt;true&lt;/code&gt; if this object is the same as the obj argument; &lt;code&gt;false&lt;/code&gt; otherwise.
    *
    * @see java.lang.Object#equals(java.lang.Object)
    */</text>
    </template>

    executing the plugin on my overwriting equals method (with no javadoc yet) a non-javadoc comment with the @see tag is created. i then change this comment to a javadoc comment and execute the plugin again. this time a 'returns other' template seems to be called; but not the one displayed in the template dialog, for i have added a few extra characters into that one for debugging.

    if, on the other hand, i change the method signature in my soure file and the template (eg. to 'eequals'), my 'equals method' template gets called right away.

    in all cases i've experienced this so far, the source of the overwritten class resides in a .jar or .zip file (like the jdk source code)
    more technical data:
    MyEclipse Enterprise Workbench 20070521-5.5.1-GA
    jdk 1.5.0_11
    JAutodoc Plug-in 1.5.0

    besides this issue, the plugin promises to be very usefull. thanks for the effort!

     
    • Martin Kesting
      Martin Kesting
      2007-09-17

      If there's no comment on overridden method, JAutodoc takes the global Eclipse template that's defined under

      Preferences->Java->Code Style->Code Templates->Overriding methods

      Default here is the non-javadoc you saw.

      If there's already a javadoc comment for the overridden method, JAutodoc checks and completes this if necessary. The problem is, that this completion is not taken from any template, but creates some hardcoded text. No template is used when completing existing comments, because there would be some merging necessary between the old text and the evaluated template.

      You can achieve to get your template applied, when you clear (empty string) the global Eclipse template mentioned above. But this will affect all overridden methods not only the equals method.

       
    • Werner Ackerl
      Werner Ackerl
      2007-09-20

      thanks for the pointer, got it working now.
      (maybe something like the ${see_to_overridden} construct of the eclipse templates might make a nice enhancement in a future version?)

      one other problem: the .rs() method can't handle constant names after the pattern [A-Z][A-Z0-9_]* properly.
      "NUMBER_OF_QUESTIONS" turns to "NUMBE r_ o f_ questions"

      i'm working around this for now by having declared an extra field template for names of this pattern.