diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2023-03-21 17:04:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-21 17:04:45 +0100 |
commit | f22f6d7e135fc86fb7383b0e8b604d328eaf1725 (patch) | |
tree | 7c79215edd15988f9ed21b75bb03092be081f16e | |
parent | f6c9bfba1b0bcc0f1bd0fbdff79aeffe59f28b70 (diff) | |
parent | d5f1f79df67eb7cb0ccbbe2933302bcb39e272a1 (diff) | |
download | lombok-f22f6d7e135fc86fb7383b0e8b604d328eaf1725.tar.gz lombok-f22f6d7e135fc86fb7383b0e8b604d328eaf1725.tar.bz2 lombok-f22f6d7e135fc86fb7383b0e8b604d328eaf1725.zip |
Merge pull request #3355 from dreis2211/module-name-fix
Remove obsolete LombokProcessor.getModuleName
-rw-r--r-- | src/core/lombok/javac/apt/LombokProcessor.java | 41 |
1 files changed, 3 insertions, 38 deletions
diff --git a/src/core/lombok/javac/apt/LombokProcessor.java b/src/core/lombok/javac/apt/LombokProcessor.java index ed713b1d..0467d758 100644 --- a/src/core/lombok/javac/apt/LombokProcessor.java +++ b/src/core/lombok/javac/apt/LombokProcessor.java @@ -25,7 +25,6 @@ import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Field; import java.lang.reflect.InvocationHandler; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.net.URL; @@ -305,10 +304,7 @@ public class LombokProcessor extends AbstractProcessor { // Step 1: Take all CUs which aren't already in the map. Give them the first priority level. - String randomModuleName = null; - for (Element element : roundEnv.getRootElements()) { - if (randomModuleName == null) randomModuleName = getModuleNameFor(element); JCCompilationUnit unit = toUnit(element); if (unit == null) continue; if (roots.containsKey(unit)) continue; @@ -353,7 +349,7 @@ public class LombokProcessor extends AbstractProcessor { newLevels.retainAll(priorityLevelsRequiringResolutionReset); if (!newLevels.isEmpty()) { // Force a new round to reset resolution. The next round will cause this method (process) to be called again. - forceNewRound(randomModuleName, javacFiler); + forceNewRound(javacFiler); return false; } // None of the new levels need resolution, so just keep going. @@ -361,7 +357,7 @@ public class LombokProcessor extends AbstractProcessor { } private int dummyCount = 0; - private void forceNewRound(String randomModuleName, JavacFiler filer) { + private void forceNewRound(JavacFiler filer) { if (!filer.newFiles()) { try { filer.getGeneratedSourceNames().add("lombok.dummy.ForceNewRound" + (dummyCount++)); @@ -372,38 +368,7 @@ public class LombokProcessor extends AbstractProcessor { } } } - - private String getModuleNameFor(Element element) { - while (element != null) { - if (element.getKind().name().equals("MODULE")) return getModuleName(element); - Element n = element.getEnclosingElement(); - if (n == element) return null; - element = n; - } - return null; - } - - private static Class<?> qualifiedNamableClass = null; - private static Method qualifiedNamableQualifiedNameMethod = null; - // QualifiedNameable isn't in java 6, so to remain compatible with java6, use reflection. - private static String getModuleName(Element element) { - try { - if (qualifiedNamableClass == null) qualifiedNamableClass = Class.forName("javax.lang.model.element.QualifiedNamable"); - if (!qualifiedNamableClass.isInstance(element)) return null; - if (qualifiedNamableQualifiedNameMethod == null) qualifiedNamableQualifiedNameMethod = Permit.getMethod(qualifiedNamableClass, "getQualifiedName"); - String name = Permit.invoke(qualifiedNamableQualifiedNameMethod, element).toString().trim(); - return name.isEmpty() ? null : name; - } catch (ClassNotFoundException e) { - return null; - } catch (NoSuchMethodException e) { - return null; - } catch (InvocationTargetException e) { - return null; - } catch (IllegalAccessException e) { - return null; - } - } - + private JCCompilationUnit toUnit(Element element) { TreePath path = null; if (trees != null) { |