当前位置: 首页>>代码示例>>Java>>正文


Java PythonSdkType.getSdk方法代码示例

本文整理汇总了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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:QualifiedNameResolverImpl.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:PyUserSkeletonsUtil.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:PyUnresolvedReferencesInspection.java


注:本文中的com.jetbrains.python.sdk.PythonSdkType.getSdk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。