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


Java PythonSdkType.getLanguageLevelForSdk方法代码示例

本文整理汇总了Java中com.jetbrains.python.sdk.PythonSdkType.getLanguageLevelForSdk方法的典型用法代码示例。如果您正苦于以下问题:Java PythonSdkType.getLanguageLevelForSdk方法的具体用法?Java PythonSdkType.getLanguageLevelForSdk怎么用?Java PythonSdkType.getLanguageLevelForSdk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jetbrains.python.sdk.PythonSdkType的用法示例。


在下文中一共展示了PythonSdkType.getLanguageLevelForSdk方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: guessLanguageLevel

import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
@NotNull
public static LanguageLevel guessLanguageLevel(@NotNull Project project) {
  final ModuleManager moduleManager = ModuleManager.getInstance(project);
  if (moduleManager != null) {
    LanguageLevel maxLevel = null;
    for (Module projectModule : moduleManager.getModules()) {
      final Sdk sdk = PythonSdkType.findPythonSdk(projectModule);
      if (sdk != null) {
        final LanguageLevel level = PythonSdkType.getLanguageLevelForSdk(sdk);
        if (maxLevel == null || maxLevel.isOlderThan(level)) {
          maxLevel = level;
        }
      }
    }
    if (maxLevel != null) {
      return maxLevel;
    }
  }
  return LanguageLevel.getDefault();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PyUtil.java

示例2: findErrorSolution

import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
@Nullable
private static String findErrorSolution(@NotNull PyExecutionException e, @Nullable String cause, @Nullable Sdk sdk) {
  if (cause != null) {
    if (StringUtil.containsIgnoreCase(cause, "SyntaxError")) {
      final LanguageLevel languageLevel = PythonSdkType.getLanguageLevelForSdk(sdk);
      return "Make sure that you use a version of Python supported by this package. Currently you are using Python " +
             languageLevel + ".";
    }
  }

  if (SystemInfo.isLinux && (containsInOutput(e, "pyconfig.h") || containsInOutput(e, "Python.h"))) {
    return "Make sure that you have installed Python development packages for your operating system.";
  }

  if ("pip".equals(e.getCommand()) && sdk != null) {
    return "Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' " +
           "installed for your Python interpreter located at '" + sdk.getHomePath() + "'.";
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PyPackageManagementService.java

示例3: getFileLanguageLevel

import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
public static LanguageLevel getFileLanguageLevel(@NotNull Project project, @Nullable VirtualFile file) {
  if (ApplicationManager.getApplication().isUnitTestMode() && LanguageLevel.FORCE_LANGUAGE_LEVEL != null) {
    return LanguageLevel.FORCE_LANGUAGE_LEVEL;
  }
  if (file == null) return null;
  final Sdk sdk = getFileSdk(project, file);
  if (sdk != null) {
    return PythonSdkType.getLanguageLevelForSdk(sdk);
  }
  return PyUtil.guessLanguageLevelWithCaching(project);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:PythonLanguageLevelPusher.java

示例4: getImmediateValue

import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
public LanguageLevel getImmediateValue(@NotNull Module module) {
  if (ApplicationManager.getApplication().isUnitTestMode() && LanguageLevel.FORCE_LANGUAGE_LEVEL != null) {
    return LanguageLevel.FORCE_LANGUAGE_LEVEL;
  }

  final Sdk sdk = PythonSdkType.findPythonSdk(module);
  return PythonSdkType.getLanguageLevelForSdk(sdk);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PythonLanguageLevelPusher.java

示例5: updateSdkLanguageLevel

import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
private void updateSdkLanguageLevel(@NotNull final Project project, final Sdk sdk) {
  final LanguageLevel languageLevel = PythonSdkType.getLanguageLevelForSdk(sdk);
  final VirtualFile[] files = sdk.getRootProvider().getFiles(OrderRootType.CLASSES);
  final Application application = ApplicationManager.getApplication();
  PyUtil.invalidateLanguageLevelCache(project);
  application.executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      application.runReadAction(new Runnable() {
        @Override
        public void run() {
          if (project.isDisposed()) {
            return;
          }
          for (VirtualFile file : files) {
            if (file.isValid()) {
              VirtualFile parent = file.getParent();
              boolean suppressSizeLimit = false;
              if (parent != null && parent.getName().equals(PythonSdkType.SKELETON_DIR_NAME)) {
                suppressSizeLimit = true;
              }
              markRecursively(project, file, languageLevel, suppressSizeLimit);
            }
          }
        }
      });
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:PythonLanguageLevelPusher.java

示例6: createVirtualEnv

import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
@NotNull
public String createVirtualEnv(@NotNull String destinationDir, boolean useGlobalSite) throws ExecutionException {
  final List<String> args = new ArrayList<String>();
  final LanguageLevel languageLevel = PythonSdkType.getLanguageLevelForSdk(mySdk);
  final boolean usePyVenv = languageLevel.isAtLeast(LanguageLevel.PYTHON33);
  if (usePyVenv) {
    args.add("pyvenv");
    if (useGlobalSite) {
      args.add("--system-site-packages");
    }
    args.add(destinationDir);
    getHelperResult(PACKAGING_TOOL, args, false, true, null);
  }
  else {
    if (useGlobalSite) {
      args.add("--system-site-packages");
    }
    args.add(destinationDir);
    final boolean pre26 = languageLevel.isOlderThan(LanguageLevel.PYTHON26);
    final String name = "virtualenv-" + (pre26 ? VIRTUALENV_PRE_26_VERSION : VIRTUALENV_VERSION);
    final String dirName = extractHelper(name + ".tar.gz");
    try {
      final String fileName = dirName + name + File.separatorChar + "virtualenv.py";
      getPythonProcessResult(fileName, args, false, true, dirName + name);
    }
    finally {
      FileUtil.delete(new File(dirName));
    }
  }

  final String binary = PythonSdkType.getPythonExecutable(destinationDir);
  final String binaryFallback = destinationDir + File.separator + "bin" + File.separator + "python";
  final String path = (binary != null) ? binary : binaryFallback;

  if (usePyVenv) {
    // Still no 'packaging' and 'pysetup3' for Python 3.3rc1, see PEP 405
    final VirtualFile binaryFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
    if (binaryFile != null) {
      final ProjectJdkImpl tmpSdk = new ProjectJdkImpl("", PythonSdkType.getInstance());
      tmpSdk.setHomePath(path);
      final PyPackageManager manager = PyPackageManager.getInstance(tmpSdk);
      manager.installManagement();
    }
  }
  return path;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:47,代码来源:PyPackageManagerImpl.java


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