mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
JPS mappings for incremental compilation refactoring: support storing graph data in portable format; introduce NodeSourcePathMapper
GitOrigin-RevId: 4d2cbb59b9a52da1b33303af108a7569f02b8a6b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
af0bb596d5
commit
286f2cefe8
@@ -4,14 +4,13 @@ package org.jetbrains.jps.builders.java;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.dependency.GraphConfiguration;
|
||||
import org.jetbrains.jps.dependency.Node;
|
||||
import org.jetbrains.jps.dependency.NodeSource;
|
||||
import org.jetbrains.jps.dependency.impl.FileSource;
|
||||
import org.jetbrains.jps.dependency.java.*;
|
||||
import org.jetbrains.jps.javac.Iterators;
|
||||
import org.jetbrains.org.objectweb.asm.ClassReader;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
class BackendCallbackToGraphDeltaAdapter implements Callbacks.Backend {
|
||||
@@ -21,6 +20,12 @@ class BackendCallbackToGraphDeltaAdapter implements Callbacks.Backend {
|
||||
private final Map<String, Pair<Collection<String>, Collection<String>>> myImportRefs = Collections.synchronizedMap(new HashMap<>());
|
||||
private final Map<String, Collection<Callbacks.ConstantRef>> myConstantRefs = Collections.synchronizedMap(new HashMap<>());
|
||||
private final List<Pair<Node<?, ?>, Iterable<NodeSource>>> myNodes = new ArrayList<>();
|
||||
private final GraphConfiguration myGraphConfig;
|
||||
|
||||
BackendCallbackToGraphDeltaAdapter(GraphConfiguration graphConfig) {
|
||||
myGraphConfig = graphConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void associate(String classFileName, Collection<String> sources, ClassReader cr, boolean isGenerated) {
|
||||
JvmClassNodeBuilder builder = JvmClassNodeBuilder.create(classFileName, cr, isGenerated);
|
||||
@@ -34,7 +39,7 @@ class BackendCallbackToGraphDeltaAdapter implements Callbacks.Backend {
|
||||
|
||||
var node = builder.getResult();
|
||||
if (!node.isPrivate()) {
|
||||
myNodes.add(new Pair<>(node, Iterators.collect(Iterators.map(sources, s -> new FileSource(Path.of(s))), new SmartList<>())));
|
||||
myNodes.add(new Pair<>(node, Iterators.collect(Iterators.map(sources, myGraphConfig.getPathMapper()::toNodeSource), new SmartList<>())));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,8 @@ import org.jetbrains.jps.builders.*;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Mappings;
|
||||
import org.jetbrains.jps.builders.storage.BuildDataCorruptedException;
|
||||
import org.jetbrains.jps.dependency.Delta;
|
||||
import org.jetbrains.jps.dependency.DependencyGraph;
|
||||
import org.jetbrains.jps.dependency.DifferentiateParameters;
|
||||
import org.jetbrains.jps.dependency.DifferentiateResult;
|
||||
import org.jetbrains.jps.dependency.*;
|
||||
import org.jetbrains.jps.dependency.impl.DifferentiateParametersBuilder;
|
||||
import org.jetbrains.jps.dependency.impl.FileSource;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.fs.CompilationRound;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
@@ -47,7 +43,6 @@ import org.jetbrains.jps.service.JpsServiceManager;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
public final class JavaBuilderUtil {
|
||||
@@ -107,10 +102,11 @@ public final class JavaBuilderUtil {
|
||||
}
|
||||
|
||||
public static @NotNull Callbacks.Backend getDependenciesRegistrar(CompileContext context) {
|
||||
if (isDepGraphEnabled()) {
|
||||
GraphConfiguration graphConfig = context.getProjectDescriptor().dataManager.getDependencyGraph();
|
||||
if (isDepGraphEnabled() && graphConfig != null) {
|
||||
BackendCallbackToGraphDeltaAdapter callback = GRAPH_DELTA_CALLBACK_KEY.get(context);
|
||||
if (callback == null) {
|
||||
GRAPH_DELTA_CALLBACK_KEY.set(context, callback = new BackendCallbackToGraphDeltaAdapter());
|
||||
GRAPH_DELTA_CALLBACK_KEY.set(context, callback = new BackendCallbackToGraphDeltaAdapter(graphConfig));
|
||||
}
|
||||
return callback;
|
||||
}
|
||||
@@ -127,7 +123,9 @@ public final class JavaBuilderUtil {
|
||||
public static boolean updateMappingsOnRoundCompletion(
|
||||
CompileContext context, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, ModuleChunk chunk) throws IOException {
|
||||
|
||||
if(isDepGraphEnabled()) {
|
||||
BuildDataManager dataManager = context.getProjectDescriptor().dataManager;
|
||||
GraphConfiguration graphConfig = dataManager.getDependencyGraph();
|
||||
if(isDepGraphEnabled() && graphConfig != null) {
|
||||
Delta delta = null;
|
||||
BackendCallbackToGraphDeltaAdapter callback = GRAPH_DELTA_CALLBACK_KEY.get(context);
|
||||
|
||||
@@ -141,10 +139,10 @@ public final class JavaBuilderUtil {
|
||||
// so the next compilation might compile much more files than is actually needed.
|
||||
Iterable<File> inputFiles = Utils.errorsDetected(context)? Collections.emptyList() : Iterators.filter(getFilesContainer(context, FILES_TO_COMPILE_KEY), f -> !compiledWithErrors.contains(f));
|
||||
|
||||
DependencyGraph graph = context.getProjectDescriptor().dataManager.getDependencyGraph();
|
||||
delta = graph.createDelta(
|
||||
Iterators.map(inputFiles, f -> new FileSource(f)),
|
||||
Iterators.map(getRemovedPaths(chunk, dirtyFilesHolder), p -> new FileSource(Path.of(p)))
|
||||
NodeSourcePathMapper pathMapper = graphConfig.getPathMapper();
|
||||
delta = graphConfig.getGraph().createDelta(
|
||||
Iterators.map(inputFiles, pathMapper::toNodeSource),
|
||||
Iterators.map(getRemovedPaths(chunk, dirtyFilesHolder), pathMapper::toNodeSource)
|
||||
);
|
||||
for (var nodeData : callback.getNodes()) {
|
||||
delta.associate(nodeData.getFirst(), nodeData.getSecond());
|
||||
@@ -208,15 +206,17 @@ public final class JavaBuilderUtil {
|
||||
|
||||
public static void markDirtyDependenciesForInitialRound(CompileContext context, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dfh, ModuleChunk chunk) throws IOException {
|
||||
if (hasRemovedPaths(chunk, dfh)) {
|
||||
if (isDepGraphEnabled()) {
|
||||
Delta delta = context.getProjectDescriptor().dataManager.getDependencyGraph().createDelta(
|
||||
Collections.emptyList(),
|
||||
Iterators.map(getRemovedPaths(chunk, dfh), p -> new FileSource(Path.of(p)))
|
||||
BuildDataManager dataManager = context.getProjectDescriptor().dataManager;
|
||||
GraphConfiguration graphConfig = dataManager.getDependencyGraph();
|
||||
if (isDepGraphEnabled() && graphConfig != null) {
|
||||
NodeSourcePathMapper mapper = graphConfig.getPathMapper();
|
||||
Delta delta = graphConfig.getGraph().createDelta(
|
||||
Collections.emptyList(), Iterators.map(getRemovedPaths(chunk, dfh), mapper::toNodeSource)
|
||||
);
|
||||
updateDependencyGraph(context, delta, chunk, CompilationRound.CURRENT, null);
|
||||
return;
|
||||
}
|
||||
final Mappings delta = context.getProjectDescriptor().dataManager.getMappings().createDelta();
|
||||
final Mappings delta = dataManager.getMappings().createDelta();
|
||||
final Set<File> empty = Collections.emptySet();
|
||||
updateMappings(context, delta, dfh, chunk, empty, empty, CompilationRound.CURRENT, null);
|
||||
}
|
||||
@@ -420,21 +420,24 @@ public final class JavaBuilderUtil {
|
||||
boolean additionalPassRequired = false;
|
||||
final boolean errorsDetected = Utils.errorsDetected(context);
|
||||
BuildDataManager dataManager = context.getProjectDescriptor().dataManager;
|
||||
DependencyGraph graph = dataManager.getDependencyGraph();
|
||||
GraphConfiguration graphConfig = Objects.requireNonNull(dataManager.getDependencyGraph());
|
||||
DependencyGraph dependencyGraph = graphConfig.getGraph();
|
||||
NodeSourcePathMapper pathMapper = graphConfig.getPathMapper();
|
||||
|
||||
final ModulesBasedFileFilter moduleBasedFilter = new ModulesBasedFileFilter(context, chunk);
|
||||
DifferentiateParametersBuilder params = DifferentiateParametersBuilder.create(chunk.getPresentableShortName())
|
||||
.calculateAffected(context.shouldDifferentiate(chunk) && !isForcedRecompilationAllJavaModules(context))
|
||||
.processConstantsIncrementally(dataManager.isProcessConstantsIncrementally())
|
||||
.withAffectionFilter(s -> moduleBasedFilter.accept(s.getPath().toFile()))
|
||||
.withChunkStructureFilter(s -> moduleBasedFilter.belongsToCurrentTargetChunk(s.getPath().toFile()));
|
||||
.withAffectionFilter(s -> moduleBasedFilter.accept(pathMapper.toPath(s).toFile()))
|
||||
.withChunkStructureFilter(s -> moduleBasedFilter.belongsToCurrentTargetChunk(pathMapper.toPath(s).toFile()));
|
||||
DifferentiateParameters differentiateParams = params.get();
|
||||
DifferentiateResult diffResult = graph.differentiate(delta, differentiateParams);
|
||||
DifferentiateResult diffResult = dependencyGraph.differentiate(delta, differentiateParams);
|
||||
|
||||
final boolean compilingIncrementally = isCompileJavaIncrementally(context);
|
||||
|
||||
if (diffResult.isIncremental()) {
|
||||
final Set<File> affectedFiles = Iterators.collect(
|
||||
Iterators.filter(Iterators.map(diffResult.getAffectedSources(), src -> src.getPath().toFile()), f -> skipMarkDirtyFilter == null || !skipMarkDirtyFilter.accept(f)),
|
||||
Iterators.filter(Iterators.map(diffResult.getAffectedSources(), src -> pathMapper.toPath(src).toFile()), f -> skipMarkDirtyFilter == null || !skipMarkDirtyFilter.accept(f)),
|
||||
new HashSet<>()
|
||||
);
|
||||
|
||||
@@ -527,7 +530,7 @@ public final class JavaBuilderUtil {
|
||||
}
|
||||
|
||||
if (performIntegrate) {
|
||||
graph.integrate(diffResult);
|
||||
dependencyGraph.integrate(diffResult);
|
||||
}
|
||||
|
||||
return additionalPassRequired;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.jps.dependency;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface GraphConfiguration {
|
||||
|
||||
@NotNull
|
||||
NodeSourcePathMapper getPathMapper();
|
||||
|
||||
@NotNull
|
||||
DependencyGraph getGraph();
|
||||
}
|
||||
@@ -1,16 +1,15 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.jps.dependency;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* Represents a source (normally a text file) from which one or more nodes were produced.
|
||||
* One source can be associated with several Nodes and a Node can be produced basing on several sources
|
||||
*/
|
||||
public interface NodeSource extends ExternalizableGraphElement {
|
||||
Path getPath();
|
||||
|
||||
boolean equals(Object other);
|
||||
|
||||
int hashCode();
|
||||
|
||||
String toString();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.jps.dependency;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface NodeSourcePathMapper {
|
||||
|
||||
NodeSource toNodeSource(File file);
|
||||
|
||||
NodeSource toNodeSource(Path path);
|
||||
|
||||
NodeSource toNodeSource(String path);
|
||||
|
||||
Path toPath(NodeSource nodeSource);
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.jps.dependency.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.dependency.GraphDataInput;
|
||||
import org.jetbrains.jps.dependency.GraphDataOutput;
|
||||
import org.jetbrains.jps.dependency.NodeSource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class FileSource implements NodeSource {
|
||||
|
||||
private final Path myPath;
|
||||
|
||||
public FileSource(@NotNull File file) {
|
||||
this(file.toPath());
|
||||
}
|
||||
|
||||
public FileSource(@NotNull Path path) {
|
||||
myPath = path;
|
||||
}
|
||||
|
||||
public FileSource(@NotNull GraphDataInput in) throws IOException {
|
||||
myPath = Path.of(in.readUTF());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(GraphDataOutput out) throws IOException {
|
||||
out.writeUTF(myPath.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getPath() {
|
||||
return myPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final FileSource that = (FileSource)o;
|
||||
|
||||
if (!myPath.equals(that.myPath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return myPath.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NodeSource {" + myPath + "}";
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ abstract class GraphImpl implements Graph {
|
||||
addIndex(myDependencyIndex = new NodeDependenciesIndex(cFactory));
|
||||
|
||||
// important: if multiple implementations of NodeSource are available, change to generic graph element externalizer
|
||||
Externalizer<NodeSource> srcExternalizer = Externalizer.forGraphElement(FileSource::new);
|
||||
Externalizer<NodeSource> srcExternalizer = Externalizer.forGraphElement(PathSource::new);
|
||||
myNodeToSourcesMap = cFactory.createSetMultiMaplet("node-sources-map", Externalizer.forGraphElement(JvmNodeReferenceID::new), srcExternalizer);
|
||||
mySourceToNodesMap = cFactory.createSetMultiMaplet("source-nodes-map", srcExternalizer, Externalizer.forAnyGraphElement());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.jps.dependency.impl;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfoRt;
|
||||
import com.intellij.openapi.util.text.StringUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.dependency.GraphDataInput;
|
||||
import org.jetbrains.jps.dependency.GraphDataOutput;
|
||||
import org.jetbrains.jps.dependency.NodeSource;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class PathSource implements NodeSource {
|
||||
|
||||
@NotNull
|
||||
private final String myPath;
|
||||
|
||||
public PathSource(@NotNull String path) {
|
||||
myPath = File.separatorChar != '/'? path.replace(File.separatorChar, '/') : path;
|
||||
}
|
||||
|
||||
public PathSource(@NotNull GraphDataInput in) throws IOException {
|
||||
myPath = in.readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(GraphDataOutput out) throws IOException {
|
||||
out.writeUTF(myPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final PathSource that = (PathSource)o;
|
||||
|
||||
//noinspection StringEquality,SSBasedInspection
|
||||
if (myPath == that.myPath) {
|
||||
return true;
|
||||
}
|
||||
return SystemInfoRt.isFileSystemCaseSensitive? myPath.equals(that.myPath) : myPath.equalsIgnoreCase(that.myPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (myPath.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return SystemInfoRt.isFileSystemCaseSensitive? myPath.hashCode() : StringUtilRt.stringHashCodeInsensitive(myPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myPath;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.jps.dependency.impl;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.dependency.NodeSource;
|
||||
import org.jetbrains.jps.dependency.NodeSourcePathMapper;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PathSourceMapper implements NodeSourcePathMapper {
|
||||
@NotNull
|
||||
private final Function<String, String> toFull;
|
||||
@NotNull
|
||||
private final Function<String, String> toRelative;
|
||||
|
||||
public PathSourceMapper() {
|
||||
this(Function.identity(), Function.identity());
|
||||
}
|
||||
|
||||
public PathSourceMapper(@NotNull Function<String, String> toFull, @NotNull Function<String, String> toRelative) {
|
||||
this.toFull = toFull;
|
||||
this.toRelative = toRelative;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeSource toNodeSource(File file) {
|
||||
return toNodeSource(FileUtilRt.toCanonicalPath(file.getAbsolutePath(), File.separatorChar, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeSource toNodeSource(Path path) {
|
||||
return toNodeSource(FileUtilRt.toCanonicalPath(path.toString(), File.separatorChar, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeSource toNodeSource(String path) {
|
||||
return new PathSource(toRelative.apply(path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path toPath(NodeSource nodeSource) {
|
||||
return Path.of(toFull.apply(nodeSource.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class JavaDifferentiateStrategy extends JvmDifferentiateStrategyImpl {
|
||||
msg.append("Possibly duplicated classes in the same compilation chunk; Scheduling for recompilation sources: ");
|
||||
for (NodeSource candidate : candidates) {
|
||||
context.affectNodeSource(candidate);
|
||||
msg.append(candidate.getPath()).append("; ");
|
||||
msg.append(candidate).append("; ");
|
||||
}
|
||||
debug(msg.toString());
|
||||
continue; // if duplicates are found, do not perform further checks for classes with the same short name
|
||||
@@ -630,7 +630,7 @@ public class JavaDifferentiateStrategy extends JvmDifferentiateStrategyImpl {
|
||||
}))) {
|
||||
if (future.isMethodVisible(outerClass, addedMethod) || future.inheritsFromLibraryClass(outerClass)) {
|
||||
for (NodeSource source : filter(sources, context.getParams().affectionFilter()::test)) {
|
||||
debug("Affecting file due to local overriding: ", source.getPath());
|
||||
debug("Affecting file due to local overriding: ", source);
|
||||
context.affectNodeSource(source);
|
||||
}
|
||||
}
|
||||
@@ -972,7 +972,7 @@ public class JavaDifferentiateStrategy extends JvmDifferentiateStrategyImpl {
|
||||
for (NodeSource source : filter(context.getGraph().getSources(clsId), affectionFilter::test)) {
|
||||
if (forceAffect || !context.isCompiled(source) && !deletedSources.contains(source)) {
|
||||
context.affectNodeSource(source);
|
||||
debug(affectReason, source.getPath());
|
||||
debug(affectReason, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -981,7 +981,7 @@ public class JavaDifferentiateStrategy extends JvmDifferentiateStrategyImpl {
|
||||
debug("Affecting module ", mod.getName());
|
||||
for (NodeSource source : utils.getNodeSources(mod.getReferenceID())) {
|
||||
context.affectNodeSource(source);
|
||||
debug("Affected source ", source.getPath());
|
||||
debug("Affected source ", source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.jps.dependency.*;
|
||||
import org.jetbrains.jps.dependency.impl.Containers;
|
||||
import org.jetbrains.jps.dependency.impl.DependencyGraphImpl;
|
||||
import org.jetbrains.jps.dependency.impl.LoggingDependencyGraph;
|
||||
import org.jetbrains.jps.dependency.impl.PathSourceMapper;
|
||||
import org.jetbrains.jps.incremental.IncProjectBuilder;
|
||||
import org.jetbrains.jps.incremental.relativizer.PathRelativizerService;
|
||||
|
||||
@@ -53,6 +54,7 @@ public final class BuildDataManager {
|
||||
private final Mappings myMappings;
|
||||
private final Object myGraphManagementLock = new Object();
|
||||
private DependencyGraph myDepGraph;
|
||||
private final NodeSourcePathMapper myDepGraphPathMapper;
|
||||
private final BuildDataPaths myDataPaths;
|
||||
private final BuildTargetsState myTargetsState;
|
||||
private final OutputToTargetRegistry myOutputToTargetRegistry;
|
||||
@@ -92,6 +94,7 @@ public final class BuildDataManager {
|
||||
myMappings.setProcessConstantsIncrementally(isProcessConstantsIncrementally());
|
||||
}
|
||||
myVersionFile = new File(myDataPaths.getDataStorageRoot(), "version.dat");
|
||||
myDepGraphPathMapper = relativizer != null? new PathSourceMapper(relativizer::toFull, relativizer::toRelative) : new PathSourceMapper();
|
||||
myRelativizer = relativizer;
|
||||
}
|
||||
|
||||
@@ -137,9 +140,21 @@ public final class BuildDataManager {
|
||||
return myMappings;
|
||||
}
|
||||
|
||||
public DependencyGraph getDependencyGraph() {
|
||||
@Nullable
|
||||
public GraphConfiguration getDependencyGraph() {
|
||||
synchronized (myGraphManagementLock) {
|
||||
return myDepGraph;
|
||||
DependencyGraph depGraph = myDepGraph;
|
||||
return depGraph == null? null : new GraphConfiguration() {
|
||||
@Override
|
||||
public @NotNull NodeSourcePathMapper getPathMapper() {
|
||||
return myDepGraphPathMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull DependencyGraph getGraph() {
|
||||
return depGraph;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.jetbrains.jps.ModuleChunk
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Mappings
|
||||
import org.jetbrains.jps.builders.storage.StorageProvider
|
||||
import org.jetbrains.jps.dependency.DependencyGraph
|
||||
import org.jetbrains.jps.dependency.GraphConfiguration
|
||||
import org.jetbrains.jps.dependency.java.JvmNodeReferenceID
|
||||
import org.jetbrains.jps.incremental.BuilderCategory
|
||||
import org.jetbrains.jps.incremental.CompileContext
|
||||
@@ -67,9 +67,12 @@ class MockPackageFacadeGenerator : ModuleLevelBuilder(BuilderCategory.SOURCE_PRO
|
||||
mappings.getClassSources(mappings.getName(qName))
|
||||
}
|
||||
else {
|
||||
val graph: DependencyGraph = context.projectDescriptor.dataManager.dependencyGraph
|
||||
val files = mutableListOf<File>()
|
||||
graph.getSources(JvmNodeReferenceID(qName)).forEach { files.add(it.path.toFile()) }
|
||||
val graphConfig: GraphConfiguration? = context.projectDescriptor.dataManager.dependencyGraph
|
||||
if (graphConfig != null) {
|
||||
val mapper = graphConfig.pathMapper
|
||||
graphConfig.graph.getSources(JvmNodeReferenceID(qName)).forEach { files.add(mapper.toPath(it).toFile()) }
|
||||
}
|
||||
files
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.jetbrains.jps.dependency.diff.DiffCapable;
|
||||
import org.jetbrains.jps.dependency.impl.Containers;
|
||||
import org.jetbrains.jps.dependency.impl.DependencyGraphImpl;
|
||||
import org.jetbrains.jps.dependency.impl.DifferentiateParametersBuilder;
|
||||
import org.jetbrains.jps.dependency.impl.FileSource;
|
||||
import org.jetbrains.jps.dependency.impl.PathSource;
|
||||
import org.jetbrains.jps.dependency.java.JVMFlags;
|
||||
import org.jetbrains.jps.dependency.java.JvmClass;
|
||||
import org.jetbrains.jps.dependency.serializer.JvmClassTestUtil;
|
||||
@@ -21,10 +21,9 @@ public class NodeGraphPersistentTest extends BasePlatformTestCase {
|
||||
public void testPersistentNodeGraph() throws IOException {
|
||||
// Create and fill out the graph
|
||||
File tempDirectory = FileUtil.createTempDirectory("persistent", "map");
|
||||
DependencyGraphImpl graph = new DependencyGraphImpl(Containers.createPersistentContainerFactory(tempDirectory.getAbsolutePath()));
|
||||
try {
|
||||
FileSource aSrc = createNodeSource("A");
|
||||
FileSource bSrc = createNodeSource("B");
|
||||
try (DependencyGraphImpl graph = new DependencyGraphImpl(Containers.createPersistentContainerFactory(tempDirectory.getAbsolutePath()))) {
|
||||
NodeSource aSrc = createNodeSource("A");
|
||||
NodeSource bSrc = createNodeSource("B");
|
||||
|
||||
// This should be executed before compiler run
|
||||
Delta delta = graph.createDelta(Arrays.asList(aSrc, bSrc), null);
|
||||
@@ -44,11 +43,10 @@ public class NodeGraphPersistentTest extends BasePlatformTestCase {
|
||||
JvmClass jvmClassFromGraph = graph.getNodes(nodeSourcesFromGraph.get(0), JvmClass.class).iterator().next();
|
||||
JvmClass jvmClassFromGraphByDifferentSource = graph.getNodes(nodeSourcesFromGraph.get(1), JvmClass.class).iterator().next();
|
||||
JvmClassTestUtil.checkJvmClassEquals(jvmClassFromGraph, jvmClassFromGraphByDifferentSource);
|
||||
|
||||
|
||||
JvmClassTestUtil.checkJvmClassEquals(jvmClassNode, jvmClassFromGraph);
|
||||
}
|
||||
finally {
|
||||
graph.close();
|
||||
FileUtil.delete(tempDirectory);
|
||||
}
|
||||
}
|
||||
@@ -56,10 +54,9 @@ public class NodeGraphPersistentTest extends BasePlatformTestCase {
|
||||
public void testIntegrateNodesWithSameID() throws IOException {
|
||||
// Create and fill out the graph
|
||||
File tempDirectory = FileUtil.createTempDirectory("persistent", "map");
|
||||
DependencyGraphImpl graph = new DependencyGraphImpl(Containers.createPersistentContainerFactory(tempDirectory.getAbsolutePath()));
|
||||
try {
|
||||
FileSource aSrc = createNodeSource("A");
|
||||
FileSource bSrc = createNodeSource("B");
|
||||
try (DependencyGraphImpl graph = new DependencyGraphImpl(Containers.createPersistentContainerFactory(tempDirectory.getAbsolutePath()))) {
|
||||
NodeSource aSrc = createNodeSource("A");
|
||||
NodeSource bSrc = createNodeSource("B");
|
||||
|
||||
Delta initialDelta = graph.createDelta(Arrays.asList(aSrc, bSrc), null);
|
||||
JvmClass clsNodeA = new JvmClass(JVMFlags.EMPTY, "", "com.ppp.aClass", "out/modA/cls", "", "", Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), null, Collections.emptyList());
|
||||
@@ -101,12 +98,11 @@ public class NodeGraphPersistentTest extends BasePlatformTestCase {
|
||||
assertTrue(nodesFromGraphAfterChange.contains(clsNodeB));
|
||||
}
|
||||
finally {
|
||||
graph.close();
|
||||
FileUtil.delete(tempDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
private static FileSource createNodeSource(String fileName) {
|
||||
return new FileSource(new File("src/" + fileName + ".java"));
|
||||
private static NodeSource createNodeSource(String fileName) {
|
||||
return new PathSource("src/" + fileName + ".java");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user