diff options
author | Roman Shevchenko <roman.shevchenko@jetbrains.com> | 2014-05-26 15:47:00 +0400 |
---|---|---|
committer | Roman Shevchenko <roman.shevchenko@jetbrains.com> | 2014-05-26 15:49:53 +0400 |
commit | 27f08da5cbeca38640327d36feff6274f72cc7b0 (patch) | |
tree | 6f9920bab4293492510ffcca542b12fd57719d92 /src | |
parent | 9e231a7e2e86c7e9030667f22b9fa66af96b7b72 (diff) | |
download | fernflower-27f08da5cbeca38640327d36feff6274f72cc7b0.tar fernflower-27f08da5cbeca38640327d36feff6274f72cc7b0.tar.gz fernflower-27f08da5cbeca38640327d36feff6274f72cc7b0.tar.lz fernflower-27f08da5cbeca38640327d36feff6274f72cc7b0.tar.xz fernflower-27f08da5cbeca38640327d36feff6274f72cc7b0.zip |
deprecation comments generation changed once again
new behavior:
- depreaction comment (/** @deprecated */) is added always
- @Deprecated annotation is added only when presented in .class file
rationale:
- both deprecation comment and @Deprecated anno produce "Deprecated" attribute
- adding annotation to members deprecated by comment (old behavior) is actually incorrect
- adding comment to members deprecated by annotation may be incorrect but is acceptable (there is no way to tell if a member was deprecated by sole annotation or both by annotation and comment)
- additional configuration option is therefore no longer needed
Diffstat (limited to 'src')
-rw-r--r-- | src/de/fernflower/main/ClassWriter.java | 58 | ||||
-rw-r--r-- | src/de/fernflower/main/extern/IFernflowerPreferences.java | 1 |
2 files changed, 14 insertions, 45 deletions
diff --git a/src/de/fernflower/main/ClassWriter.java b/src/de/fernflower/main/ClassWriter.java index 54a490e..a500fa4 100644 --- a/src/de/fernflower/main/ClassWriter.java +++ b/src/de/fernflower/main/ClassWriter.java @@ -344,25 +344,15 @@ public class ClassWriter { writer.newLine(); } } - - // class annotations - boolean hasDeprecatedAnno = false; - List<AnnotationExprent> lstAnn = getAllAnnotations(cl.getAttributes()); - for(AnnotationExprent annexpr : lstAnn) { - if("java/lang/Deprecated".equals(annexpr.getClassname())) { - hasDeprecatedAnno = true; - } - } - if ((isDeprecated || hasDeprecatedAnno) && DecompilerContext.getOption(IFernflowerPreferences.DEPRECATED_COMMENT)) { + + if(isDeprecated) { writer.write(indstr); writer.write("/** @deprecated */"); writer.newLine(); } - if(isDeprecated && !hasDeprecatedAnno) { - writer.write(indstr); - writer.write("@Deprecated"); - writer.newLine(); - } + + // class annotations + List<AnnotationExprent> lstAnn = getAllAnnotations(cl.getAttributes()); for(AnnotationExprent annexpr : lstAnn) { writer.write(annexpr.toJava(indent)); writer.newLine(); @@ -490,25 +480,15 @@ 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())) { - hasDeprecatedAnno = true; - } - } - if ((isDeprecated || hasDeprecatedAnno) && DecompilerContext.getOption(IFernflowerPreferences.DEPRECATED_COMMENT)) { + + if(isDeprecated) { writer.write(indstr); writer.write("/** @deprecated */"); writer.newLine(); } - if(isDeprecated && !hasDeprecatedAnno) { - writer.write(indstr); - writer.write("@Deprecated"); - writer.newLine(); - } + + // field annotations + List<AnnotationExprent> lstAnn = getAllAnnotations(fd.getAttributes()); for(AnnotationExprent annexpr : lstAnn) { writer.write(annexpr.toJava(indent)); writer.newLine(); @@ -729,24 +709,14 @@ 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())) { - hasDeprecatedAnno = true; - } - } - if ((isDeprecated || hasDeprecatedAnno) && DecompilerContext.getOption(IFernflowerPreferences.DEPRECATED_COMMENT)) { + if(isDeprecated) { writer.write(indstr); writer.write("/** @deprecated */"); writer.newLine(); } - if(isDeprecated && !hasDeprecatedAnno) { - bufstrwriter.write(indstr); - bufstrwriter.write("@Deprecated"); - bufstrwriter.newLine(); - } + + // method annotations + List<AnnotationExprent> lstAnn = getAllAnnotations(mt.getAttributes()); for(AnnotationExprent annexpr : lstAnn) { bufstrwriter.write(annexpr.toJava(indent)); bufstrwriter.newLine(); diff --git a/src/de/fernflower/main/extern/IFernflowerPreferences.java b/src/de/fernflower/main/extern/IFernflowerPreferences.java index 0d3ea52..35b17de 100644 --- a/src/de/fernflower/main/extern/IFernflowerPreferences.java +++ b/src/de/fernflower/main/extern/IFernflowerPreferences.java @@ -46,7 +46,6 @@ public interface IFernflowerPreferences { public static final String LOG_LEVEL = "log"; - public static final String DEPRECATED_COMMENT = "dpc"; public static final String NEW_LINE_SEPARATOR = "nls"; public static final String IDEA_NOT_NULL_ANNOTATION = "inn"; public static final String LAMBDA_TO_ANONYMOUS_CLASS = "lac"; |