From 92acca9c1af629a7a95f45fe9d7366887d38cf77 Mon Sep 17 00:00:00 2001 From: azerr Date: Thu, 23 Nov 2023 21:07:27 +0100 Subject: [PATCH] perf: Avoid using ModuleUtilCore#findModuleForFile which can blick IJ since 2023.3 Beta2 Fixes #1272 Signed-off-by: azerr --- .../redhat/devtools/intellij/quarkus/QuarkusModuleUtil.java | 4 ++-- .../intellij/quarkus/json/QuarkusJsonSchemaProvider.java | 4 ++-- .../devtools/intellij/qute/lang/QuteLanguageSubstitutor.java | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/QuarkusModuleUtil.java b/src/main/java/com/redhat/devtools/intellij/quarkus/QuarkusModuleUtil.java index 348ef62ce..cf7b70f5f 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/QuarkusModuleUtil.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/QuarkusModuleUtil.java @@ -13,7 +13,6 @@ import com.intellij.facet.FacetManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; -import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.LibraryOrderEntry; import com.intellij.openapi.roots.ModuleRootManager; @@ -21,6 +20,7 @@ import com.intellij.openapi.roots.RootPolicy; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.redhat.devtools.intellij.lsp4ij.LSPIJUtils; import com.redhat.devtools.intellij.lsp4mp4ij.psi.internal.core.ls.PsiUtilsLSImpl; import com.redhat.devtools.intellij.quarkus.facet.QuarkusFacet; import org.jetbrains.annotations.NotNull; @@ -144,7 +144,7 @@ public static boolean isQuarkusYAMLFile(VirtualFile file, Project project) { } private static boolean isQuarkusModule(VirtualFile file, Project project) { - Module module = ModuleUtilCore.findModuleForFile(file, project); + Module module = LSPIJUtils.getModule(file, project); return module != null && (FacetManager.getInstance(module).getFacetByType(QuarkusFacet.FACET_TYPE_ID) != null || QuarkusModuleUtil.isQuarkusModule(module)); } diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/json/QuarkusJsonSchemaProvider.java b/src/main/java/com/redhat/devtools/intellij/quarkus/json/QuarkusJsonSchemaProvider.java index 62eebc5c8..6b919f102 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/json/QuarkusJsonSchemaProvider.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/json/QuarkusJsonSchemaProvider.java @@ -11,10 +11,10 @@ package com.redhat.devtools.intellij.quarkus.json; import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.jetbrains.jsonSchema.extension.JsonSchemaFileProvider; import com.jetbrains.jsonSchema.extension.SchemaType; +import com.redhat.devtools.intellij.lsp4ij.LSPIJUtils; import com.redhat.devtools.intellij.quarkus.QuarkusModuleUtil; import com.redhat.devtools.intellij.quarkus.QuarkusProjectService; import org.jetbrains.annotations.NotNull; @@ -29,7 +29,7 @@ public QuarkusJsonSchemaProvider(Module module) { @Override public boolean isAvailable(@NotNull VirtualFile file) { - return isApplicationYAMLFile(file) && module.equals(ModuleUtilCore.findModuleForFile(file, module.getProject())); + return isApplicationYAMLFile(file) && module.equals(LSPIJUtils.getModule(file, module.getProject())); } private boolean isApplicationYAMLFile(VirtualFile file) { diff --git a/src/main/java/com/redhat/devtools/intellij/qute/lang/QuteLanguageSubstitutor.java b/src/main/java/com/redhat/devtools/intellij/qute/lang/QuteLanguageSubstitutor.java index ed4bb119f..e8f3f0f94 100644 --- a/src/main/java/com/redhat/devtools/intellij/qute/lang/QuteLanguageSubstitutor.java +++ b/src/main/java/com/redhat/devtools/intellij/qute/lang/QuteLanguageSubstitutor.java @@ -22,6 +22,7 @@ import com.intellij.openapi.roots.RootPolicy; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.LanguageSubstitutor; +import com.redhat.devtools.intellij.lsp4ij.LSPIJUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -70,7 +71,7 @@ private Module findModule(VirtualFile file) { @Override public @Nullable Language getLanguage(@NotNull VirtualFile file, @NotNull Project project) { - Module module = ModuleUtilCore.findModuleForFile(file, project); + Module module = LSPIJUtils.getModule(file, project); if (module != null) { if (isTemplate(file, module) && isQuteModule(module)) { return QuteLanguage.INSTANCE;