Search in sources :

Example 6 with SdkType

use of com.intellij.openapi.projectRoots.SdkType in project intellij-community by JetBrains.

the class NamedLibraryElementNode method getJdkIcon.

private static Icon getJdkIcon(JdkOrderEntry entry) {
    final Sdk sdk = entry.getJdk();
    if (sdk == null) {
        return AllIcons.General.Jdk;
    }
    final SdkType sdkType = (SdkType) sdk.getSdkType();
    return sdkType.getIcon();
}
Also used : SdkType(com.intellij.openapi.projectRoots.SdkType) Sdk(com.intellij.openapi.projectRoots.Sdk)

Example 7 with SdkType

use of com.intellij.openapi.projectRoots.SdkType in project intellij-community by JetBrains.

the class PythonMockSdk method create.

public static Sdk create(final String version, @NotNull final VirtualFile... additionalRoots) {
    final String mock_path = PythonTestUtil.getTestDataPath() + "/MockSdk" + version + "/";
    String sdkHome = new File(mock_path, "bin/python" + version).getPath();
    SdkType sdkType = PythonSdkType.getInstance();
    final Sdk sdk = new ProjectJdkImpl(MOCK_SDK_NAME + " " + version, sdkType) {

        @Override
        public String getVersionString() {
            return "Python " + version + " Mock SDK";
        }
    };
    final SdkModificator sdkModificator = sdk.getSdkModificator();
    sdkModificator.setHomePath(sdkHome);
    File libPath = new File(mock_path, "Lib");
    if (libPath.exists()) {
        sdkModificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(libPath), OrderRootType.CLASSES);
    }
    sdkModificator.addRoot(PyUserSkeletonsUtil.getUserSkeletonsDirectory(), OrderRootType.CLASSES);
    final LanguageLevel level = LanguageLevel.fromPythonVersion(version);
    final VirtualFile typeShedDir = PyTypeShed.INSTANCE.getDirectory();
    PyTypeShed.INSTANCE.findRootsForLanguageLevel(level).forEach(path -> {
        final VirtualFile file = typeShedDir.findFileByRelativePath(path);
        if (file != null) {
            sdkModificator.addRoot(file, OrderRootType.CLASSES);
        }
    });
    String mock_stubs_path = mock_path + PythonSdkType.SKELETON_DIR_NAME;
    sdkModificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByPath(mock_stubs_path), PythonSdkType.BUILTIN_ROOT_TYPE);
    for (final VirtualFile root : additionalRoots) {
        sdkModificator.addRoot(root, OrderRootType.CLASSES);
    }
    sdkModificator.commitChanges();
    final FileBasedIndex index = FileBasedIndex.getInstance();
    index.requestRebuild(StubUpdatingIndex.INDEX_ID);
    index.requestRebuild(PyModuleNameIndex.NAME);
    return sdk;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PythonSdkType(com.jetbrains.python.sdk.PythonSdkType) SdkType(com.intellij.openapi.projectRoots.SdkType) LanguageLevel(com.jetbrains.python.psi.LanguageLevel) ProjectJdkImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkImpl) Sdk(com.intellij.openapi.projectRoots.Sdk) SdkModificator(com.intellij.openapi.projectRoots.SdkModificator) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex)

Aggregations

SdkType (com.intellij.openapi.projectRoots.SdkType)7 Sdk (com.intellij.openapi.projectRoots.Sdk)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 FlexmojosSdkType (com.intellij.lang.javascript.flex.sdk.FlexmojosSdkType)1 FileChooser (com.intellij.openapi.fileChooser.FileChooser)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 Project (com.intellij.openapi.project.Project)1 SdkModificator (com.intellij.openapi.projectRoots.SdkModificator)1 ProjectJdkImpl (com.intellij.openapi.projectRoots.impl.ProjectJdkImpl)1 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)1 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)1 JdkComboBox (com.intellij.openapi.roots.ui.configuration.JdkComboBox)1 CompositeAppearance (com.intellij.openapi.roots.ui.util.CompositeAppearance)1 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)1 FileBasedIndex (com.intellij.util.indexing.FileBasedIndex)1 LanguageLevel (com.jetbrains.python.psi.LanguageLevel)1 PythonSdkType (com.jetbrains.python.sdk.PythonSdkType)1 File (java.io.File)1 NotNull (org.jetbrains.annotations.NotNull)1