mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-930 Remove usage of getOrderEntriesForFile from JdkUtils
GitOrigin-RevId: dd0ed191c98cafe869657dbbe503e19a80ef2822
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ccc153b382
commit
0b538dca29
@@ -30,6 +30,8 @@ jvm_library(
|
||||
"@lib//:kotlin-stdlib",
|
||||
"//uast/uast-common:uast",
|
||||
"//uast/uast-common-ide:ide",
|
||||
"//platform/workspace/jps",
|
||||
"//platform/workspace/storage",
|
||||
],
|
||||
exports = [
|
||||
"//uast/uast-common:uast",
|
||||
|
||||
@@ -33,5 +33,7 @@
|
||||
<orderEntry type="library" name="kotlin-stdlib" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.uast" exported="" />
|
||||
<orderEntry type="module" module-name="intellij.platform.uast.ide" exported="" />
|
||||
<orderEntry type="module" module-name="intellij.platform.workspace.jps" />
|
||||
<orderEntry type="module" module-name="intellij.platform.workspace.storage" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,24 +1,24 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.roots;
|
||||
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.platform.workspace.jps.entities.SdkEntity;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class JdkUtils {
|
||||
public static @Nullable Sdk getJdkForElement(@NotNull PsiElement element) {
|
||||
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
|
||||
if (virtualFile == null) return null;
|
||||
final List<OrderEntry> entries = ProjectRootManager.getInstance(element.getProject()).getFileIndex().getOrderEntriesForFile(virtualFile);
|
||||
for (OrderEntry orderEntry : entries) {
|
||||
if (orderEntry instanceof JdkOrderEntry entry) {
|
||||
Sdk jdk = entry.getJdk();
|
||||
if (jdk != null) return jdk;
|
||||
var jdks = ProjectRootManager.getInstance(element.getProject()).getFileIndex().findContainingSdks(virtualFile);
|
||||
for (SdkEntity jdk : jdks) {
|
||||
var sdkBridge = ProjectJdkTable.getInstance(element.getProject()).findJdk(jdk.getName());
|
||||
if (sdkBridge != null) {
|
||||
return sdkBridge;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user