deprecation comments generation fixed

master
Roman Shevchenko 11 years ago
parent e1efc66c86
commit 6c2cc096fb
  1. 81
      src/de/fernflower/main/ClassWriter.java

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

Loading…
Cancel
Save