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


Java CompilerUtil类代码示例

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


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


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