deprecation comments generation fixed

This commit is contained in:
Roman Shevchenko 2014-05-19 22:24:10 +04:00
parent e1efc66c86
commit 6c2cc096fb

View File

@ -346,11 +346,24 @@ public class ClassWriter {
} }
// class annotations // class annotations
boolean hasDeprecatedAnno = false;
List<AnnotationExprent> lstAnn = getAllAnnotations(cl.getAttributes()); List<AnnotationExprent> lstAnn = getAllAnnotations(cl.getAttributes());
for(AnnotationExprent annexpr : lstAnn) { for(AnnotationExprent annexpr : lstAnn) {
if("java/lang/Deprecated".equals(annexpr.getClassname())) { if("java/lang/Deprecated".equals(annexpr.getClassname())) {
isDeprecated = false; hasDeprecatedAnno = true;
} }
}
if ((isDeprecated || hasDeprecatedAnno) && DecompilerContext.getOption(IFernflowerPreferences.DEPRECATED_COMMENT)) {
writer.write(indstr);
writer.write("/** @deprecated */");
writer.newLine();
}
if(isDeprecated && !hasDeprecatedAnno) {
writer.write(indstr);
writer.write("@Deprecated");
writer.newLine();
}
for(AnnotationExprent annexpr : lstAnn) {
writer.write(annexpr.toJava(indent)); writer.write(annexpr.toJava(indent));
writer.newLine(); writer.newLine();
} }
@ -363,18 +376,6 @@ public class ClassWriter {
writer.newLine(); writer.newLine();
} }
if(isDeprecated) {
if(DecompilerContext.getOption(IFernflowerPreferences.DEPRECATED_COMMENT)) { // special comment for JB
writer.write(indstr);
writer.write("/** @deprecated */");
writer.newLine();
}
writer.write(indstr);
writer.write("@Deprecated");
writer.newLine();
}
writer.write(indstr); writer.write(indstr);
if(isEnum) { if(isEnum) {
@ -488,11 +489,24 @@ public class ClassWriter {
boolean isDeprecated = fd.getAttributes().containsKey("Deprecated"); boolean isDeprecated = fd.getAttributes().containsKey("Deprecated");
// field annotations // field annotations
boolean hasDeprecatedAnno = false;
List<AnnotationExprent> lstAnn = getAllAnnotations(fd.getAttributes()); List<AnnotationExprent> lstAnn = getAllAnnotations(fd.getAttributes());
for(AnnotationExprent annexpr : lstAnn) { for(AnnotationExprent annexpr : lstAnn) {
if("java/lang/Deprecated".equals(annexpr.getClassname())) { if("java/lang/Deprecated".equals(annexpr.getClassname())) {
isDeprecated = false; hasDeprecatedAnno = true;
} }
}
if ((isDeprecated || hasDeprecatedAnno) && DecompilerContext.getOption(IFernflowerPreferences.DEPRECATED_COMMENT)) {
writer.write(indstr);
writer.write("/** @deprecated */");
writer.newLine();
}
if(isDeprecated && !hasDeprecatedAnno) {
writer.write(indstr);
writer.write("@Deprecated");
writer.newLine();
}
for(AnnotationExprent annexpr : lstAnn) {
writer.write(annexpr.toJava(indent)); writer.write(annexpr.toJava(indent));
writer.newLine(); writer.newLine();
} }
@ -506,18 +520,6 @@ public class ClassWriter {
writer.newLine(); writer.newLine();
} }
if(isDeprecated) {
if(DecompilerContext.getOption(IFernflowerPreferences.DEPRECATED_COMMENT)) { // special comment for JB
writer.write(indstr);
writer.write("/** @deprecated */");
writer.newLine();
}
writer.write(indstr);
writer.write("@Deprecated");
writer.newLine();
}
writer.write(indstr); writer.write(indstr);
if(!isEnum) { if(!isEnum) {
@ -725,11 +727,24 @@ public class ClassWriter {
} }
// method annotations // method annotations
boolean hasDeprecatedAnno = false;
List<AnnotationExprent> lstAnn = getAllAnnotations(mt.getAttributes()); List<AnnotationExprent> lstAnn = getAllAnnotations(mt.getAttributes());
for(AnnotationExprent annexpr : lstAnn) { for(AnnotationExprent annexpr : lstAnn) {
if("java/lang/Deprecated".equals(annexpr.getClassname())) { if("java/lang/Deprecated".equals(annexpr.getClassname())) {
isDeprecated = false; hasDeprecatedAnno = true;
} }
}
if ((isDeprecated || hasDeprecatedAnno) && DecompilerContext.getOption(IFernflowerPreferences.DEPRECATED_COMMENT)) {
writer.write(indstr);
writer.write("/** @deprecated */");
writer.newLine();
}
if(isDeprecated && !hasDeprecatedAnno) {
bufstrwriter.write(indstr);
bufstrwriter.write("@Deprecated");
bufstrwriter.newLine();
}
for(AnnotationExprent annexpr : lstAnn) {
bufstrwriter.write(annexpr.toJava(indent)); bufstrwriter.write(annexpr.toJava(indent));
bufstrwriter.newLine(); bufstrwriter.newLine();
} }
@ -749,18 +764,6 @@ public class ClassWriter {
bufstrwriter.newLine(); bufstrwriter.newLine();
} }
if(isDeprecated) {
if(DecompilerContext.getOption(IFernflowerPreferences.DEPRECATED_COMMENT)) { // special comment for JB
writer.write(indstr);
writer.write("/** @deprecated */");
writer.newLine();
}
bufstrwriter.write(indstr);
bufstrwriter.write("@Deprecated");
bufstrwriter.newLine();
}
bufstrwriter.write(indstr); bufstrwriter.write(indstr);
for(int i=0;i<modval_meth.length;i++) { for(int i=0;i<modval_meth.length;i++) {
if(!isInterface || !mod_notinterface_meth.contains(modval_meth[i])) { if(!isInterface || !mod_notinterface_meth.contains(modval_meth[i])) {