diff options
author | Rawi01 <Rawi01@users.noreply.github.com> | 2020-12-19 11:44:31 +0100 |
---|---|---|
committer | Rawi01 <Rawi01@users.noreply.github.com> | 2020-12-20 14:03:28 +0100 |
commit | 626c33255bbac12ddab72dda7de2447132f29ae4 (patch) | |
tree | 2d4ad6ba4229cf9a6feb1e4c6c81286ab29ae702 /src/eclipseAgent/lombok/eclipse/agent | |
parent | f17dd036384242971546bc443749ad527b8cd21c (diff) | |
download | lombok-626c33255bbac12ddab72dda7de2447132f29ae4.tar.gz lombok-626c33255bbac12ddab72dda7de2447132f29ae4.tar.bz2 lombok-626c33255bbac12ddab72dda7de2447132f29ae4.zip |
[tests] Support javadoc in ecj tests
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 2 | ||||
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/PatchJavadoc.java | 49 |
2 files changed, 25 insertions, 26 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index d5077b86..171fa8a9 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -916,7 +916,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .requestExtra(StackRequest.PARAM1) .build()); - sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.replaceMethodCall() + sm.addScript(ScriptBuilder.replaceMethodCall() .target(new MethodTarget("org.eclipse.jdt.internal.compiler.ast.TypeDeclaration", "printBody", "java.lang.StringBuffer", "int", "java.lang.StringBuffer")) .methodToReplace(new Hook("org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration", "print", "java.lang.StringBuffer", "int", "java.lang.StringBuffer")) .replacementMethod(new Hook("lombok.launch.PatchFixesHider$Javadoc", "printMethod", "java.lang.StringBuffer", "org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration", "int", "java.lang.StringBuffer", "org.eclipse.jdt.internal.compiler.ast.TypeDeclaration")) diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchJavadoc.java b/src/eclipseAgent/lombok/eclipse/agent/PatchJavadoc.java index f5678154..5b34917e 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchJavadoc.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchJavadoc.java @@ -21,7 +21,7 @@ */ package lombok.eclipse.agent; -import static lombok.eclipse.EcjAugments.EclipseAugments.CompilationUnit_javadoc; +import static lombok.eclipse.EcjAugments.CompilationUnit_javadoc; import java.lang.reflect.Method; import java.util.Map; @@ -41,7 +41,7 @@ import lombok.permit.Permit; public class PatchJavadoc { - public static String getHTMLContentFromSource(String original, IJavaElement member) { + public static String getHTMLContentFromSource(String original, Object member) { if (original != null) { return original; } @@ -51,15 +51,14 @@ public class PatchJavadoc { ICompilationUnit iCompilationUnit = sourceMethod.getCompilationUnit(); if (iCompilationUnit instanceof CompilationUnit) { CompilationUnit compilationUnit = (CompilationUnit) iCompilationUnit; - Map<String, String> docs = CompilationUnit_javadoc.get(compilationUnit); if (docs == null) return null; - String signature = getSignature(sourceMethod); + String signature = Signature.getSignature(sourceMethod); String rawJavadoc = docs.get(signature); if (rawJavadoc == null) return null; - return Reflection.javadoc2HTML((IMember) member, member, rawJavadoc); + return Reflection.javadoc2HTML((IMember) member, (IJavaElement) member, rawJavadoc); } } @@ -67,33 +66,33 @@ public class PatchJavadoc { } public static StringBuffer printMethod(AbstractMethodDeclaration methodDeclaration, Integer tab, StringBuffer output, TypeDeclaration type) { - if (methodDeclaration.compilationResult.compilationUnit instanceof CompilationUnit) { - Map<String, String> docs = CompilationUnit_javadoc.get((CompilationUnit) methodDeclaration.compilationResult.compilationUnit); - if (docs != null) { - String signature = EclipseHandlerUtil.getSignature(type, methodDeclaration); - String rawJavadoc = docs.get(signature); - if (rawJavadoc != null) { - for (String line : rawJavadoc.split("\r?\n")) { - ASTNode.printIndent(tab, output).append(line).append("\n"); - } + Map<String, String> docs = CompilationUnit_javadoc.get(methodDeclaration.compilationResult.compilationUnit); + if (docs != null) { + String signature = EclipseHandlerUtil.getSignature(type, methodDeclaration); + String rawJavadoc = docs.get(signature); + if (rawJavadoc != null) { + for (String line : rawJavadoc.split("\r?\n")) { + ASTNode.printIndent(tab, output).append(line).append("\n"); } } } return methodDeclaration.print(tab, output); } - private static String getSignature(SourceMethod sourceMethod) { - StringBuilder sb = new StringBuilder(); - sb.append(sourceMethod.getParent().getElementName()); - sb.append("."); - sb.append(sourceMethod.getElementName()); - sb.append("("); - for (String type : sourceMethod.getParameterTypes()) { - sb.append(type); + private static class Signature { + static final String getSignature(SourceMethod sourceMethod) { + StringBuilder sb = new StringBuilder(); + sb.append(sourceMethod.getParent().getElementName()); + sb.append("."); + sb.append(sourceMethod.getElementName()); + sb.append("("); + for (String type : sourceMethod.getParameterTypes()) { + sb.append(org.eclipse.jdt.core.Signature.toString(type)); + } + sb.append(")"); + + return sb.toString(); } - sb.append(")"); - - return sb.toString(); } /** |