use of com.intellij.openapi.projectRoots.SdkTypeId in project intellij-community by JetBrains.
the class PyBuiltinCache method getSkeletonFile.
@Nullable
private static PyFile getSkeletonFile(@NotNull final Project project, @NotNull Sdk sdk, @NotNull String name) {
SdkTypeId sdkType = sdk.getSdkType();
if (sdkType instanceof PythonSdkType) {
final int index = name.indexOf(".");
if (index != -1) {
name = name.substring(0, index);
}
final List<PsiElement> results = PyResolveImportUtil.resolveQualifiedName(QualifiedName.fromComponents(name), PyResolveImportUtil.fromSdk(project, sdk));
return as(ContainerUtil.getFirstItem(results), PyFile.class);
}
return null;
}
use of com.intellij.openapi.projectRoots.SdkTypeId 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;
}
use of com.intellij.openapi.projectRoots.SdkTypeId in project intellij-elixir by KronicDeth.
the class MixExUnitRunConfigurationProducer method setupConfigurationFromContextImpl.
private boolean setupConfigurationFromContextImpl(@NotNull MixExUnitRunConfiguration configuration, @NotNull PsiElement psiElement) {
boolean contextApplicable = false;
if (psiElement instanceof PsiDirectory) {
PsiDirectory psiDirectory = (PsiDirectory) psiElement;
Module module = ModuleUtilCore.findModuleForPsiElement(psiDirectory);
Sdk sdk;
if (module != null) {
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
sdk = moduleRootManager.getSdk();
} else {
ProjectRootManager projectRootManager = ProjectRootManager.getInstance(psiDirectory.getProject());
sdk = projectRootManager.getProjectSdk();
}
SdkTypeId sdkTypeId = null;
if (sdk != null) {
sdkTypeId = sdk.getSdkType();
}
if ((sdkTypeId == null || sdkTypeId.equals(ElixirSdkType.getInstance())) && ProjectRootsUtil.isInTestSource(psiDirectory.getVirtualFile(), psiDirectory.getProject())) {
String basePath = psiElement.getProject().getBasePath();
String workingDirectory = workingDirectory(psiElement, basePath);
configuration.setWorkingDirectory(workingDirectory);
PsiDirectory dir = (PsiDirectory) psiElement;
configuration.setName(configurationName(dir, workingDirectory, basePath));
configuration.setProgramParameters(programParameters(dir, workingDirectory));
contextApplicable = true;
}
} else {
PsiFile containingFile = psiElement.getContainingFile();
if (!(containingFile instanceof ElixirFile || containingFile instanceof PsiDirectory))
return false;
if (ProjectRootsUtil.isInTestSource(containingFile)) {
String basePath = psiElement.getProject().getBasePath();
String workingDirectory = workingDirectory(psiElement, basePath);
configuration.setWorkingDirectory(workingDirectory);
int lineNumber = lineNumber(psiElement);
configuration.setName(configurationName(containingFile, lineNumber, workingDirectory, basePath));
configuration.setProgramParameters(programParameters(containingFile, lineNumber, workingDirectory));
contextApplicable = true;
}
}
return contextApplicable;
}
Aggregations