When coding a realistic class, it is found that an entity class has a lot of fields to annotate, they're all private, they can't be accessed directly, and the documentation comments we added when we wrote it didn't work, but the documentation comments for the auto-generated Get,set method did not meet our requirements (no documentation comments in the containing fields) So it's very tangled. On the Internet to see some of the great God has a solution to try the next can, take out and share with you.
Modified Effect Chart:
Steps:
1: Search in Myeclipse/eclisp to find Org.eclipse.jdt.ui_*.jar (* is version number)
2: Change the jar file to a. rar format and open (it is best to back up this jar file before modifying it)
3: Find \org\eclipse\jdt\internal\corext\ Codemanipulation This directory under the Gettersetterutil.class this file, and download me to provide compressed files under the file replace this one file on it
4: Open the development tool to find Window->preferences->java->codestyle->code templates->comments->getters/setters
Specific code Modifications:
By recompiling the technology, you modify the Org.eclipse.jdt.ui_3.3.1.r331_v20070906.jar package in the eclipse
Org.eclipse.jdt.internal.corext.codemanipulation.GetterSetterUtil class
The getsetterstub and GETGETTERSTUB functions below to implement the build Getter/setter, the annotation uses the annotation of the member (if the member's comment is there, if not, use the annotation template to generate, if the build getter/is selected Setter needs to generate code comment.)
The Getsetterstub function is modified in the following places:
The original:
if (addcomments)
{
String comment = codegeneration.getsettercomment (Field.getcompilationunit (), Parenttype.gettypequalifiedname ('. '), Settername, Field.getelementname (), TypeName, Argname, Accessorname, Linedelim);
Modified to:
if (addcomments)
{
String comment = codegeneration.getsettercomment (Field.getcompilationunit (), Parenttype.gettypequalifiedname ('. '), Settername, Field.getelementname (), TypeName, Argname, Accessorname, Linedelim);
Isourcerange sr = Field.getjavadocrange ();
if (null!= SR)
Comment = Field.getsource (). substring (0, sr.getlength ());
The Getgetterstub function is modified in the following places:
The original:
if (addcomments)
{
String comment = codegeneration.getgettercomment (Field.getcompilationunit (), Parenttype.gettypequalifiedname ('. '), Gettername, Field.getelementname (), TypeName, Accessorname, Linedelim);
Modified to:
if (addcomments)
{
String comment = codegeneration.getgettercomment (Field.getcompilationunit (), Parenttype.gettypequalifiedname ('. '), Gettername, Field.getelementname (), TypeName, Accessorname, Linedelim);
Isourcerange sr = Field.getjavadocrange ();
if (null!= SR)
Comment = Field.getsource (). substring (0, sr.getlength ());
Getters:/** * Get ${bare_field_name} * @return ${bare_field_name} ${bare_field_name}/setters:/** * Set ${bare_field_name} * @param ${bare_field_name} ${bare_field_name} * *
Note: Generate method is selected when generating Get/set methods comments
I tested successfully in the myeclips8.6. We can try.
MyEclipse10 available