diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-08-21 00:13:03 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-08-21 00:14:03 +0200 |
commit | f83488af9c3a1e1d1906601aec60a55579dd4d90 (patch) | |
tree | edea3566f88fd253ad131d540e64ddbb326c590c /src/core/lombok/javac | |
parent | 42c96d92fd5a9b362eba0ceb75c35da906de130f (diff) | |
download | lombok-f83488af9c3a1e1d1906601aec60a55579dd4d90.tar.gz lombok-f83488af9c3a1e1d1906601aec60a55579dd4d90.tar.bz2 lombok-f83488af9c3a1e1d1906601aec60a55579dd4d90.zip |
[#1808] Probable fix: Using module names with dots in them was causing issues, as we only use the simple name. Actually getting the full module name is a little tricky, but this should do the job.
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r-- | src/core/lombok/javac/apt/LombokProcessor.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/core/lombok/javac/apt/LombokProcessor.java b/src/core/lombok/javac/apt/LombokProcessor.java index 89608546..26e16d32 100644 --- a/src/core/lombok/javac/apt/LombokProcessor.java +++ b/src/core/lombok/javac/apt/LombokProcessor.java @@ -43,6 +43,7 @@ import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; import javax.lang.model.SourceVersion; import javax.lang.model.element.Element; +import javax.lang.model.element.QualifiedNameable; import javax.lang.model.element.TypeElement; import javax.tools.Diagnostic.Kind; import javax.tools.JavaFileManager; @@ -380,10 +381,7 @@ public class LombokProcessor extends AbstractProcessor { private String getModuleNameFor(Element element) { while (element != null) { - if (element.getKind().name().equals("MODULE")) { - String n = element.getSimpleName().toString().trim(); - return n.isEmpty() ? null : n; - } + if (element.getKind().name().equals("MODULE")) return ModuleNameOracle.getModuleName(element); Element n = element.getEnclosingElement(); if (n == element) return null; element = n; @@ -391,6 +389,15 @@ public class LombokProcessor extends AbstractProcessor { return null; } + // QualifiedNameable is a java7 thing, so to remain compatible with java6, shove this into an inner class to avoid the ClassNotFoundError. + private static class ModuleNameOracle { + static String getModuleName(Element element) { + if (!(element instanceof QualifiedNameable)) return null; + String name = ((QualifiedNameable) element).getQualifiedName().toString().trim(); + return name.isEmpty() ? null : name; + } + } + private JCCompilationUnit toUnit(Element element) { TreePath path = trees == null ? null : trees.getPath(element); if (path == null) return null; |