diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java index eccce5104a00..54b67af6e2f7 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.compiler.impl; import com.intellij.CommonBundle; @@ -84,24 +83,23 @@ import java.util.concurrent.TimeUnit; import static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope; public class CompileDriver { - private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.CompileDriver"); - private final Project myProject; + private static final Key COMPILATION_STARTED_AUTOMATICALLY = Key.create("compilation_started_automatically"); + private static final Key COMPILE_SERVER_BUILD_STATUS = Key.create("COMPILE_SERVER_BUILD_STATUS"); + private static final long ONE_MINUTE_MS = 60L * 1000L; + private final Project myProject; private final Map myModuleOutputPaths = new HashMap<>(); private final Map myModuleTestOutputPaths = new HashMap<>(); - private static final Key COMPILATION_STARTED_AUTOMATICALLY = Key.create("compilation_started_automatically"); - - private CompilerFilter myCompilerFilter = CompilerFilter.ALL; - - private static final long ONE_MINUTE_MS = 60L /*sec*/ * 1000L /*millisec*/; + @SuppressWarnings("deprecation") private CompilerFilter myCompilerFilter = CompilerFilter.ALL; public CompileDriver(Project project) { myProject = project; } + @SuppressWarnings("deprecation") public void setCompilerFilter(CompilerFilter compilerFilter) { myCompilerFilter = compilerFilter == null? CompilerFilter.ALL : compilerFilter; } @@ -356,9 +354,6 @@ public class CompileDriver { }); } - - private static final Key COMPILE_SERVER_BUILD_STATUS = Key.create("COMPILE_SERVER_BUILD_STATUS"); - private void startup(final CompileScope scope, final boolean isRebuild, final boolean forceCompile, @@ -366,8 +361,7 @@ public class CompileDriver { final CompilerMessage message) { ApplicationManager.getApplication().assertIsDispatchThread(); - final String contentName = - forceCompile ? CompilerBundle.message("compiler.content.name.compile") : CompilerBundle.message("compiler.content.name.make"); + final String contentName = CompilerBundle.message(forceCompile ? "compiler.content.name.compile" : "compiler.content.name.make"); final boolean isUnitTestMode = ApplicationManager.getApplication().isUnitTestMode(); final CompilerTask compileTask = new CompilerTask(myProject, contentName, isUnitTestMode, true, true, isCompilationStartedAutomatically(scope)); @@ -541,27 +535,10 @@ public class CompileDriver { return message; } - /* - private void dropScopesCaches() { - // hack to be sure the classpath will include the output directories - ApplicationManager.getApplication().runReadAction(new Runnable() { - public void run() { - ((ProjectRootManagerEx)ProjectRootManager.getInstance(myProject)).clearScopesCachesForModules(); - } - }); - } - */ - // [mike] performance optimization - this method is accessed > 15,000 times in Aurora - private String getModuleOutputPath(final Module module, boolean inTestSourceContent) { - final Map map = inTestSourceContent ? myModuleTestOutputPaths : myModuleOutputPaths; - String path = map.get(module); - if (path == null) { - path = CompilerPaths.getModuleOutputPath(module, inTestSourceContent); - map.put(module, path); - } - - return path; + private String getModuleOutputPath(Module module, boolean inTestSourceContent) { + Map map = inTestSourceContent ? myModuleTestOutputPaths : myModuleOutputPaths; + return map.computeIfAbsent(module, k -> CompilerPaths.getModuleOutputPath(module, inTestSourceContent)); } public void executeCompileTask(final CompileTask task, final CompileScope scope, final String contentName, final Runnable onTaskFinished) { @@ -595,9 +572,8 @@ public class CompileDriver { try { CompileTask[] tasks = beforeTasks ? manager.getBeforeTasks() : manager.getAfterTasks(); if (tasks.length > 0) { - progressIndicator.setText(beforeTasks - ? CompilerBundle.message("progress.executing.precompile.tasks") - : CompilerBundle.message("progress.executing.postcompile.tasks")); + progressIndicator.setText( + CompilerBundle.message(beforeTasks ? "progress.executing.precompile.tasks" : "progress.executing.postcompile.tasks")); for (CompileTask task : tasks) { if (!task.execute(context)) { return false; @@ -809,4 +785,4 @@ public class CompileDriver { } } } -} +} \ No newline at end of file diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/java/JavaBuilderUtil.java b/jps/jps-builders/src/org/jetbrains/jps/builders/java/JavaBuilderUtil.java index 5f273028135a..6382ce3c253d 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/builders/java/JavaBuilderUtil.java +++ b/jps/jps-builders/src/org/jetbrains/jps/builders/java/JavaBuilderUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +53,9 @@ import java.util.*; * @author nik */ public class JavaBuilderUtil { + public static final Key CONSTANT_SEARCH_SERVICE = Key.create("_constant_search_service_"); + + private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.Builder"); private static final Key> ALL_AFFECTED_FILES_KEY = Key.create("_all_affected_files_"); private static final Key> ALL_COMPILED_FILES_KEY = Key.create("_all_compiled_files_"); private static final Key> FILES_TO_COMPILE_KEY = Key.create("_files_to_compile_"); @@ -60,13 +63,11 @@ public class JavaBuilderUtil { private static final Key> SUCCESSFULLY_COMPILED_FILES_KEY = Key.create("_successfully_compiled_files_"); private static final Key> SKIP_MARKING_DIRTY_FILTERS_KEY = Key.create("_skip_marking_dirty_filters_"); private static final Key> MAPPINGS_DELTA_KEY = Key.create("_mappings_delta_"); - public static final Key CONSTANT_SEARCH_SERVICE = Key.create("_constant_search_service_"); - private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.Builder"); public static void registerFileToCompile(CompileContext context, File file) { registerFilesToCompile(context, Collections.singleton(file)); } - + public static void registerFilesToCompile(CompileContext context, Collection files) { getFilesContainer(context, FILES_TO_COMPILE_KEY).addAll(files); } @@ -130,8 +131,10 @@ public class JavaBuilderUtil { } /** - * @deprecated this method isn't supposed to be called by plugins anymore, the mappings are updated by the build process infrastructure automatically. - * Use {@link #getDependenciesRegistrar(CompileContext)}, {@link #registerFilesToCompile(CompileContext, Collection)}, {@link #registerSuccessfullyCompiled(CompileContext, Collection)} instead. + * @deprecated this method isn't supposed to be called by plugins anymore, the mappings are updated + * by the build process infrastructure automatically. Use {@link #getDependenciesRegistrar(CompileContext)}, + * {@link #registerFilesToCompile(CompileContext, Collection)}, or + * {@link #registerSuccessfullyCompiled(CompileContext, Collection)} instead. */ public static boolean updateMappings(CompileContext context, final Mappings delta, @@ -319,8 +322,8 @@ public class JavaBuilderUtil { public static boolean isForcedRecompilationAllJavaModules(CompileContext context) { CompileScope scope = context.getScope(); - return scope.isBuildForcedForAllTargets(JavaModuleBuildTargetType.PRODUCTION) && scope.isBuildForcedForAllTargets( - JavaModuleBuildTargetType.TEST); + return scope.isBuildForcedForAllTargets(JavaModuleBuildTargetType.PRODUCTION) && + scope.isBuildForcedForAllTargets(JavaModuleBuildTargetType.TEST); } public static boolean isCompileJavaIncrementally(CompileContext context) { @@ -465,4 +468,4 @@ public class JavaBuilderUtil { return !myFilter.accept(pathname); } } -} +} \ No newline at end of file diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/BuildOperations.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/BuildOperations.java index e66b3743211f..beb3df64c1d9 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/BuildOperations.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/BuildOperations.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,11 +39,10 @@ import java.util.*; /** * @author Eugene Zhuravlev - * Date: 10/30/12 + * @since 30.10.2012 */ public class BuildOperations { - private BuildOperations() { - } + private BuildOperations() { } public static void ensureFSStateInitialized(CompileContext context, BuildTarget target) throws IOException { final ProjectDescriptor pd = context.getProjectDescriptor(); @@ -135,13 +134,13 @@ public class BuildOperations { Map> cleanOutputsCorrespondingToChangedFiles(final CompileContext context, DirtyFilesHolder dirtyFilesHolder) throws ProjectBuildException { final BuildDataManager dataManager = context.getProjectDescriptor().dataManager; try { - final Map> cleanedSources = new java.util.HashMap>(); + final Map> cleanedSources = new HashMap>(); final THashSet dirsToDelete = new THashSet(FileUtil.FILE_HASHING_STRATEGY); final Collection deletedPaths = new ArrayList(); dirtyFilesHolder.processDirtyFiles(new FileProcessor() { - private final Map mappingsCache = new java.util.HashMap(); // cache the mapping locally + private final Map mappingsCache = new HashMap(); // cache the mapping locally private final TObjectIntHashMap idsCache = new TObjectIntHashMap(); @Override @@ -226,4 +225,4 @@ public class BuildOperations { } return deleted; } -} +} \ No newline at end of file diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildTargetConfiguration.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildTargetConfiguration.java index abf0ca97aaf9..090d8997a20c 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildTargetConfiguration.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/storage/BuildTargetConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,12 +38,14 @@ import java.util.Set; */ public class BuildTargetConfiguration { public static final Key> MODULES_WITH_TARGET_CONFIG_CHANGED_KEY = GlobalContextKey.create("_modules_with_target_config_changed_"); + private static final Logger LOG = Logger.getInstance(BuildTargetConfiguration.class); + private static final GlobalContextKey> ALL_DELETED_ROOTS_KEY = GlobalContextKey.create("_all_deleted_output_roots_"); + private final BuildTarget myTarget; private final BuildTargetsState myTargetsState; private String myConfiguration; private volatile String myCurrentState; - private static final GlobalContextKey> ALL_DELETED_ROOTS_KEY = GlobalContextKey.create("_all_deleted_output_roots_"); public BuildTargetConfiguration(BuildTarget target, BuildTargetsState targetsState) { myTarget = target; @@ -140,7 +142,7 @@ public class BuildTargetConfiguration { } File file = getNonexistentOutputsFile(); if (nonexistentOutputRoots.isEmpty()) { - file.delete(); + FileUtil.delete(file); } else { FileUtil.writeToFile(file, StringUtil.join(nonexistentOutputRoots, "\n")); @@ -186,4 +188,4 @@ public class BuildTargetConfiguration { } return !storedNonExistentOutputs.containsAll(nonexistentOutputRoots); } -} +} \ No newline at end of file