GWT: don't start (slow and non-incremental) GWT compilation for whole module if ... appcode/144.694 clion/144.698
authornik <Nikolay.Chashnikov@jetbrains.com>
Wed, 28 Oct 2015 18:04:47 +0000 (21:04 +0300)
committernik <Nikolay.Chashnikov@jetbrains.com>
Thu, 29 Oct 2015 08:44:46 +0000 (11:44 +0300)
jps/jps-builders/src/org/jetbrains/jps/incremental/CompileScope.java
jps/jps-builders/src/org/jetbrains/jps/incremental/CompileScopeImpl.java
jps/jps-builders/testSrc/org/jetbrains/jps/builders/CompileScopeTestBuilder.java

index 4028622768d55ac9e1368400cb284c0cc42bc36b..1be4088043bdceafbc7c3a92134b7f4e0dd64fd0 100644 (file)
@@ -28,8 +28,16 @@ import java.io.File;
 public abstract class CompileScope {
   public abstract boolean isAffected(BuildTarget<?> target, @NotNull File file);
 
+  /**
+   * @return {@code true} if at least one file from {@code target} is included into the scope
+   */
   public abstract boolean isAffected(@NotNull BuildTarget<?> target);
 
+  /**
+   * @return {@code true} if all files from {@code target} are included into the scope
+   */
+  public abstract boolean isWholeTargetAffected(@NotNull BuildTarget<?> target);
+
   public abstract boolean isBuildForced(@NotNull BuildTarget<?> target);
 
   public abstract boolean isBuildForcedForAllTargets(@NotNull BuildTargetType<?> targetType);
index afb1f271a59726dca1c97d48ad5bfcc6a0c341cc..d3a6ca5d443bdb6e530fdd538347d232364a9b40 100644 (file)
@@ -62,13 +62,17 @@ public class CompileScopeImpl extends CompileScope {
 
   @Override
   public boolean isAffected(@NotNull BuildTarget<?> target) {
-    return myTypes.contains(target.getTargetType()) || myTargets.contains(target) || myFiles.containsKey(target) || isAffectedByAssociatedModule(target);
+    return isWholeTargetAffected(target) || myFiles.containsKey(target);
+  }
+
+  @Override
+  public boolean isWholeTargetAffected(@NotNull BuildTarget<?> target) {
+    return myTypes.contains(target.getTargetType()) || myTargets.contains(target) || isAffectedByAssociatedModule(target);
   }
 
   @Override
   public boolean isBuildForced(@NotNull BuildTarget<?> target) {
-    BuildTargetType<?> type = target.getTargetType();
-    return myTypesToForceBuild.contains(type) && myFiles.isEmpty() && (myTypes.contains(type) || myTargets.contains(target) || isAffectedByAssociatedModule(target));
+    return myTypesToForceBuild.contains(target.getTargetType()) && myFiles.isEmpty() && isWholeTargetAffected(target);
   }
 
   @Override
index 73f1e3ebe1e09876c35de512992603036cd519f1..d633583e91600fcd4e0216cafaa174a00949ff96 100644 (file)
@@ -35,6 +35,7 @@ public class CompileScopeTestBuilder {
   private final boolean myForceBuild;
   private final Set<BuildTargetType<?>> myTargetTypes = new HashSet<BuildTargetType<?>>();
   private final Set<BuildTarget<?>> myTargets = new HashSet<BuildTarget<?>>();
+  private LinkedHashMap<BuildTarget<?>, Set<File>> myFiles = new LinkedHashMap<BuildTarget<?>, Set<File>>();
 
   public static CompileScopeTestBuilder rebuild() {
     return new CompileScopeTestBuilder(true);
@@ -78,9 +79,19 @@ public class CompileScopeTestBuilder {
     return this;
   }
 
+  public CompileScopeTestBuilder file(BuildTarget<?> target, String path) {
+    Set<File> files = myFiles.get(target);
+    if (files == null) {
+      files = new LinkedHashSet<File>();
+      myFiles.put(target, files);
+    }
+    files.add(new File(path));
+    return this;
+  }
+
   public CompileScope build() {
     Collection<BuildTargetType<?>> typesToForceBuild = myForceBuild ? myTargetTypes : Collections.<BuildTargetType<?>>emptyList();
-    return new CompileScopeImpl(myTargetTypes, typesToForceBuild, myTargets, Collections.<BuildTarget<?>,Set<File>>emptyMap());
+    return new CompileScopeImpl(myTargetTypes, typesToForceBuild, myTargets, myFiles);
   }
 
   public CompileScopeTestBuilder all() {