diff --git a/src/main/java/de/plushnikov/intellij/plugin/jps/LombokBuildProcessParametersProvider.java b/src/main/java/de/plushnikov/intellij/plugin/jps/LombokBuildProcessParametersProvider.java index 831f243e1..76c65cc3e 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/jps/LombokBuildProcessParametersProvider.java +++ b/src/main/java/de/plushnikov/intellij/plugin/jps/LombokBuildProcessParametersProvider.java @@ -2,21 +2,10 @@ package de.plushnikov.intellij.plugin.jps; import com.intellij.compiler.server.BuildProcessParametersProvider; -import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.OrderEntry; -import com.intellij.openapi.roots.ProjectRootManager; -import com.intellij.psi.JavaPsiFacade; -import com.intellij.psi.PsiDirectory; -import com.intellij.psi.PsiPackage; -import com.intellij.psi.util.CachedValueProvider; -import com.intellij.psi.util.CachedValuesManager; -import de.plushnikov.intellij.plugin.Version; import org.jetbrains.annotations.NotNull; -import java.util.Collections; import java.util.List; /** @@ -38,36 +27,36 @@ public LombokBuildProcessParametersProvider(Project project) { // } return super.getVMArguments(); } - - private boolean isVersionLessThan1_18_16(Project project) { - return CachedValuesManager.getManager(project).getCachedValue(project, () -> { - Boolean isVersionLessThan; - try { - isVersionLessThan = ReadAction.nonBlocking( - () -> isVersionLessThanInternal(project, Version.LAST_LOMBOK_VERSION_WITH_JPS_FIX)) - .executeSynchronously(); - } catch (ProcessCanceledException e) { - throw e; - } catch (Throwable e) { - isVersionLessThan = false; - LOG.error(e); - } - return new CachedValueProvider.Result<>(isVersionLessThan, ProjectRootManager.getInstance(project)); - }); - } - - private boolean isVersionLessThanInternal(@NotNull Project project, @NotNull String version) { - PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage("lombok.experimental"); - if (aPackage != null) { - PsiDirectory[] directories = aPackage.getDirectories(); - if (directories.length > 0) { - List entries = - ProjectRootManager.getInstance(project).getFileIndex().getOrderEntriesForFile(directories[0].getVirtualFile()); - if (!entries.isEmpty()) { - return Version.isLessThan(entries.get(0), version); - } - } - } - return false; - } +// +// private boolean isVersionLessThan1_18_16(Project project) { +// return CachedValuesManager.getManager(project).getCachedValue(project, () -> { +// Boolean isVersionLessThan; +// try { +// isVersionLessThan = ReadAction.nonBlocking( +// () -> isVersionLessThanInternal(project, Version.LAST_LOMBOK_VERSION_WITH_JPS_FIX)) +// .executeSynchronously(); +// } catch (ProcessCanceledException e) { +// throw e; +// } catch (Throwable e) { +// isVersionLessThan = false; +// LOG.error(e); +// } +// return new CachedValueProvider.Result<>(isVersionLessThan, ProjectRootManager.getInstance(project)); +// }); +// } +// +// private boolean isVersionLessThanInternal(@NotNull Project project, @NotNull String version) { +// PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage("lombok.experimental"); +// if (aPackage != null) { +// PsiDirectory[] directories = aPackage.getDirectories(); +// if (directories.length > 0) { +// List entries = +// ProjectRootManager.getInstance(project).getFileIndex().getOrderEntriesForFile(directories[0].getVirtualFile()); +// if (!entries.isEmpty()) { +// return Version.isLessThan(entries.get(0), version); +// } +// } +// } +// return false; +// } } diff --git a/src/main/java/de/plushnikov/intellij/plugin/processor/handler/FieldNameConstantsHandler.java b/src/main/java/de/plushnikov/intellij/plugin/processor/handler/FieldNameConstantsHandler.java index 4eb467d93..9385d5997 100644 --- a/src/main/java/de/plushnikov/intellij/plugin/processor/handler/FieldNameConstantsHandler.java +++ b/src/main/java/de/plushnikov/intellij/plugin/processor/handler/FieldNameConstantsHandler.java @@ -15,7 +15,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Set; @@ -76,33 +75,6 @@ private static LombokLightClassBuilder createEnum(@NotNull String name, @NotNull .withImplicitModifier(PsiModifier.STATIC) .withImplicitModifier(PsiModifier.FINAL); - lazyClassBuilder.withMethodSupplier(()-> { - //add enum methods like here: ClassInnerStuffCache.calcMethods - final PsiManager psiManager = containingClass.getManager(); - final PsiClassType enumClassType = PsiClassUtil.getTypeWithGenerics(lazyClassBuilder); -// "public static " + myClass.getName() + "[] values() { }" - final LombokLightMethodBuilder valuesEnumMethod = new LombokLightMethodBuilder(psiManager, "values") - .withModifier(PsiModifier.PUBLIC) - .withModifier(PsiModifier.STATIC) - .withContainingClass(containingClass) - .withNavigationElement(navigationElement) - .withMethodReturnType(new PsiArrayType(enumClassType)); - valuesEnumMethod.withBody(PsiMethodUtil.createCodeBlockFromText("", valuesEnumMethod)); - - // "public static " + myClass.getName() + " valueOf(java.lang.String name) throws java.lang.IllegalArgumentException { }" - final LombokLightMethodBuilder valueOfEnumMethod = new LombokLightMethodBuilder(psiManager, "valueOf") - .withModifier(PsiModifier.PUBLIC) - .withModifier(PsiModifier.STATIC) - .withContainingClass(containingClass) - .withNavigationElement(navigationElement) - .withParameter("name", PsiType.getJavaLangString(psiManager, containingClass.getResolveScope())) - .withException(PsiType.getTypeByName("java.lang.IllegalArgumentException", containingClass.getProject(), containingClass.getResolveScope())) - .withMethodReturnType(enumClassType); - valueOfEnumMethod.withBody(PsiMethodUtil.createCodeBlockFromText("", valueOfEnumMethod)); - - return Arrays.asList(valuesEnumMethod, valueOfEnumMethod); - }); - return lazyClassBuilder; }