mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
JPS mappings for incremental compilation refactoring: introduce special 'File' nodes for sources without any classes
GitOrigin-RevId: 22c8e037790b872011d01d762dd2be0d6f9e635a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3a5936d5b7
commit
adc56a59ea
+9
-4
@@ -4,10 +4,7 @@ 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.Usage;
|
||||
import org.jetbrains.jps.dependency.*;
|
||||
import org.jetbrains.jps.dependency.java.*;
|
||||
import org.jetbrains.jps.javac.Iterators;
|
||||
import org.jetbrains.org.objectweb.asm.ClassReader;
|
||||
@@ -58,6 +55,14 @@ final class BackendCallbackToGraphDeltaAdapter implements Callbacks.Backend {
|
||||
|
||||
public List<Pair<Node<?, ?>, Iterable<NodeSource>>> getNodes() {
|
||||
try {
|
||||
NodeSourcePathMapper pathMapper = myGraphConfig.getPathMapper();
|
||||
for (NodeSource source : Iterators.flat(Iterators.map(myNodes, p -> p.getSecond()))) {
|
||||
myPerSourceAdditionalUsages.remove(pathMapper.toPath(source));
|
||||
}
|
||||
for (Map.Entry<Path, Set<Usage>> entry : myPerSourceAdditionalUsages.entrySet()) {
|
||||
NodeSource src = pathMapper.toNodeSource(entry.getKey());
|
||||
myNodes.add(new Pair<>(new FileNode(src.toString(), entry.getValue()), List.of(src)));
|
||||
}
|
||||
return myNodes;
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.jps.dependency.java;
|
||||
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.dependency.GraphDataInput;
|
||||
import org.jetbrains.jps.dependency.GraphDataOutput;
|
||||
import org.jetbrains.jps.dependency.Node;
|
||||
import org.jetbrains.jps.dependency.Usage;
|
||||
import org.jetbrains.jps.dependency.diff.DiffCapable;
|
||||
import org.jetbrains.jps.dependency.diff.Difference;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class FileNode implements Node<FileNode, FileNode.Diff> {
|
||||
private final JvmNodeReferenceID myId;
|
||||
private final Iterable<Usage> myUsages;
|
||||
|
||||
public FileNode(String name, @NotNull Iterable<Usage> usages) {
|
||||
myId = new JvmNodeReferenceID(name);
|
||||
myUsages = usages;
|
||||
}
|
||||
|
||||
public FileNode(GraphDataInput in) throws IOException {
|
||||
myId = new JvmNodeReferenceID(in);
|
||||
|
||||
List<Usage> usages = new SmartList<>();
|
||||
try {
|
||||
int groupCount = in.readInt();
|
||||
while(groupCount-- > 0) {
|
||||
in.readGraphElementCollection(usages);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
myUsages = usages;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(GraphDataOutput out) throws IOException {
|
||||
myId.write(out);
|
||||
|
||||
Map<Class<? extends Usage>, List<Usage>> usageGroups = new HashMap<>();
|
||||
for (Usage usage : myUsages) {
|
||||
usageGroups.computeIfAbsent(usage.getClass(), k -> new SmartList<>()).add(usage);
|
||||
}
|
||||
|
||||
out.writeInt(usageGroups.size());
|
||||
for (Map.Entry<Class<? extends Usage>, List<Usage>> entry : usageGroups.entrySet()) {
|
||||
out.writeGraphElementCollection(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull JvmNodeReferenceID getReferenceID() {
|
||||
return myId;
|
||||
}
|
||||
|
||||
public @NotNull String getName() {
|
||||
return myId.getNodeName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Usage> getUsages() {
|
||||
return myUsages;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSame(DiffCapable<?, ?> other) {
|
||||
if (!(other instanceof FileNode)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FileNode that = (FileNode)other;
|
||||
return myId.equals(that.myId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int diffHashCode() {
|
||||
return myId.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Diff difference(FileNode past) {
|
||||
return new Diff(past);
|
||||
}
|
||||
|
||||
public class Diff implements Difference {
|
||||
private final Supplier<Specifier<Usage, ?>> myUsagesDiff;
|
||||
|
||||
public Diff(FileNode past) {
|
||||
myUsagesDiff = Utils.lazyValue(() -> Difference.diff(past.getUsages(), getUsages()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unchanged() {
|
||||
return usages().unchanged();
|
||||
}
|
||||
|
||||
public Specifier<Usage, ?> usages() {
|
||||
return myUsagesDiff.get();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -67,6 +67,7 @@ Cleaning output files:
|
||||
End of files
|
||||
Compiling files:
|
||||
src/classLiteral.kt
|
||||
src/importA.kt
|
||||
End of files
|
||||
Exit code: OK
|
||||
------------------------------------------
|
||||
+2
@@ -53,6 +53,8 @@ Compiling files:
|
||||
src/classLiteral.kt
|
||||
src/functionParameter.kt
|
||||
src/getA.kt
|
||||
src/importA.kt
|
||||
src/importAGrandChild.kt
|
||||
src/importStar.kt
|
||||
src/referencedByFqName.kt
|
||||
src/returnType.kt
|
||||
|
||||
Reference in New Issue
Block a user