Search in sources :

Example 6 with PythonSdkType

use of com.jetbrains.python.sdk.PythonSdkType in project intellij-community by JetBrains.

the class PyTreeStructureProvider method getPythonSdk.

@Nullable
private static Sdk getPythonSdk(@NotNull AbstractTreeNode node) {
    if (node instanceof NamedLibraryElementNode) {
        final NamedLibraryElement value = ((NamedLibraryElementNode) node).getValue();
        if (value != null) {
            final LibraryOrSdkOrderEntry entry = value.getOrderEntry();
            if (entry instanceof JdkOrderEntry) {
                final Sdk sdk = ((JdkOrderEntry) entry).getJdk();
                final SdkTypeId type = sdk.getSdkType();
                if (type instanceof PythonSdkType) {
                    return sdk;
                }
            }
        }
    }
    return null;
}
Also used : NamedLibraryElement(com.intellij.ide.projectView.impl.nodes.NamedLibraryElement) JdkOrderEntry(com.intellij.openapi.roots.JdkOrderEntry) LibraryOrSdkOrderEntry(com.intellij.openapi.roots.LibraryOrSdkOrderEntry) Sdk(com.intellij.openapi.projectRoots.Sdk) SdkTypeId(com.intellij.openapi.projectRoots.SdkTypeId) PythonSdkType(com.jetbrains.python.sdk.PythonSdkType) NamedLibraryElementNode(com.intellij.ide.projectView.impl.nodes.NamedLibraryElementNode) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PythonSdkType (com.jetbrains.python.sdk.PythonSdkType)6 Sdk (com.intellij.openapi.projectRoots.Sdk)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 ArrayList (java.util.ArrayList)3 Nullable (org.jetbrains.annotations.Nullable)3 SdkTypeId (com.intellij.openapi.projectRoots.SdkTypeId)2 NamedLibraryElement (com.intellij.ide.projectView.impl.nodes.NamedLibraryElement)1 NamedLibraryElementNode (com.intellij.ide.projectView.impl.nodes.NamedLibraryElementNode)1 ModalityState (com.intellij.openapi.application.ModalityState)1 SdkAdditionalData (com.intellij.openapi.projectRoots.SdkAdditionalData)1 ProjectJdkImpl (com.intellij.openapi.projectRoots.impl.ProjectJdkImpl)1 JdkOrderEntry (com.intellij.openapi.roots.JdkOrderEntry)1 LibraryOrSdkOrderEntry (com.intellij.openapi.roots.LibraryOrSdkOrderEntry)1 VirtualFileFilter (com.intellij.openapi.vfs.VirtualFileFilter)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 PyDocumentationSettings (com.jetbrains.python.documentation.PyDocumentationSettings)1 DocStringFormat (com.jetbrains.python.documentation.docstrings.DocStringFormat)1 PreferredSdkComparator (com.jetbrains.python.sdk.PreferredSdkComparator)1 PyDetectedSdk (com.jetbrains.python.sdk.PyDetectedSdk)1 PythonSdkAdditionalData (com.jetbrains.python.sdk.PythonSdkAdditionalData)1