Skip to content

Commit

Permalink
perf: Avoid using ModuleUtilCore#findModuleForFile which can block IJ
Browse files Browse the repository at this point in the history
since 2023.3 Beta2

Fixes #1272

Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Nov 23, 2023
1 parent 4282405 commit d104517
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
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;
import com.intellij.openapi.roots.OrderEnumerator;
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;
Expand Down Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d104517

Please sign in to comment.