通过反编译技术,修改ECLIPSE的org.eclipse.jdt.ui_3.3.1.r331_v20070906.jar包中的
org.eclipse.jdt.internal.corext.codemanipulation.GetterSetterUtil类
下的getSetterStub及getGetterStub函数,来实现生成getter/setter时,注释使用成员的注释(如果成员的注释有的话,如果没有则使用注释模板生成,如果选择了生成getter/setter需要生成code comment的话)
getSetterStub函数修改的地方为:
将原:
if(addComments)
{
String comment = CodeGeneration.getSetterComment(field.getCompilationUnit(), parentType.getTypeQualifiedName('.'), setterName, field.getElementName(), typeName, argname, accessorName, lineDelim);
?
修改为:
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() );?
getGetterStub函数修改的地方为:
将原:
if(addComments) { String comment = CodeGeneration.getGetterComment(field.getCompilationUnit(), parentType.getTypeQualifiedName('.'), getterName, field.getElementName(), typeName, accessorName, lineDelim);?
修改为:
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() );?