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);
 }
  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
  }
示例#3
0
  @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");
    }
  }