diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2020-12-27 05:36:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-27 05:36:51 +0100 |
commit | 11b6f8f97a6fde9a5f6e39f38e63cdff73742822 (patch) | |
tree | 733b5a65b754f325fa9273d11fb840a7e0002398 /src/eclipseAgent/lombok/eclipse/agent | |
parent | 0532285eb8de98e9e4e3fc4131476b5f4ef2740d (diff) | |
parent | 624c8a5a52d14ba1a6b690809f9ada15f71e15f5 (diff) | |
download | lombok-11b6f8f97a6fde9a5f6e39f38e63cdff73742822.tar.gz lombok-11b6f8f97a6fde9a5f6e39f38e63cdff73742822.tar.bz2 lombok-11b6f8f97a6fde9a5f6e39f38e63cdff73742822.zip |
Merge pull request #2684 from Rawi01/npe-javadoc
Fix NullPointerException during Javadoc copy
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(); } /** |