diff options
author | Rawi01 <Rawi01@users.noreply.github.com> | 2020-07-29 12:55:02 +0200 |
---|---|---|
committer | Rawi01 <Rawi01@users.noreply.github.com> | 2020-07-29 13:39:42 +0200 |
commit | 2b4b5c983540af4a4c08cfb7a3d4057df0b84c39 (patch) | |
tree | 78a310e0f6d611d2113caf9a4b0a38889ac1926f /test | |
parent | 7dfbe4323c15cbd88983380b27a250d2a381d148 (diff) | |
download | lombok-2b4b5c983540af4a4c08cfb7a3d4057df0b84c39.tar.gz lombok-2b4b5c983540af4a4c08cfb7a3d4057df0b84c39.tar.bz2 lombok-2b4b5c983540af4a4c08cfb7a3d4057df0b84c39.zip |
Support javadoc copying in eclipse
Diffstat (limited to 'test')
8 files changed, 146 insertions, 2 deletions
diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java index ab28cb0c..3a6e1702 100644 --- a/test/core/src/lombok/RunTestsViaEcj.java +++ b/test/core/src/lombok/RunTestsViaEcj.java @@ -36,16 +36,17 @@ import lombok.eclipse.Eclipse; import lombok.javac.CapturingDiagnosticListener.CompilerMessage; import org.eclipse.jdt.core.compiler.CategorizedProblem; +import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.Compiler; import org.eclipse.jdt.internal.compiler.ICompilerRequestor; import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; -import org.eclipse.jdt.internal.compiler.batch.CompilationUnit; import org.eclipse.jdt.internal.compiler.batch.FileSystem; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; +import org.eclipse.jdt.internal.core.CompilationUnit; public class RunTestsViaEcj extends AbstractRunTests { protected CompilerOptions ecjCompilerOptions() { @@ -103,7 +104,7 @@ public class RunTestsViaEcj extends AbstractRunTests { }; String source = readFile(file); - final CompilationUnit sourceUnit = new CompilationUnit(source.toCharArray(), file.getName(), encoding == null ? "UTF-8" : encoding); + final CompilationUnit sourceUnit = new TestCompilationUnit(file.getName(), source); Compiler ecjCompiler = new Compiler(createFileSystem(file, minVersion), ecjErrorHandlingPolicy(), ecjCompilerOptions(), bitbucketRequestor, new DefaultProblemFactory(Locale.ENGLISH)) { @Override protected synchronized void addCompilationUnit(ICompilationUnit inUnit, CompilationUnitDeclaration parsedUnit) { @@ -150,4 +151,42 @@ public class RunTestsViaEcj extends AbstractRunTests { } return new FileSystem(classpath.toArray(new String[0]), new String[] {file.getAbsolutePath()}, "UTF-8"); } + + private static final class TestCompilationUnit extends CompilationUnit { + private final char[] source; + private final char[] mainTypeName; + + private TestCompilationUnit(String name, String source) { + super(null, name, null); + this.source = source.toCharArray(); + + char[] fileNameCharArray = getFileName(); + int start = CharOperation.lastIndexOf(File.separatorChar, fileNameCharArray) + 1; + int end = CharOperation.lastIndexOf('.', fileNameCharArray); + if (end == -1) { + end = fileNameCharArray.length; + } + mainTypeName = CharOperation.subarray(fileNameCharArray, start, end); + } + + @Override public char[] getContents() { + return source; + } + + @Override public char[] getMainTypeName() { + return mainTypeName; + } + + @Override public boolean ignoreOptionalProblems() { + return false; + } + + @Override public char[][] getPackageName() { + return null; + } + + @Override public char[] getModuleName() { + return null; + } + } } diff --git a/test/transform/resource/after-ecj/BuilderJavadoc.java b/test/transform/resource/after-ecj/BuilderJavadoc.java index 445b5417..3afd3be2 100644 --- a/test/transform/resource/after-ecj/BuilderJavadoc.java +++ b/test/transform/resource/after-ecj/BuilderJavadoc.java @@ -16,10 +16,21 @@ import java.util.List; @java.lang.SuppressWarnings("all") BuilderJavadocBuilder() { super(); } + /** + * basic gets only a builder setter. + * @see #getsetwith + * @param tag is moved to the setter. + * @return {@code this}. + */ public @java.lang.SuppressWarnings("all") BuilderJavadoc.BuilderJavadocBuilder<T> basic(final int basic) { this.basic = basic; return this; } + /** + * getsetwith gets a builder setter, an instance getter and setter, and a wither. + * @param tag is moved to the setters and wither. + * @return {@code this}. + */ public @java.lang.SuppressWarnings("all") BuilderJavadoc.BuilderJavadocBuilder<T> getsetwith(final int getsetwith) { this.getsetwith = getsetwith; return this; @@ -45,12 +56,26 @@ import java.util.List; public static @java.lang.SuppressWarnings("all") <T>BuilderJavadoc.BuilderJavadocBuilder<T> builder() { return new BuilderJavadoc.BuilderJavadocBuilder<T>(); } + /** + * getsetwith gets a builder setter, an instance getter and setter, and a wither. + * + * @return tag is moved to the getter. + */ public @java.lang.SuppressWarnings("all") int getGetsetwith() { return this.getsetwith; } + /** + * getsetwith gets a builder setter, an instance getter and setter, and a wither. + * @param tag is moved to the setters and wither. + */ public @java.lang.SuppressWarnings("all") void setGetsetwith(final int getsetwith) { this.getsetwith = getsetwith; } + /** + * getsetwith gets a builder setter, an instance getter and setter, and a wither. + * @param tag is moved to the setters and wither. + * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed). + */ public @java.lang.SuppressWarnings("all") BuilderJavadoc<T> withGetsetwith(final int getsetwith) { return ((this.getsetwith == getsetwith) ? this : new BuilderJavadoc<T>(this.basic, getsetwith, this.predef, this.predefWithJavadoc)); } diff --git a/test/transform/resource/after-ecj/BuilderWithDeprecated.java b/test/transform/resource/after-ecj/BuilderWithDeprecated.java index 724a25e6..65326a66 100644 --- a/test/transform/resource/after-ecj/BuilderWithDeprecated.java +++ b/test/transform/resource/after-ecj/BuilderWithDeprecated.java @@ -10,6 +10,10 @@ public @Builder class BuilderWithDeprecated { @java.lang.SuppressWarnings("all") BuilderWithDeprecatedBuilder() { super(); } + /** + * @deprecated since always + * @return {@code this}. + */ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") BuilderWithDeprecated.BuilderWithDeprecatedBuilder dep1(final String dep1) { this.dep1 = dep1; return this; diff --git a/test/transform/resource/after-ecj/GetterDeprecated.java b/test/transform/resource/after-ecj/GetterDeprecated.java index 546f7fb7..087a60b8 100644 --- a/test/transform/resource/after-ecj/GetterDeprecated.java +++ b/test/transform/resource/after-ecj/GetterDeprecated.java @@ -8,6 +8,9 @@ class GetterDeprecated { public @java.lang.Deprecated @java.lang.SuppressWarnings("all") int getAnnotation() { return this.annotation; } + /** + * @deprecated + */ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") int getJavadoc() { return this.javadoc; } diff --git a/test/transform/resource/after-ecj/GetterSetterJavadoc.java b/test/transform/resource/after-ecj/GetterSetterJavadoc.java index 4923fd02..c3308c51 100644 --- a/test/transform/resource/after-ecj/GetterSetterJavadoc.java +++ b/test/transform/resource/after-ecj/GetterSetterJavadoc.java @@ -1,8 +1,18 @@ @lombok.Data class GetterSetterJavadoc1 { private int fieldName; + /** + * Getter section + * + * @return Sky is blue1 + */ public @java.lang.SuppressWarnings("all") int getFieldName() { return this.fieldName; } + /** + * Some text + * + * @param fieldName Hello, World1 + */ public @java.lang.SuppressWarnings("all") void setFieldName(final int fieldName) { this.fieldName = fieldName; } @@ -39,9 +49,19 @@ class GetterSetterJavadoc2 { GetterSetterJavadoc2() { super(); } + /** + * Some text + * + * @return Sky is blue2 + */ public @java.lang.SuppressWarnings("all") int getFieldName() { return this.fieldName; } + /** + * Some text + * + * @param fieldName Hello, World2 + */ public @java.lang.SuppressWarnings("all") void setFieldName(final int fieldName) { this.fieldName = fieldName; } @@ -51,9 +71,17 @@ class GetterSetterJavadoc3 { GetterSetterJavadoc3() { super(); } + /** + * Getter section + * @return Sky is blue3 + */ public @java.lang.SuppressWarnings("all") int getFieldName() { return this.fieldName; } + /** + * Setter section + * @param fieldName Hello, World3 + */ public @java.lang.SuppressWarnings("all") void setFieldName(final int fieldName) { this.fieldName = fieldName; } @@ -63,9 +91,20 @@ class GetterSetterJavadoc3 { GetterSetterJavadoc4() { super(); } + /** + * Some text + * + * @return Sky is blue4 + */ public @java.lang.SuppressWarnings("all") int fieldName() { return this.fieldName; } + /** + * Some text + * + * @param fieldName Hello, World4 + * @return {@code this}. + */ public @java.lang.SuppressWarnings("all") GetterSetterJavadoc4 fieldName(final int fieldName) { this.fieldName = fieldName; return this; @@ -76,9 +115,18 @@ class GetterSetterJavadoc3 { GetterSetterJavadoc5() { super(); } + /** + * Getter section + * @return Sky is blue5 + */ public @java.lang.SuppressWarnings("all") int fieldName() { return this.fieldName; } + /** + * Setter section + * @param fieldName Hello, World5 + * @return Sky is blue5 + */ public @java.lang.SuppressWarnings("all") GetterSetterJavadoc5 fieldName(final int fieldName) { this.fieldName = fieldName; return this; diff --git a/test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java b/test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java index dd64e358..c95b7bab 100644 --- a/test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java +++ b/test/transform/resource/after-ecj/SetterAndWithMethodJavadoc.java @@ -7,15 +7,33 @@ class SetterAndWithMethodJavadoc { this.i = i; this.j = j; } + /** + * Some value. + * @param the new value + */ public @java.lang.SuppressWarnings("all") void setI(final int i) { this.i = i; } + /** + * Some value. + * @param the new value + * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed). + */ public @java.lang.SuppressWarnings("all") SetterAndWithMethodJavadoc withI(final int i) { return ((this.i == i) ? this : new SetterAndWithMethodJavadoc(i, this.j)); } + /** + * Set some other value. + * @param the new other value + */ public @java.lang.SuppressWarnings("all") void setJ(final int j) { this.j = j; } + /** + * Reinstantiate with some other value. + * @param the other new other value + * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed). + */ public @java.lang.SuppressWarnings("all") SetterAndWithMethodJavadoc withJ(final int j) { return ((this.j == j) ? this : new SetterAndWithMethodJavadoc(this.i, j)); } diff --git a/test/transform/resource/after-ecj/SetterDeprecated.java b/test/transform/resource/after-ecj/SetterDeprecated.java index d76612b7..cc089566 100644 --- a/test/transform/resource/after-ecj/SetterDeprecated.java +++ b/test/transform/resource/after-ecj/SetterDeprecated.java @@ -8,6 +8,9 @@ class SetterDeprecated { public @java.lang.Deprecated @java.lang.SuppressWarnings("all") void setAnnotation(final int annotation) { this.annotation = annotation; } + /** + * @deprecated + */ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") void setJavadoc(final int javadoc) { this.javadoc = javadoc; } diff --git a/test/transform/resource/after-ecj/WithMethodMarkedDeprecated.java b/test/transform/resource/after-ecj/WithMethodMarkedDeprecated.java index cd123fe8..4220308c 100644 --- a/test/transform/resource/after-ecj/WithMethodMarkedDeprecated.java +++ b/test/transform/resource/after-ecj/WithMethodMarkedDeprecated.java @@ -8,6 +8,10 @@ class WithMethodMarkedDeprecated { public @java.lang.Deprecated @java.lang.SuppressWarnings("all") WithMethodMarkedDeprecated withAnnotation(final int annotation) { return ((this.annotation == annotation) ? this : new WithMethodMarkedDeprecated(annotation, this.javadoc)); } + /** + * @deprecated + * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed). + */ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") WithMethodMarkedDeprecated withJavadoc(final int javadoc) { return ((this.javadoc == javadoc) ? this : new WithMethodMarkedDeprecated(this.annotation, javadoc)); } |