• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CompilerUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createParserSetupCommand

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
private static String[] createParserSetupCommand(final Sdk jdk) {

    final VirtualFile homeDirectory = jdk.getHomeDirectory();
    if (homeDirectory == null) {
      throw new IllegalArgumentException(CompilerBundle.jdkHomeNotFoundMessage(jdk));
    }

    final List<String> commandLine = new ArrayList<String>();
    commandLine.add(((JavaSdkType)jdk.getSdkType()).getVMExecutablePath(jdk));

    CompilerUtil.addLocaleOptions(commandLine, false);

    //noinspection HardCodedStringLiteral
    commandLine.add("-classpath");
    commandLine.add(((JavaSdkType)jdk.getSdkType()).getToolsPath(jdk) + File.pathSeparator + JavaSdkUtil.getIdeaRtJarPath());

    commandLine.add(JavacResourcesReader.class.getName());

    return ArrayUtil.toStringArray(commandLine);
  }
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:JavacOutputParserPool.java


示例2: createStartupCommand

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
private void createStartupCommand(final ModuleChunk chunk,
                                  @NonNls final ArrayList<String> commandLine,
                                  final String outputPath,
                                  final boolean useTempFile) throws IOException {
  final EclipseCompilerOptions options = EclipseCompilerConfiguration.getOptions(myProject, EclipseCompilerConfiguration.class);

  final Sdk projectJdk = JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk();
  final String vmExePath = ((JavaSdkType)projectJdk.getSdkType()).getVMExecutablePath(projectJdk);
  commandLine.add(vmExePath);
  commandLine.add("-Xmx" + options.MAXIMUM_HEAP_SIZE + "m");

  CompilerUtil.addLocaleOptions(commandLine, false);

  commandLine.add("-classpath");
  commandLine.add(PATH_TO_COMPILER_JAR);
  commandLine.add(getCompilerClass());

  addCommandLineOptions(commandLine, chunk, outputPath, options, useTempFile, true);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:EclipseCompiler.java


示例3: writeStubs

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
private static List<VirtualFile> writeStubs(VirtualFile outputRootDirectory, Map<String, CharSequence> output, VirtualFile src) {
  final ArrayList<VirtualFile> stubs = ContainerUtil.newArrayList();
  for (String relativePath : output.keySet()) {
    final File stubFile = new File(outputRootDirectory.getPath(), relativePath);
    FileUtil.createIfDoesntExist(stubFile);
    try {
      FileUtil.writeToFile(stubFile, output.get(relativePath).toString().getBytes(src.getCharset()));
    }
    catch (IOException e) {
      LOG.error(e);
    }
    CompilerUtil.refreshIOFile(stubFile);
    ContainerUtil.addIfNotNull(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(stubFile), stubs);
  }
  return stubs;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:GroovycStubGenerator.java


示例4: run

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
public static void run(@NotNull AndroidAutogeneratorMode mode,
                       @NotNull AndroidFacet facet,
                       @NotNull CompileContext context,
                       boolean force) {
  if (!toRun(mode, facet, force)) {
    return;
  }
  final Set<String> obsoleteFiles = new HashSet<String>(facet.getAutogeneratedFiles(mode));

  switch (mode) {
    case AAPT:
      runAapt(facet, context, force);
      break;
    case AIDL:
      runAidl(facet, context);
      break;
    case RENDERSCRIPT:
      runRenderscript(facet, context);
      break;
    case BUILDCONFIG:
      runBuildConfigGenerator(facet, context);
      break;
    default:
      LOG.error("Unknown mode" + mode);
  }
  obsoleteFiles.removeAll(facet.getAutogeneratedFiles(mode));

  for (String path : obsoleteFiles) {
    final File file = new File(path);

    if (file.isFile()) {
      FileUtil.delete(file);
      CompilerUtil.refreshIOFile(file);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:AndroidAutogenerator.java


示例5: generate

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
public GenerationItem[] generate(CompileContext context, GenerationItem[] items, VirtualFile outputRootDirectory) {
    if (JFlex.isCompilationEnabled()) {
        if (items != null && items.length > 0) {
            Application application = ApplicationManager.getApplication();
            GenerationItem[] generationItems = application.runReadAction(new GenerateAction(context, items, outputRootDirectory, ProjectRootManager.getInstance(context.getProject()).getProjectSdk()));
            for (GenerationItem item : generationItems) {
                CompilerUtil.refreshIOFile(((JFlexGenerationItem) item).getGeneratedFile());
            }
            return generationItems;
        }
    }
    return EMPTY_GENERATION_ITEM_ARRAY;
}
 
开发者ID:jflex-de,项目名称:idea-jflex,代码行数:14,代码来源:JFlexSourceGeneratingCompiler.java


示例6: addCommandLineOptions

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
public static void addCommandLineOptions(@NotNull ModuleChunk chunk,
                                         @NonNls List<String> commandLine,
                                         @NotNull String outputPath,
                                         @NotNull Sdk jdk,
                                         boolean isAnnotationProcessingMode) throws IOException {

  LanguageLevel languageLevel = chunk.getLanguageLevel();
  CompilerUtil.addSourceCommandLineSwitch(jdk, languageLevel, commandLine);

  commandLine.add("-verbose");

  final String bootCp = chunk.getCompilationBootClasspath();

  final String classPath = chunk.getCompilationClasspath();
  commandLine.add("-bootclasspath");
  addClassPathValue(commandLine, bootCp);

  commandLine.add("-classpath");
  addClassPathValue(commandLine, classPath);

  if (isAnnotationProcessingMode) {
    commandLine.add("-s");
    commandLine.add(outputPath.replace('/', File.separatorChar));
    final String moduleOutputPath = CompilerPaths.getModuleOutputPath(chunk.getModules()[0], false);
    if (moduleOutputPath != null) {
      commandLine.add("-d");
      commandLine.add(moduleOutputPath.replace('/', File.separatorChar));
    }
  }
  else {
    commandLine.add("-d");
    commandLine.add(outputPath.replace('/', File.separatorChar));
  }
}
 
开发者ID:diy1,项目名称:error-prone-aspirator,代码行数:35,代码来源:ErrorProneIdeaCompiler.java


示例7: processItems

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
@Override
public void processItems(@NotNull final ArtifactBuildTarget target,
                         @NotNull final List<GenericCompilerProcessingItem<ArtifactCompilerCompileItem,VirtualFilePersistentState,ArtifactPackagingItemOutputState>> changedItems,
                         @NotNull List<GenericCompilerCacheState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems,
                         @NotNull OutputConsumer<ArtifactCompilerCompileItem> consumer) {

  final THashSet<String> deletedJars = deleteFiles(obsoleteItems, changedItems);

  final Set<String> writtenPaths = createPathsHashSet();
  final Ref<Boolean> built = Ref.create(false);
  final Set<ArtifactCompilerCompileItem> processedItems = new HashSet<ArtifactCompilerCompileItem>();
  CompilerUtil.runInContext(myContext, "Copying files", new ThrowableRunnable<RuntimeException>() {
    public void run() throws RuntimeException {
      built.set(doBuild(target.getArtifact(), changedItems, processedItems, writtenPaths, deletedJars));
    }
  });
  if (!built.get()) {
    return;
  }

  myContext.getProgressIndicator().setText(CompilerBundle.message("packaging.compiler.message.updating.caches"));
  myContext.getProgressIndicator().setText2("");
  for (String path : writtenPaths) {
    consumer.addFileToRefresh(new File(path));
  }
  for (ArtifactCompilerCompileItem item : processedItems) {
    consumer.addProcessedItem(item);
  }
  ArtifactsCompiler.addWrittenPaths(myContext, writtenPaths);
  ArtifactsCompiler.addChangedArtifact(myContext, target.getArtifact());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:ArtifactsCompilerInstance.java


示例8: deleteGeneratedFiles

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
public void deleteGeneratedFiles() {
  if (FileUtil.delete(myStub)) {
    CompilerUtil.refreshIOFile(myStub);
  }
  if (FileUtil.delete(mySkel)) {
    CompilerUtil.refreshIOFile(mySkel);
  }
  if (FileUtil.delete(myTie)) {
    CompilerUtil.refreshIOFile(myTie);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:RmicCompiler.java


示例9: setupSourceVersion

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
@SuppressWarnings({"HardCodedStringLiteral"})
private static void setupSourceVersion(final ModuleChunk chunk, final ArrayList<String> commandLine) {
  final Sdk jdk = chunk.getJdk();
  final String versionString = jdk.getVersionString();

  final LanguageLevel applicableLanguageLevel = CompilerUtil.getApplicableLanguageLevel(versionString, chunk.getLanguageLevel());
  if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_5)) {
    commandLine.add("-source");
    commandLine.add("1.4"); // -source 1.5 not supported yet by jikes, so use the highest possible version
  }
  else if (applicableLanguageLevel.equals(LanguageLevel.JDK_1_4)) {
    commandLine.add("-source");
    commandLine.add("1.4");
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:JikesCompiler.java


示例10: compileFinished

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
private void compileFinished(int exitValue, final ModuleChunk chunk, final String outputDir) {
  if (exitValue != 0 && !myCompileContext.getProgressIndicator().isCanceled() && myCompileContext.getMessageCount(CompilerMessageCategory.ERROR) == 0) {
    myCompileContext.addMessage(CompilerMessageCategory.ERROR, CompilerBundle.message("error.compiler.internal.error", exitValue), null, -1, -1);
  }

  myCompiler.compileFinished();
  final List<File> toRefresh = new ArrayList<File>();
  final Map<String, Collection<TranslatingCompiler.OutputItem>> results = new HashMap<String, Collection<TranslatingCompiler.OutputItem>>();
  try {
    final FileTypeManager typeManager = FileTypeManager.getInstance();
    final String outputDirPath = outputDir.replace(File.separatorChar, '/');
    try {
      for (final Module module : chunk.getModules()) {
        for (final VirtualFile root : chunk.getSourceRoots(module)) {
          final String packagePrefix = myProjectFileIndex.getPackageNameByDirectory(root);
          if (LOG.isDebugEnabled()) {
            LOG.debug("Building output items for " + root.getPresentableUrl() + "; output dir = " + outputDirPath + "; packagePrefix = \"" + packagePrefix + "\"");
          }
          buildOutputItemsList(outputDirPath, module, root, typeManager, root, packagePrefix, toRefresh, results);
        }
      }
    }
    catch (CacheCorruptedException e) {
      myCompileContext.requestRebuildNextTime(CompilerBundle.message("error.compiler.caches.corrupted"));
      if (LOG.isDebugEnabled()) {
        LOG.debug(e);
      }
    }
  }
  finally {
    CompilerUtil.refreshIOFiles(toRefresh);
    for (Iterator<Map.Entry<String, Collection<TranslatingCompiler.OutputItem>>> it = results.entrySet().iterator(); it.hasNext();) {
      Map.Entry<String, Collection<TranslatingCompiler.OutputItem>> entry = it.next();
      mySink.add(entry.getKey(), entry.getValue(), VirtualFile.EMPTY_ARRAY);
      it.remove(); // to free memory
    }
  }
  myFileNameToSourceMap.clear(); // clear the map before the next use
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:40,代码来源:BackendCompilerWrapper.java


示例11: compile

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
public void compile(final CompileContext context, Chunk<Module> moduleChunk, final VirtualFile[] files, OutputSink sink) {
  final List<File> filesToRefresh = new ArrayList<File>();
  final Map<String, Collection<OutputItem>> outputs = new HashMap<String, Collection<OutputItem>>();
  ApplicationManager.getApplication().runReadAction(new Runnable() {
    public void run() {
      for (final VirtualFile file : files) {
        final Module module = context.getModuleByFile(file);
        try {
          final VirtualFile outputDir = context.getModuleOutputDirectory(module);
          if (outputDir != null) {
            final String outputDirPath = outputDir.getPath();
            final File compiledFile = doCompile(outputDir, file);
            filesToRefresh.add(compiledFile);
            Collection<OutputItem> collection = outputs.get(outputDirPath);
            if (collection == null) {
              collection = new ArrayList<OutputItem>();
              outputs.put(outputDirPath, collection);
            }
            collection.add(new OutputItemImpl(FileUtil.toSystemIndependentName(compiledFile.getPath()), file));
          }
        }
        catch (IOException e) {
          context.addMessage(CompilerMessageCategory.ERROR, e.getMessage(), null, 0, 0);
        }
      }
    }
  });
  CompilerUtil.refreshIOFiles(filesToRefresh);
  for (Map.Entry<String, Collection<OutputItem>> entry : outputs.entrySet()) {
    sink.add(entry.getKey(), entry.getValue(), VirtualFile.EMPTY_ARRAY);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:DummyTranslatingCompiler.java


示例12: addStubsToCompileScope

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
protected static void addStubsToCompileScope(List<String> outputPaths, CompileContext compileContext, Module module) {
  List<VirtualFile> stubFiles = new ArrayList<VirtualFile>();
  for (String outputPath : outputPaths) {
    final File stub = new File(outputPath);
    CompilerUtil.refreshIOFile(stub);
    final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(stub);
    ContainerUtil.addIfNotNull(file, stubFiles);
  }
  ((CompileContextEx)compileContext).addScope(new FileSetCompileScope(stubFiles, new Module[]{module}));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:GroovyCompilerBase.java


示例13: compile

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
public void compile(final CompileContext compileContext, Chunk<Module> moduleChunk, final VirtualFile[] virtualFiles, OutputSink sink) {
  Map<Module, List<VirtualFile>> mapModulesToVirtualFiles;
  if (moduleChunk.getNodes().size() == 1) {
    mapModulesToVirtualFiles = Collections.singletonMap(moduleChunk.getNodes().iterator().next(), Arrays.asList(virtualFiles));
  }
  else {
    mapModulesToVirtualFiles = CompilerUtil.buildModuleToFilesMap(compileContext, virtualFiles);
  }
  for (final Module module : moduleChunk.getNodes()) {
    final List<VirtualFile> moduleFiles = mapModulesToVirtualFiles.get(module);
    if (moduleFiles == null) {
      continue;
    }

    final ModuleFileIndex index = ModuleRootManager.getInstance(module).getFileIndex();
    final List<VirtualFile> toCompile = new ArrayList<VirtualFile>();
    final List<VirtualFile> toCompileTests = new ArrayList<VirtualFile>();
    final CompilerConfiguration configuration = CompilerConfiguration.getInstance(myProject);
    final PsiManager psiManager = PsiManager.getInstance(myProject);

    if (GroovyUtils.isAcceptableModuleType(ModuleType.get(module))) {
      for (final VirtualFile file : moduleFiles) {
        if (shouldCompile(file, configuration, psiManager)) {
          (index.isInTestSourceContent(file) ? toCompileTests : toCompile).add(file);
        }
      }
    }

    if (!toCompile.isEmpty()) {
      compileFiles(compileContext, module, toCompile, sink, false);
    }
    if (!toCompileTests.isEmpty()) {
      compileFiles(compileContext, module, toCompileTests, sink, true);
    }

  }

}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:39,代码来源:GroovyCompilerBase.java


示例14: processItems

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
@Override
public void processItems(@Nonnull final ArtifactBuildTarget target,
                         @Nonnull final List<GenericCompilerProcessingItem<ArtifactCompilerCompileItem,VirtualFilePersistentState,ArtifactPackagingItemOutputState>> changedItems,
                         @Nonnull List<GenericCompilerCacheState<String, VirtualFilePersistentState, ArtifactPackagingItemOutputState>> obsoleteItems,
                         @Nonnull OutputConsumer<ArtifactCompilerCompileItem> consumer) {

  final THashSet<String> deletedJars = deleteFiles(obsoleteItems, changedItems);

  final Set<String> writtenPaths = createPathsHashSet();
  final Ref<Boolean> built = Ref.create(false);
  final Set<ArtifactCompilerCompileItem> processedItems = new HashSet<ArtifactCompilerCompileItem>();
  CompilerUtil.runInContext(myContext, "Copying files", new ThrowableRunnable<RuntimeException>() {
    @Override
    public void run() throws RuntimeException {
      built.set(doBuild(target.getArtifact(), changedItems, processedItems, writtenPaths, deletedJars));
    }
  });
  if (!built.get()) {
    return;
  }

  myContext.getProgressIndicator().setText(CompilerBundle.message("packaging.compiler.message.updating.caches"));
  myContext.getProgressIndicator().setText2("");
  for (String path : writtenPaths) {
    consumer.addFileToRefresh(new File(path));
  }
  for (ArtifactCompilerCompileItem item : processedItems) {
    consumer.addProcessedItem(item);
  }
  ArtifactsCompiler.addWrittenPaths(myContext, writtenPaths);
  ArtifactsCompiler.addChangedArtifact(myContext, target.getArtifact());
}
 
开发者ID:consulo,项目名称:consulo,代码行数:33,代码来源:ArtifactsCompilerInstance.java


示例15: buildModuleToFilesMap

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
private Map<Module, List<VirtualFile>> buildModuleToFilesMap(final List<VirtualFile> filesToCompile)
{
	if(myChunk.getNodes().size() == 1)
	{
		return Collections.singletonMap(myChunk.getNodes().iterator().next(), Collections.unmodifiableList(filesToCompile));
	}
	return CompilerUtil.buildModuleToFilesMap(myCompileContext, filesToCompile);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:9,代码来源:BackendCompilerWrapper.java


示例16: 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


示例17: 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


示例18: addCommandLineOptions

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
public static void addCommandLineOptions(ModuleChunk chunk, @NonNls List<String> commandLine, String outputPath, Sdk jdk,
                                         boolean version1_0,
                                         boolean version1_1,
                                         List<File> tempFiles, boolean addSourcePath, boolean useTempFile,
                                         boolean isAnnotationProcessingMode) throws IOException {

  LanguageLevel languageLevel = chunk.getLanguageLevel();
  CompilerUtil.addSourceCommandLineSwitch(jdk, languageLevel, commandLine);
  CompilerUtil.addTargetCommandLineSwitch(chunk, commandLine);

  commandLine.add("-verbose");

  final String cp = chunk.getCompilationClasspath();
  final String bootCp = chunk.getCompilationBootClasspath();

  final String classPath;
  if (version1_0 || version1_1) {
    classPath = bootCp + File.pathSeparator + cp;
  }
  else {
    classPath = cp;
    commandLine.add("-bootclasspath");
    addClassPathValue(jdk, false, commandLine, bootCp, "javac_bootcp", tempFiles, useTempFile);
  }

  commandLine.add("-classpath");
  addClassPathValue(jdk, version1_0, commandLine, classPath, "javac_cp", tempFiles, useTempFile);

  if (!version1_1 && !version1_0 && addSourcePath) {
    commandLine.add("-sourcepath");
    // this way we tell the compiler that the sourcepath is "empty". However, javac thinks that sourcepath is 'new File("")'
    // this may cause problems if we have java code in IDEA working directory
    if (isAnnotationProcessingMode) {
      final int currentSourcesMode = chunk.getSourcesFilter();
      commandLine.add(chunk.getSourcePath(currentSourcesMode == ModuleChunk.TEST_SOURCES? ModuleChunk.ALL_SOURCES : currentSourcesMode));
    }
    else {
      commandLine.add("\"\"");
    }
  }

  if (isAnnotationProcessingMode) {
    commandLine.add("-s");
    commandLine.add(outputPath.replace('/', File.separatorChar));
    final String moduleOutputPath = CompilerPaths.getModuleOutputPath(chunk.getModules()[0], false);
    if (moduleOutputPath != null) {
      commandLine.add("-d");
      commandLine.add(moduleOutputPath.replace('/', File.separatorChar));
    }
  }
  else {
    commandLine.add("-d");
    commandLine.add(outputPath.replace('/', File.separatorChar));
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:56,代码来源:JavacCompiler.java


示例19: buildModuleToFilesMap

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
private Map<Module, List<VirtualFile>> buildModuleToFilesMap(final List<VirtualFile> filesToCompile) {
  if (myChunk.getNodes().size() == 1) {
    return Collections.singletonMap(myChunk.getNodes().iterator().next(), Collections.unmodifiableList(filesToCompile));
  }
  return CompilerUtil.buildModuleToFilesMap(myCompileContext, filesToCompile);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:7,代码来源:BackendCompilerWrapper.java


示例20: process

import com.intellij.compiler.impl.CompilerUtil; //导入依赖的package包/类
public ProcessingItem[] process(final CompileContext context, ProcessingItem[] items) {
  context.getProgressIndicator().setText("Processing Maven resources...");

  List<ProcessingItem> result = new ArrayList<ProcessingItem>(items.length);
  List<File> filesToRefresh = new ArrayList<File>(items.length);

  deleteOutdatedFile(context.getUserData(FILES_TO_DELETE_KEY), filesToRefresh);

  for (int i = 0; i < items.length; i++) {
    if (!(items[i] instanceof MyProcessingItem)) continue;

    context.getProgressIndicator().setFraction(((double)i) / items.length);
    context.getProgressIndicator().checkCanceled();

    MyProcessingItem eachItem = (MyProcessingItem)items[i];
    VirtualFile sourceVirtualFile = eachItem.getFile();
    File sourceFile = new File(sourceVirtualFile.getPath());
    File outputFile = new File(eachItem.getOutputPath());

    try {
      outputFile.getParentFile().mkdirs();

      boolean shouldFilter = eachItem.isFiltered();
      if (shouldFilter && sourceFile.length() > 10 * 1024 * 1024) {
        context.addMessage(CompilerMessageCategory.WARNING,
                           "Maven: File is too big to be filtered. Most likely it is a binary file and should be excluded from filtering.",
                           sourceVirtualFile.getUrl(), -1, -1);
        shouldFilter = false;
      }

      if (shouldFilter) {
        String charset = sourceVirtualFile.getCharset().name();
        String text = new String(FileUtil.loadFileBytes(sourceFile), charset);

        PrintWriter printWriter = new PrintWriter(outputFile, charset);
        try {
          MavenPropertyResolver.doFilterText(eachItem.getModule(),
                                             text,
                                             eachItem.getProperties(),
                                             eachItem.getEscapeString(),
                                             printWriter);
        }
        finally {
          printWriter.close();
        }
      }
      else {
        FileUtil.copy(sourceFile, outputFile);
      }

      eachItem.getValidityState().setOutputFileTimestamp(outputFile.lastModified());
      result.add(eachItem);
      filesToRefresh.add(outputFile);
    }
    catch (IOException e) {
      MavenLog.LOG.info(e);
      context.addMessage(CompilerMessageCategory.ERROR,
                         "Maven: Cannot process resource file: " + e.getMessage(),
                         sourceVirtualFile.getUrl(),
                         -1,
                         -1);
    }
  }
  CompilerUtil.refreshIOFiles(filesToRefresh);
  return result.toArray(new ProcessingItem[result.size()]);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:67,代码来源:MavenResourceCompiler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AsyncInvoker类代码示例发布时间:2022-05-23
下一篇:
Java CElement类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap