0

This Eclipse question is a response to "Getting rid of the comment above eclipse generated serialVersionUID," but so far the single answer (which addresses this linked question, and is accepted) applies to all comments.

But my question will be more specific (it is not a duplicate) - I want normal generation of comments for other fields, just no generation of the comment when you quick-fix the serializable warning by generating the field.

As what the accepted answer to the original question, the answerer stated that

It's using the template for any eclipse-generated field.

You can change it in

 Preferences -> 
     Java -> 
        Code Style -> 
           Code Templates -> 
              Comments -> 
                 Fields

and then blank out the pattern.

Though you can prevent comment generation (or change the comment template) for all fields, is there any way to prevent or change auto-comment-generation just for the serialVersionUID field?

  • Possible duplicate of [Getting rid of the comment above eclipse generated serialVersionUID](https://stackoverflow.com/questions/21631089/getting-rid-of-the-comment-above-eclipse-generated-serialversionuid) – skomisa Jul 04 '18 at 04:21
  • Vote to close as a duplicate. You correctly cite the duplicate question, but then just ask that same question again! While appearing to extend that problem to cover more than one _"type of generated field"_, that changes nothing since _"type of generated field"_ is a construct invented by you, not Eclipse. With respect to comment generation Eclipse offers no granularity for fields, and seeking proof that there is no option for each _"type of generated field"_ is meaningless. – skomisa Jul 04 '18 at 04:41
  • @skomisa Sure. For the canonical question, I'll answer this question to state that there isn't a way to do so for each "type of generated field", and therefore all the templates affect all "types of generated field." In case this question gets duped, flag to merge it to the canonical question. – Ṃųỻịgǻňạcểơửṩ Jul 04 '18 at 05:01
  • The asker suspected there is no way to do so. – Ṃųỻịgǻňạcểơửṩ Jul 04 '18 at 05:12
  • @skomisa I am sorry I found some unclarity between "generated field" and "generated comment". I realized that the "auto-generated comment" performs the generation when you generate comments for any field, but it does it automatically when you quick-fix the serializable warning. I have removed the "type of generated field" that is invented by me to clarify the question. It is that the auto-generated comment for `serialVersionUID` applies just for the quick fix, I want everything else unchanged. – Ṃųỻịgǻňạcểơửṩ Jul 04 '18 at 05:35
  • OK, though now it seems that this question is an even closer duplicate of the other post, having removed the "type of generated field" stuff. That said, the accepted (and only) answer for that question clearly does not address your concern so I have withdrawn my close vote for your question. – skomisa Jul 04 '18 at 06:03
  • @skomisa Thank you. I am currently writing my extended solution to the first accepted one to give more detail, hopefully also addressing this question. – Ṃųỻịgǻňạcểơửṩ Jul 04 '18 at 06:04
  • 1
    FYI, see [serialVersionUID template](https://www.eclipse.org/forums/index.php/t/165723/), and in particular the response _"There's no specific code template for that"_. That was from 2010 but my guess is that you still can't do what you want, and you would need to raise it as a feature request with Eclipse. – skomisa Jul 04 '18 at 06:13
  • @skimosa I have posted my answer to the original answer, and self-answered my question negatively. I have extended upon skim's answer indicating that the auto-generated comments specifically refers to the quick-fix, and that it also applies when you *generate element comment* for that field. I provided examples and a more detailed example from skim's answer. – Ṃųỻịgǻňạcểơửṩ Jul 04 '18 at 06:43

1 Answers1

0

There isn't a way to prevent the auto-generation of comments for the SerialVersionUID through quick-fixing without blanking the comment generation template for all fields.

Nevertheless, it doesn't matter as simply blanking the comment template as addressed in the original question is sufficient, as the auto-generation applies to a very narrow range of scenarios, including this quick-fix.

The comment template is normally generated when you generate element comment from the Source either from the toolbar or by right-clicking the field, and that is entirely optional.