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/core/src/lombok | |
parent | 7dfbe4323c15cbd88983380b27a250d2a381d148 (diff) | |
download | lombok-2b4b5c983540af4a4c08cfb7a3d4057df0b84c39.tar.gz lombok-2b4b5c983540af4a4c08cfb7a3d4057df0b84c39.tar.bz2 lombok-2b4b5c983540af4a4c08cfb7a3d4057df0b84c39.zip |
Support javadoc copying in eclipse
Diffstat (limited to 'test/core/src/lombok')
-rw-r--r-- | test/core/src/lombok/RunTestsViaEcj.java | 43 |
1 files changed, 41 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; + } + } } |