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


Java CompilerUtil.isOfVersion方法代码示例

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


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

示例1: checkCompiler

import com.intellij.compiler.impl.CompilerUtil; //导入方法依赖的package包/类
public boolean checkCompiler(final CompileScope scope) {
  final Module[] modules = scope.getAffectedModules();
  final Set<Sdk> checkedJdks = new HashSet<Sdk>();
  for (final Module module : modules) {
    final Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
    if (jdk == null || checkedJdks.contains(jdk)) {
      continue;
    }
    checkedJdks.add(jdk);
    final SdkTypeId sdkType = jdk.getSdkType();
    if (!(sdkType instanceof JavaSdkType)) {
      continue;
    }
    final VirtualFile homeDirectory = jdk.getHomeDirectory();
    if (homeDirectory == null) {
      //noinspection DialogTitleCapitalization
      Messages.showMessageDialog(
          myProject,
          ErrorProneIdeaBundle.jdkHomeNotFoundMessage(jdk),
          ErrorProneIdeaBundle.compilerName(),
          Messages.getErrorIcon()
      );
      return false;
    }
    final String vmExecutablePath = ((JavaSdkType)sdkType).getVMExecutablePath(jdk);
    if (vmExecutablePath == null) {
      Messages.showMessageDialog(
          myProject,
          ErrorProneIdeaBundle.message("error-prone.error.vm.executable.missing", jdk.getName()),
          ErrorProneIdeaBundle.compilerName(),
          Messages.getErrorIcon()
      );
      return false;
    }
    final String toolsJarPath = ((JavaSdkType)sdkType).getToolsPath(jdk);
    if (toolsJarPath == null) {
      Messages.showMessageDialog(
          myProject,
          ErrorProneIdeaBundle.message("error-prone.error.tools.jar.missing", jdk.getName()),
          ErrorProneIdeaBundle.compilerName(),
          Messages.getErrorIcon()
      );
      return false;
    }
    final String versionString = jdk.getVersionString();
    if (versionString == null) {
      Messages.showMessageDialog(
          myProject,
          ErrorProneIdeaBundle.message("error-prone.error.unknown.jdk.version", jdk.getName()),
          ErrorProneIdeaBundle.compilerName(),
          Messages.getErrorIcon()
      );
      return false;
    }

    if (CompilerUtil.isOfVersion(versionString, "1.0")) {
      Messages.showMessageDialog(
          myProject,
          ErrorProneIdeaBundle.message("error-prone.error.1_0_compilation.not.supported"),
          ErrorProneIdeaBundle.compilerName(),
          Messages.getErrorIcon()
      );
      return false;
    }
  }

  return true;
}
 
开发者ID:diy1,项目名称:error-prone-aspirator,代码行数:69,代码来源:ErrorProneIdeaCompiler.java

示例2: checkCompiler

import com.intellij.compiler.impl.CompilerUtil; //导入方法依赖的package包/类
public boolean checkCompiler(final CompileScope scope) {
  final Module[] modules = scope.getAffectedModules();
  final Set<Sdk> checkedJdks = new HashSet<Sdk>();
  for (final Module module : modules) {
    final Sdk jdk  = ModuleRootManager.getInstance(module).getSdk();
    if (jdk == null || checkedJdks.contains(jdk)) {
      continue;
    }
    checkedJdks.add(jdk);
    final SdkTypeId sdkType = jdk.getSdkType();
    if (!(sdkType instanceof JavaSdkType)) {
      continue;
    }
    final VirtualFile homeDirectory = jdk.getHomeDirectory();
    if (homeDirectory == null) {
      Messages.showMessageDialog(
        myProject, CompilerBundle.jdkHomeNotFoundMessage(jdk), CompilerBundle.message("compiler.javac.name"), Messages.getErrorIcon()
      );
      return false;
    }
    final String vmExecutablePath = ((JavaSdkType)sdkType).getVMExecutablePath(jdk);
    if (vmExecutablePath == null) {
      Messages.showMessageDialog(
        myProject, CompilerBundle.message("javac.error.vm.executable.missing", jdk.getName()), CompilerBundle.message("compiler.javac.name"), Messages.getErrorIcon()
      );
      return false;
    }
    final String toolsJarPath = ((JavaSdkType)sdkType).getToolsPath(jdk);
    if (toolsJarPath == null) {
      Messages.showMessageDialog(
        myProject, CompilerBundle.message("javac.error.tools.jar.missing", jdk.getName()), CompilerBundle.message("compiler.javac.name"), Messages.getErrorIcon()
      );
      return false;
    }
    final String versionString = jdk.getVersionString();
    if (versionString == null) {
      Messages.showMessageDialog(
        myProject, CompilerBundle.message("javac.error.unknown.jdk.version", jdk.getName()), CompilerBundle.message("compiler.javac.name"), Messages.getErrorIcon()
      );
      return false;
    }

    if (CompilerUtil.isOfVersion(versionString, "1.0")) {
      Messages.showMessageDialog(
        myProject, CompilerBundle.message("javac.error.1_0_compilation.not.supported"), CompilerBundle.message("compiler.javac.name"), Messages.getErrorIcon()
      );
      return false;
    }
  }

  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:53,代码来源:JavacCompiler.java


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