當前位置: 首頁>>代碼示例>>Java>>正文


Java Sdk.getVersionString方法代碼示例

本文整理匯總了Java中com.intellij.openapi.projectRoots.Sdk.getVersionString方法的典型用法代碼示例。如果您正苦於以下問題:Java Sdk.getVersionString方法的具體用法?Java Sdk.getVersionString怎麽用?Java Sdk.getVersionString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.projectRoots.Sdk的用法示例。


在下文中一共展示了Sdk.getVersionString方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkTargetJPDAInstalled

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
private static void checkTargetJPDAInstalled(JavaParameters parameters) throws ExecutionException {
  final Sdk jdk = parameters.getJdk();
  if (jdk == null) {
    throw new ExecutionException(DebuggerBundle.message("error.jdk.not.specified"));
  }
  final JavaSdkVersion version = JavaSdk.getInstance().getVersion(jdk);
  String versionString = jdk.getVersionString();
  if (version == JavaSdkVersion.JDK_1_0 || version == JavaSdkVersion.JDK_1_1) {
    throw new ExecutionException(DebuggerBundle.message("error.unsupported.jdk.version", versionString));
  }
  if (SystemInfo.isWindows && version == JavaSdkVersion.JDK_1_2) {
    final VirtualFile homeDirectory = jdk.getHomeDirectory();
    if (homeDirectory == null || !homeDirectory.isValid()) {
      throw new ExecutionException(DebuggerBundle.message("error.invalid.jdk.home", versionString));
    }
    //noinspection HardCodedStringLiteral
    File dllFile = new File(
      homeDirectory.getPath().replace('/', File.separatorChar) + File.separator + "bin" + File.separator + "jdwp.dll"
    );
    if (!dllFile.exists()) {
      GetJPDADialog dialog = new GetJPDADialog();
      dialog.show();
      throw new ExecutionException(DebuggerBundle.message("error.debug.libraries.missing"));
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:DebuggerManagerImpl.java

示例2: getExternalDocumentationRoot

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Override
public String getExternalDocumentationRoot(Sdk sdk) {
  final String versionString = sdk.getVersionString();
  if (versionString != null && StringUtil.startsWithIgnoreCase(versionString, "jython")) {
    return "http://jython.org/docs/library/";
  }
  final String pyVersion = PythonDocumentationProvider.pyVersion(versionString);
  StringBuilder urlBuilder = new StringBuilder("http://docs.python.org/");
  if (pyVersion != null) {
    urlBuilder.append(pyVersion).append("/");
  }
  if (pyVersion != null && (pyVersion.startsWith("2.4") || pyVersion.startsWith("2.5"))) {
    urlBuilder.append("lib/");
  }
  else {
    urlBuilder.append("library/");
  }
  return urlBuilder.toString();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:PyStdlibDocumentationLinkProvider.java

示例3: getLanguageLevel

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@NotNull
@Override
public LanguageLevel getLanguageLevel(@NotNull Sdk sdk) {
  final String versionString = sdk.getVersionString();
  if (versionString != null) {
    final Matcher matcher = VERSION_STRING_RE.matcher(versionString);
    if (matcher.matches()) {
      final String version = matcher.group(1);
      final String pythonVersion = matcher.group(3);
      if (pythonVersion != null) {
        return LanguageLevel.fromPythonVersion(pythonVersion);
      }
      else if (version != null) {
        return LanguageLevel.fromPythonVersion(getPythonVersion(version));
      }
    }
  }
  return LanguageLevel.getDefault();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:PyPySdkFlavor.java

示例4: findJdkVersion

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
private int findJdkVersion()
{
  Sdk projectSdk = ProjectRootManager.getInstance( _ijProject ).getProjectSdk();
  if( projectSdk == null )
  {
    return -1;
  }

  // expected format:
  // 'java version "1.8.1"'
  // 'java version "9.0.1"'
  // 'java version "10.0.1"'
  // etc.
  String version = projectSdk.getVersionString();
  int iQuote = version.indexOf( '"' );
  if( iQuote < 0 )
  {
    return -1;
  }

  String verNum = version.substring( iQuote+1 );
  int iDot = verNum.indexOf( '.' );
  if( iDot < 0 )
  {
    return -1;
  }

  verNum = verNum.substring( 0, iDot );
  if( verNum.equals( "1" ) )
  {
    return 8;
  }
  else
  {
    return Integer.parseInt( verNum );
  }
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:38,代碼來源:ManProject.java

示例5: forJdk

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@NotNull
@Override
public CellAppearanceEx forJdk(@Nullable final Sdk jdk, final boolean isInComboBox, final boolean selected, final boolean showVersion) {
  if (jdk == null) {
    return FileAppearanceService.getInstance().forInvalidUrl(NO_JDK);
  }

  String name = jdk.getName();
  CompositeAppearance appearance = new CompositeAppearance();
  SdkType sdkType = (SdkType)jdk.getSdkType();
  appearance.setIcon(sdkType.getIcon());
  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();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:OrderEntryAppearanceServiceImpl.java

示例6: addSourceCommandLineSwitch

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
public static void addSourceCommandLineSwitch(final Sdk jdk, LanguageLevel chunkLanguageLevel, @NonNls final List<String> commandLine) {
  final String versionString = jdk.getVersionString();
  if (StringUtil.isEmpty(versionString)) {
    throw new IllegalArgumentException(CompilerBundle.message("javac.error.unknown.jdk.version", jdk.getName()));
  }

  final LanguageLevel applicableLanguageLevel = getApplicableLanguageLevel(versionString, chunkLanguageLevel);
  if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_8)) {
    commandLine.add("-source");
    commandLine.add("8");
  }
  else if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_7)) {
    commandLine.add("-source");
    commandLine.add("1.7");
  }
  else if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_6)) {
    commandLine.add("-source");
    commandLine.add("1.6");
  }
  else if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_5)) {
    commandLine.add("-source");
    commandLine.add("1.5");
  }
  else if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_4)) {
    commandLine.add("-source");
    commandLine.add("1.4");
  }
  else if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_3)) {
    if (!(isOfVersion(versionString, "1.3") || isOfVersion(versionString, "1.2") || isOfVersion(versionString, "1.1"))) {
      //noinspection HardCodedStringLiteral
      commandLine.add("-source");
      commandLine.add("1.3");
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:36,代碼來源:CompilerUtil.java

示例7: PythonConsoleView

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
public PythonConsoleView(final Project project, final String title, final Sdk sdk) {
  super(project, title, PythonLanguage.getInstance());

  getVirtualFile().putUserData(LanguageLevel.KEY, PythonSdkType.getLanguageLevelForSdk(sdk));
  // Mark editor as console one, to prevent autopopup completion
  getConsoleEditor().putUserData(PythonConsoleAutopopupBlockingHandler.REPL_KEY, new Object());

  setPrompt(PyConsoleUtil.ORDINARY_PROMPT);
  setUpdateFoldingsEnabled(false);
  //noinspection ConstantConditions
  myPyHighlighter = new PyHighlighter(
    sdk != null && sdk.getVersionString() != null ? LanguageLevel.fromPythonVersion(sdk.getVersionString()) : LanguageLevel.getDefault());
  myScheme = getConsoleEditor().getColorsScheme();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:PythonConsoleView.java

示例8: getLanguageLevel

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@NotNull
public LanguageLevel getLanguageLevel(@NotNull Sdk sdk) {
  final String version = sdk.getVersionString();
  final String prefix = getName() + " ";
  if (version != null && version.startsWith(prefix)) {
    return LanguageLevel.fromPythonVersion(version.substring(prefix.length()));
  }
  return LanguageLevel.getDefault();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:PythonSdkFlavor.java

示例9: getProjectUsages

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@NotNull
@Override
public Set<UsageDescriptor> getProjectUsages(@NotNull Project project) throws CollectUsagesException {
  Set<UsageDescriptor> result = new HashSet<UsageDescriptor>();
  for(Module m: ModuleManager.getInstance(project).getModules()) {
    Sdk pythonSdk = PythonSdkType.findPythonSdk(m);
    if (pythonSdk != null) {
      String versionString = pythonSdk.getVersionString();
      if (versionString != null) {
        result.add(new UsageDescriptor(versionString, 1));
      }
    }
  }
  return result;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:PyInterpreterUsagesCollector.java

示例10: getModuleJavaVersion

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Nullable
public static String getModuleJavaVersion(@NotNull MavenProjectsManager mavenProjectsManager, @NotNull MavenProject mavenProject) {
  Sdk sdk = getModuleJdk(mavenProjectsManager, mavenProject);
  if (sdk == null) return null;

  return sdk.getVersionString();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:8,代碼來源:MavenUtil.java

示例11: getVersion

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@Nullable
private static JavaSdkVersion getVersion(@NotNull Sdk sdk) {
  String version = sdk.getVersionString();
  if (version == null) return null;
  return JdkVersionUtil.getVersion(version);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:7,代碼來源:JavaSuppressionUtil.java

示例12: isJdkSupportsLevel

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
private static boolean isJdkSupportsLevel(@Nullable final Sdk jdk, @NotNull LanguageLevel level) {
  if (jdk == null) return true;
  String versionString = jdk.getVersionString();
  JavaSdkVersion version = versionString == null ? null : JdkVersionUtil.getVersion(versionString);
  return version != null && version.getMaxLanguageLevel().isAtLeast(level);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:7,代碼來源:JavaSdkUtil.java

示例13: getBuildProcessRuntimeSdk

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
@NotNull
public static Pair<Sdk, JavaSdkVersion> getBuildProcessRuntimeSdk(Project project) {
  Sdk projectJdk = null;
  int sdkMinorVersion = 0;
  JavaSdkVersion sdkVersion = null;

  final Set<Sdk> candidates = new LinkedHashSet<Sdk>();
  final Sdk defaultSdk = ProjectRootManager.getInstance(project).getProjectSdk();
  if (defaultSdk != null && defaultSdk.getSdkType() instanceof JavaSdkType) {
    candidates.add(defaultSdk);
  }

  for (Module module : ModuleManager.getInstance(project).getModules()) {
    final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
    if (sdk != null && sdk.getSdkType() instanceof JavaSdkType) {
      candidates.add(sdk);
    }
  }

  // now select the latest version from the sdks that are used in the project, but not older than the internal sdk version
  final JavaSdk javaSdkType = JavaSdk.getInstance();
  for (Sdk candidate : candidates) {
    final String vs = candidate.getVersionString();
    if (vs != null) {
      final JavaSdkVersion candidateVersion = javaSdkType.getVersion(vs);
      if (candidateVersion != null) {
        final int candidateMinorVersion = getMinorVersion(vs);
        if (projectJdk == null) {
          sdkVersion = candidateVersion;
          sdkMinorVersion = candidateMinorVersion;
          projectJdk = candidate;
        }
        else {
          final int result = candidateVersion.compareTo(sdkVersion);
          if (result > 0 || (result == 0 && candidateMinorVersion > sdkMinorVersion)) {
            sdkVersion = candidateVersion;
            sdkMinorVersion = candidateMinorVersion;
            projectJdk = candidate;
          }
        }
      }
    }
  }

  final Sdk internalJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
  if (projectJdk == null || sdkVersion == null || !sdkVersion.isAtLeast(JavaSdkVersion.JDK_1_6)) {
    projectJdk = internalJdk;
    sdkVersion = javaSdkType.getVersion(internalJdk);
  }
  return Pair.create(projectJdk, sdkVersion);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:52,代碼來源:BuildManager.java

示例14: convert

import com.intellij.openapi.projectRoots.Sdk; //導入方法依賴的package包/類
public String convert(Sdk sdk) {
  return sdk.getVersionString();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:4,代碼來源:PathUtilEx.java


注:本文中的com.intellij.openapi.projectRoots.Sdk.getVersionString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。