use of com.intellij.openapi.roots.impl.ModuleLibraryOrderEntryImpl in project intellij-community by JetBrains.
the class PyBuiltinCache method findSdkForNonModuleFile.
@Nullable
public static Sdk findSdkForNonModuleFile(PsiFileSystemItem psiFile) {
Project project = psiFile.getProject();
Sdk sdk = null;
final VirtualFile vfile = psiFile instanceof PsiFile ? ((PsiFile) psiFile).getOriginalFile().getVirtualFile() : psiFile.getVirtualFile();
if (vfile != null) {
// reality
final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);
sdk = projectRootManager.getProjectSdk();
if (sdk == null) {
final List<OrderEntry> orderEntries = projectRootManager.getFileIndex().getOrderEntriesForFile(vfile);
for (OrderEntry orderEntry : orderEntries) {
if (orderEntry instanceof JdkOrderEntry) {
sdk = ((JdkOrderEntry) orderEntry).getJdk();
} else if (orderEntry instanceof ModuleLibraryOrderEntryImpl) {
sdk = PythonSdkType.findPythonSdk(orderEntry.getOwnerModule());
}
}
}
}
return sdk;
}
Aggregations