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
This commit is contained in:
1
dist/docs/readme.txt
vendored
1
dist/docs/readme.txt
vendored
@@ -63,7 +63,6 @@ ren (0): rename ambiguous (resp. obfuscated) classes and class elements
|
|||||||
urc : full name of user-supplied class implementing IIdentifierRenamer. It is used to determine which
|
urc : full name of user-supplied class implementing IIdentifierRenamer. It is used to determine which
|
||||||
class identifiers should be renamed and provides new identifier names. For more information
|
class identifiers should be renamed and provides new identifier names. For more information
|
||||||
s. section 5
|
s. section 5
|
||||||
dpc (0): generate a special comment ('/** @deprecated */') for deprecated classes and class members
|
|
||||||
inn (1): check for IntelliJ IDEA-specific @NotNull annotation and remove inserted code if found
|
inn (1): check for IntelliJ IDEA-specific @NotNull annotation and remove inserted code if found
|
||||||
lac (0): decompile lambda expressions to anonymous classes
|
lac (0): decompile lambda expressions to anonymous classes
|
||||||
nls (0): define new line character to be used for output. 0 - '\r\n' (Windows), 1 - '\n' (Linux)
|
nls (0): define new line character to be used for output. 0 - '\r\n' (Windows), 1 - '\n' (Linux)
|
||||||
|
|||||||
@@ -345,24 +345,14 @@ public class ClassWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// class annotations
|
if(isDeprecated) {
|
||||||
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)) {
|
|
||||||
writer.write(indstr);
|
writer.write(indstr);
|
||||||
writer.write("/** @deprecated */");
|
writer.write("/** @deprecated */");
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
}
|
}
|
||||||
if(isDeprecated && !hasDeprecatedAnno) {
|
|
||||||
writer.write(indstr);
|
// class annotations
|
||||||
writer.write("@Deprecated");
|
List<AnnotationExprent> lstAnn = getAllAnnotations(cl.getAttributes());
|
||||||
writer.newLine();
|
|
||||||
}
|
|
||||||
for(AnnotationExprent annexpr : lstAnn) {
|
for(AnnotationExprent annexpr : lstAnn) {
|
||||||
writer.write(annexpr.toJava(indent));
|
writer.write(annexpr.toJava(indent));
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
@@ -491,24 +481,14 @@ public class ClassWriter {
|
|||||||
|
|
||||||
boolean isDeprecated = fd.getAttributes().containsKey("Deprecated");
|
boolean isDeprecated = fd.getAttributes().containsKey("Deprecated");
|
||||||
|
|
||||||
// field annotations
|
if(isDeprecated) {
|
||||||
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)) {
|
|
||||||
writer.write(indstr);
|
writer.write(indstr);
|
||||||
writer.write("/** @deprecated */");
|
writer.write("/** @deprecated */");
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
}
|
}
|
||||||
if(isDeprecated && !hasDeprecatedAnno) {
|
|
||||||
writer.write(indstr);
|
// field annotations
|
||||||
writer.write("@Deprecated");
|
List<AnnotationExprent> lstAnn = getAllAnnotations(fd.getAttributes());
|
||||||
writer.newLine();
|
|
||||||
}
|
|
||||||
for(AnnotationExprent annexpr : lstAnn) {
|
for(AnnotationExprent annexpr : lstAnn) {
|
||||||
writer.write(annexpr.toJava(indent));
|
writer.write(annexpr.toJava(indent));
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
@@ -729,24 +709,14 @@ public class ClassWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// method annotations
|
if(isDeprecated) {
|
||||||
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)) {
|
|
||||||
writer.write(indstr);
|
writer.write(indstr);
|
||||||
writer.write("/** @deprecated */");
|
writer.write("/** @deprecated */");
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
}
|
}
|
||||||
if(isDeprecated && !hasDeprecatedAnno) {
|
|
||||||
bufstrwriter.write(indstr);
|
// method annotations
|
||||||
bufstrwriter.write("@Deprecated");
|
List<AnnotationExprent> lstAnn = getAllAnnotations(mt.getAttributes());
|
||||||
bufstrwriter.newLine();
|
|
||||||
}
|
|
||||||
for(AnnotationExprent annexpr : lstAnn) {
|
for(AnnotationExprent annexpr : lstAnn) {
|
||||||
bufstrwriter.write(annexpr.toJava(indent));
|
bufstrwriter.write(annexpr.toJava(indent));
|
||||||
bufstrwriter.newLine();
|
bufstrwriter.newLine();
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ public interface IFernflowerPreferences {
|
|||||||
|
|
||||||
public static final String LOG_LEVEL = "log";
|
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 NEW_LINE_SEPARATOR = "nls";
|
||||||
public static final String IDEA_NOT_NULL_ANNOTATION = "inn";
|
public static final String IDEA_NOT_NULL_ANNOTATION = "inn";
|
||||||
public static final String LAMBDA_TO_ANONYMOUS_CLASS = "lac";
|
public static final String LAMBDA_TO_ANONYMOUS_CLASS = "lac";
|
||||||
|
|||||||
Reference in New Issue
Block a user