Java Code Examples for com.intellij.openapi.projectRoots.Sdk#getSdkType()
The following examples show how to use
com.intellij.openapi.projectRoots.Sdk#getSdkType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlazePyBuiltinReferenceResolveProvider.java From intellij with Apache License 2.0 | 6 votes |
@Nullable private static PyBuiltinCache getBuiltInCache(PyQualifiedExpression element) { final PsiElement realContext = PyPsiUtils.getRealContext(element); PsiFileSystemItem psiFile = realContext.getContainingFile(); if (psiFile == null) { return null; } Sdk sdk = PyBuiltinCache.findSdkForFile(psiFile); if (sdk != null && sdk.getSdkType() instanceof PythonSdkType) { // this case is already handled by PythonBuiltinReferenceResolveProvider return null; } Sdk pythonSdk = PySdkUtils.getPythonSdk(psiFile.getProject()); return pythonSdk != null ? PythonSdkPathCache.getInstance(psiFile.getProject(), pythonSdk).getBuiltins() : null; }
Example 2
Source File: IdeaJdkHelper.java From intellij with Apache License 2.0 | 5 votes |
/** @throws RuntimeException if input Sdk is not an IdeaJdk */ public static String getSandboxHome(Sdk sdk) { if (!isIdeaJdk(sdk)) { throw new RuntimeException("Invalid SDK type: " + sdk.getSdkType()); } return ((Sandbox) sdk.getSdkAdditionalData()).getSandboxHome(); }
Example 3
Source File: Jdks.java From intellij with Apache License 2.0 | 5 votes |
/** * Returns null if the SDK is not a java JDK, or doesn't have a recognized java langauge level. */ @Nullable private static LanguageLevel getJavaLanguageLevel(Sdk sdk) { if (!(sdk.getSdkType() instanceof JavaSdk)) { return null; } JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk); return version != null ? version.getMaxLanguageLevel() : null; }
Example 4
Source File: BlazePyOutsideModuleImportResolver.java From intellij with Apache License 2.0 | 5 votes |
@Nullable @Override public PsiElement resolveImportReference( QualifiedName name, PyQualifiedNameResolveContext context, boolean withRoots) { Project project = context.getProject(); if (!Blaze.isBlazeProject(project)) { return null; } if (context.getModule() != null) { // the file is associated with a module, so this import resolver is not necessary. return null; } if (context.getFoothold() == null) { // we're not resolving in the context of a specific py file, so this hack is unnecessary. return null; } Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk(); if (projectSdk != null && projectSdk.getSdkType() instanceof PythonSdkType) { // if this is a python workspace type, imports in external files are already resolved by the // python plugin. return null; } Sdk pythonSdk = PySdkUtils.getPythonSdk(context.getProject()); if (pythonSdk == null) { return null; } for (VirtualFile root : pythonSdk.getRootProvider().getFiles(OrderRootType.CLASSES)) { if (!root.isValid() || !root.isDirectory()) { continue; } PsiElement element = resolveModuleAt(context.getPsiManager().findDirectory(root), name, context); if (element != null) { return element; } } return null; }
Example 5
Source File: PySdkUtils.java From intellij with Apache License 2.0 | 5 votes |
/** Find a python SDK associated with a blaze project, or its workspace module. */ @Nullable public static Sdk getPythonSdk(Project project) { Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk(); if (projectSdk != null && projectSdk.getSdkType() instanceof PythonSdkType) { return projectSdk; } // look for a SDK associated with a python facet instead. return PythonSdkType.findPythonSdk( ModuleManager.getInstance(project) .findModuleByName(BlazeDataStorage.WORKSPACE_MODULE_NAME)); }
Example 6
Source File: BlazePythonSyncPlugin.java From intellij with Apache License 2.0 | 5 votes |
private static boolean isValidPythonSdk(@Nullable Sdk sdk) { if (sdk == null) { return false; } if (!(sdk.getSdkType() instanceof PythonSdkType)) { return false; } // facets aren't properly updated when SDKs change (e.g. when they're deleted), so we need to // manually check against the full list. if (!PythonSdkType.getAllSdks().contains(sdk)) { return false; } // If an SDK exists with a home path that doesn't exist anymore, it's not valid String sdkHome = sdk.getHomePath(); if (sdkHome == null) { return false; } File sdkHomeFile = new File(sdkHome); if (!sdkHomeFile.exists()) { return false; } // Allow PySdkSuggester extensions the ability to veto an SDK as deprecated return !isDeprecatedPythonSdk(sdk); }
Example 7
Source File: ModuleChunk.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean value(OrderEntry orderEntry) { if (orderEntry instanceof ModuleExtensionWithSdkOrderEntry && myOwnerModule.equals(orderEntry.getOwnerModule())) { final Sdk sdk = ((ModuleExtensionWithSdkOrderEntry)orderEntry).getSdk(); if(sdk == null || sdk.getSdkType() != mySdkType) { return true; } mySdkFound = true; } return !mySdkFound; }
Example 8
Source File: ModuleChunk.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean value(OrderEntry orderEntry) { if (orderEntry instanceof ModuleExtensionWithSdkOrderEntry) { final Sdk sdk = ((ModuleExtensionWithSdkOrderEntry)orderEntry).getSdk(); if(sdk == null || sdk.getSdkType() != mySdkType) { return true; } mySdkFound = true; return false; } return mySdkFound; }
Example 9
Source File: SdkUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static Image getIcon(@Nullable Sdk sdk) { if (sdk == null) { return AllIcons.Toolbar.Unknown; } SdkType sdkType = (SdkType)sdk.getSdkType(); Image icon = ObjectUtil.notNull(sdkType.getIcon(), AllIcons.Toolbar.Unknown); if(sdk.isPredefined()) { return ImageEffects.layered(icon, AllIcons.Nodes.Locked); } else { return icon; } }
Example 10
Source File: OrderEntryAppearanceServiceImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public CellAppearanceEx forSdk(@Nullable final Sdk jdk, final boolean isInComboBox, final boolean selected, final boolean showVersion) { if (jdk == null) { return SimpleTextCellAppearance.invalid(ProjectBundle.message("unknown.sdk"), AllIcons.Toolbar.Unknown); } String name = jdk.getName(); CompositeAppearance appearance = new CompositeAppearance(); SdkType sdkType = (SdkType)jdk.getSdkType(); appearance.setIcon(SdkUtil.getIcon(jdk)); SimpleTextAttributes attributes = getTextAttributes(sdkType.sdkHasValidPath(jdk), selected); CompositeAppearance.DequeEnd ending = appearance.getEnding(); ending.addText(name, attributes); if (showVersion) { String versionString = jdk.getVersionString(); if (versionString != null && !versionString.equals(name)) { SimpleTextAttributes textAttributes = isInComboBox && !selected ? SimpleTextAttributes.SYNTHETIC_ATTRIBUTES : SystemInfo.isMac && selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, Color.WHITE): SimpleTextAttributes.GRAY_ATTRIBUTES; ending.addComment(versionString, textAttributes); } } return ending.getAppearance(); }
Example 11
Source File: CppCompiler.java From CppTools with Apache License 2.0 | 5 votes |
@NotNull public ProcessingItem[] getProcessingItems(final CompileContext compileContext) { final List<ProcessingItem> processingItems = new ArrayList<ProcessingItem>(); boolean doneSave = false; Module[] affectedModules = ApplicationManager.getApplication().runReadAction(new Computable<Module[]>() { public Module[] compute() { return compileContext.getCompileScope().getAffectedModules(); } }); for(Module module: affectedModules) { Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (ModuleType.get(module) == CppModuleType.getInstance() || (sdk != null && sdk.getSdkType() == CppSdkType.getInstance())) { processingItems.add(new MyProcessingItem(module)); if (!doneSave) { BuildState.saveDocuments(); doneSave = true; } VirtualFile moduleFile = module.getModuleFile(); if (moduleFile == null) { BuildState.saveAll(); } } } return processingItems.toArray(new ProcessingItem[processingItems.size()]); }
Example 12
Source File: CppCompiler.java From CppTools with Apache License 2.0 | 5 votes |
public boolean validateConfiguration(CompileScope compileScope) { EnvironmentFacade facade = EnvironmentFacade.getInstance(); for(Module module:compileScope.getAffectedModules()) { if (ModuleType.get(module) == CppModuleType.getInstance()) { Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (!(sdk.getSdkType() == CppSdkType.getInstance())) { Messages.showMessageDialog(module.getProject(), "C/Cpp module type is not configured", "C/C++ compiler problem", Messages.getErrorIcon()); return false; } } } return true; }
Example 13
Source File: OCamlSdkForm.java From reasonml-idea-plugin with MIT License | 4 votes |
public void createUIComponents(@NotNull Sdk sdk) { SdkTypeId sdkType = sdk.getSdkType(); if (sdkType instanceof OCamlSdkType) { m_sdkVersion = sdk.getVersionString(); m_data = (OCamlSdkAdditionalData) sdk.getSdkAdditionalData(); if (m_data != null) { c_version.setText("Current version is: " + m_data); c_forceVersion.setSelected(m_data.isForced()); c_forceVersion.addItemListener(itemEvent -> c_forceValue.setEnabled(itemEvent.getStateChange() == ItemEvent.SELECTED)); c_forceValue.setText(m_data.toString()); c_forceValue.setEnabled(m_data.isForced()); c_sdkHome.addBrowseFolderListener("Choose Sdk Home Directory: ", null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor()); c_download.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { OCamlSdkAdditionalData odkData = (OCamlSdkAdditionalData) sdk.getSdkAdditionalData(); if (odkData != null) { // Download SDK from distribution site LOG.debug("Download SDK", m_data.toString()); VirtualFileSystem fileSystem = LocalFileSystem.getInstance(); VirtualFile sdkHome = fileSystem.findFileByPath(c_sdkHome.getText().trim()); if (sdkHome != null) { Task.WithResult<String, RuntimeException> download = new Task.WithResult<String, RuntimeException>(null, "Download SDK", false) { @Override protected String compute(@NotNull ProgressIndicator indicator) throws RuntimeException { new SdkDownloader(odkData.getMajor(), odkData.getMinor(), odkData.getPatch(), sdkHome).run(null, indicator); return sdkHome.getPath(); } }; String path = ProgressManager.getInstance().run(download); Notifications.Bus.notify(new ORNotification("SDK", "SDK " + odkData + " downloaded to " + path, NotificationType.INFORMATION)); } } } }); } } }
Example 14
Source File: CSharpCompilerProvider.java From consulo-csharp with Apache License 2.0 | 4 votes |
public boolean isSelected(@Nonnull DotNetSimpleModuleExtension<?> moduleExtension, @Nonnull String name, @Nullable Sdk sdk) { return sdk != null && getBundleType(moduleExtension) == sdk.getSdkType(); }