本文整理汇总了Java中com.jetbrains.python.sdk.PythonSdkType.getSdk方法的典型用法代码示例。如果您正苦于以下问题:Java PythonSdkType.getSdk方法的具体用法?Java PythonSdkType.getSdk怎么用?Java PythonSdkType.getSdk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jetbrains.python.sdk.PythonSdkType
的用法示例。
在下文中一共展示了PythonSdkType.getSdk方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRelativeImportResultsFromSkeletons
import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
/**
* Resolve relative imports from sdk root to the skeleton dir
*/
private void addRelativeImportResultsFromSkeletons(@NotNull final PsiFile foothold) {
final boolean inSource = FileIndexFacade.getInstance(foothold.getProject()).isInContent(foothold.getVirtualFile());
if (inSource) return;
PsiDirectory containingDirectory = foothold.getContainingDirectory();
if (myRelativeLevel > 0) {
containingDirectory = ResolveImportUtil.stepBackFrom(foothold, myRelativeLevel);
}
if (containingDirectory != null) {
final QualifiedName containingQName = QualifiedNameFinder.findCanonicalImportPath(containingDirectory, null);
if (containingQName != null && containingQName.getComponentCount() > 0) {
final QualifiedName absoluteQName = containingQName.append(myQualifiedName.toString());
final QualifiedNameResolverImpl absoluteVisitor =
(QualifiedNameResolverImpl)new QualifiedNameResolverImpl(absoluteQName).fromElement(foothold);
final Sdk sdk = PythonSdkType.getSdk(foothold);
if (sdk == null) return;
final VirtualFile skeletonsDir = PySdkUtil.findSkeletonsDir(sdk);
if (skeletonsDir == null) return;
final PsiDirectory directory = myContext.getPsiManager().findDirectory(skeletonsDir);
final PsiElement psiElement = absoluteVisitor.resolveModuleAt(directory);
if (psiElement != null)
myLibResults.add(psiElement);
}
}
}
示例2: getUserSkeletonForModuleQName
import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
@Nullable
public static PyFile getUserSkeletonForModuleQName(@NotNull String qName, @NotNull PsiElement foothold) {
final Sdk sdk = PythonSdkType.getSdk(foothold);
if (sdk != null) {
final Project project = foothold.getProject();
final PythonSdkPathCache cache = PythonSdkPathCache.getInstance(project, sdk);
final QualifiedName cacheQName = QualifiedName.fromDottedString(USER_SKELETONS_DIR + "." + qName);
final List<PsiElement> results = cache.get(cacheQName);
if (results != null) {
final PsiElement element = results.isEmpty() ? null : results.get(0);
if (element instanceof PyFile) {
return (PyFile)element;
}
}
final VirtualFile directory = getUserSkeletonsDirectory();
if (directory != null) {
final PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(directory);
PsiElement fileSkeleton = new QualifiedNameResolverImpl(qName).resolveModuleAt(psiDirectory);
if (fileSkeleton instanceof PsiDirectory) {
fileSkeleton = PyUtil.getPackageElement((PsiDirectory)fileSkeleton, foothold);
}
if (fileSkeleton instanceof PyFile) {
cache.put(cacheQName, Collections.singletonList(fileSkeleton));
return (PyFile)fileSkeleton;
}
}
cache.put(cacheQName, Collections.<PsiElement>emptyList());
}
return null;
}
示例3: isEnabled
import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
public boolean isEnabled(@NotNull PsiElement anchor) {
if (myIsEnabled == null) {
final boolean isPyCharm = PlatformUtils.isPyCharm();
if (PySkeletonRefresher.isGeneratingSkeletons()) {
myIsEnabled = false;
}
else if (isPyCharm) {
myIsEnabled = PythonSdkType.getSdk(anchor) != null || PyUtil.isInScratchFile(anchor);
}
else {
myIsEnabled = true;
}
}
return myIsEnabled;
}