[#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.

This commit is contained in:
Reinier Zwitserloot committed 2018-08-21 00:14:03 +02:00
1 parent 42c96d92fd
commit f83488af9c
2 files changed
+13 -5

No files matched your search

+2 -1
View File
@@ -2,7 +2,8 @@ Lombok Changelog
----------------
### v1.18.3 "Edgy Guinea Pig"
* FEATURE: THe `@FieldNameConstants` feature has been completely redesigned. [Issue #1774](https://github.com/rzwitserloot/lombok/issues/1774) [FieldNameConstants documentation](https://projectlombok.org/features/experimental/FieldNameConstants)
* FEATURE: The `@FieldNameConstants` feature has been completely redesigned. [Issue #1774](https://github.com/rzwitserloot/lombok/issues/1774) [FieldNameConstants documentation](https://projectlombok.org/features/experimental/FieldNameConstants)
* BUGFIX: When using lombok to compile modularized (`module-info.java`-style) code, if the module name has dots in it, it wouldn't work. [Issue #1808](https://github.com/rzwitserloot/lombok/issues/1808)
### v1.18.2 (July 26th, 2018)
* BUGFIX: mapstruct + lombok in eclipse should hopefully work again. [Issue #1359](https://github.com/rzwitserloot/lombok/issues/1359) and [mapstruct issue #1159](https://github.com/mapstruct/mapstruct/issues/1159)
+11 -4
View File
@@ -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;