mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-CR-55081 review follow-up: create more precise compilation scope when particular files are recompiled (IDEA-226671)
GitOrigin-RevId: 2c0d4a694fa1a98d1718d038feedf813b4e6c445
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5dcfe99b83
commit
4a701ead67
@@ -30,6 +30,7 @@ import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.incremental.artifacts.ArtifactBuildTargetType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -70,22 +71,39 @@ public class CompileScopeUtil {
|
||||
}
|
||||
|
||||
public static void addScopesForSourceSets(Collection<? extends ModuleSourceSet> sets, Collection<String> unloadedModules, List<? super TargetTypeBuildScope> scopes, boolean forceBuild) {
|
||||
if (!sets.isEmpty() || !unloadedModules.isEmpty()) {
|
||||
for (ModuleSourceSet set : sets) {
|
||||
final BuildTargetType targetType = toTargetType(set);
|
||||
assert targetType != null;
|
||||
|
||||
TargetTypeBuildScope.Builder builder = TargetTypeBuildScope.newBuilder().setTypeId(targetType.getTypeId()).setForceBuild(forceBuild);
|
||||
builder.addTargetId(set.getModule().getName());
|
||||
for (String unloadedModule : unloadedModules) {
|
||||
builder.addTargetId(unloadedModule);
|
||||
}
|
||||
scopes.add(builder.build());
|
||||
if (sets.isEmpty() && unloadedModules.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final Map<BuildTargetType<?>, Set<String>> targetsByType = new HashMap<>();
|
||||
final Function<BuildTargetType<?>, Set<String>> idsOf = targetType -> {
|
||||
Set<String> ids = targetsByType.get(targetType);
|
||||
if (ids == null) {
|
||||
ids = new HashSet<>();
|
||||
targetsByType.put(targetType, ids);
|
||||
}
|
||||
return ids;
|
||||
};
|
||||
for (ModuleSourceSet set : sets) {
|
||||
final BuildTargetType<?> targetType = toTargetType(set);
|
||||
assert targetType != null;
|
||||
idsOf.apply(targetType).add(set.getModule().getName());
|
||||
}
|
||||
if (!unloadedModules.isEmpty()) {
|
||||
for (JavaModuleBuildTargetType targetType : JavaModuleBuildTargetType.ALL_TYPES) {
|
||||
idsOf.apply(targetType).addAll(unloadedModules);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<BuildTargetType<?>, Set<String>> entry : targetsByType.entrySet()) {
|
||||
TargetTypeBuildScope.Builder builder = TargetTypeBuildScope.newBuilder().setTypeId(entry.getKey().getTypeId()).setForceBuild(forceBuild);
|
||||
for (String targetId : entry.getValue()) {
|
||||
builder.addTargetId(targetId);
|
||||
}
|
||||
scopes.add(builder.build());
|
||||
}
|
||||
}
|
||||
|
||||
private static BuildTargetType toTargetType(ModuleSourceSet set) {
|
||||
private static BuildTargetType<?> toTargetType(ModuleSourceSet set) {
|
||||
switch (set.getType()) {
|
||||
case TEST: return JavaModuleBuildTargetType.TEST;
|
||||
case PRODUCTION: return JavaModuleBuildTargetType.PRODUCTION;
|
||||
|
||||
Reference in New Issue
Block a user