mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
better deps order for kotlin compiler; fix IC- data collection for kotlin
GitOrigin-RevId: 8481762f19582dab91129a53adca5445a1f148ca
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1be0518179
commit
71da5a1955
@@ -20,8 +20,6 @@ kt_jvm_library(
|
||||
"//dependency-graph",
|
||||
"//jps-builders-6:build-javac-rt",
|
||||
"//:jps-javac-extension",
|
||||
"//src/worker-framework",
|
||||
"//src/worker-util",
|
||||
"//:annotations",
|
||||
"//:h2-mvstore",
|
||||
"//:hash4j",
|
||||
@@ -30,10 +28,12 @@ kt_jvm_library(
|
||||
"//:caffeine",
|
||||
"//:intellij-deps-fastutil",
|
||||
"//:qdox",
|
||||
"//:jps", # temporary dep for instrumentation-util and instrumenters, must be the last dep in classpath
|
||||
"//src/worker-framework",
|
||||
"//src/worker-util",
|
||||
"patched-kotlin-compiler-for-bazel",
|
||||
"//:kotlin-compose-compiler-plugin",
|
||||
"//:kotlin-serialization-compiler-plugin",
|
||||
"//:jps", # temporary dep for instrumentation-util and instrumenters, must be the last dep in classpath
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
+20
-19
@@ -161,7 +161,9 @@ public class BazelIncBuilder {
|
||||
if (!diagnostic.hasErrors()) {
|
||||
if (!srcSnapshotDelta.isRecompileAll()) {
|
||||
// delete outputs corresponding to deleted or recompiled sources
|
||||
cleanOutputsForCompiledFiles(context, srcSnapshotDelta, storageManager.getGraph(), roundCompilers, outSink);
|
||||
for (CompilerRunner compiler : roundCompilers) {
|
||||
cleanOutputsForCompiledFiles(context, srcSnapshotDelta, storageManager.getGraph(), compiler, outSink);
|
||||
}
|
||||
}
|
||||
|
||||
for (CompilerRunner runner : roundCompilers) {
|
||||
@@ -256,38 +258,37 @@ public class BazelIncBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void cleanOutputsForCompiledFiles(BuildContext context, NodeSourceSnapshotDelta snapshotDelta, DependencyGraph depGraph, List<CompilerRunner> roundCompilers, OutputSink outSink) {
|
||||
private static void cleanOutputsForCompiledFiles(BuildContext context, NodeSourceSnapshotDelta snapshotDelta, DependencyGraph depGraph, CompilerRunner compiler, OutputSink outSink) {
|
||||
// separately logging deleted outputs for 'deleted' and 'modified' sources to adjust for existing test data
|
||||
Iterable<@NotNull NodeSource> deleted = snapshotDelta.getDeleted();
|
||||
if (!isEmpty(deleted)) {
|
||||
logDeletedPaths(
|
||||
context,
|
||||
deleteCompilerOutputs(depGraph, deleted, outSink, new ArrayList<>())
|
||||
);
|
||||
}
|
||||
Collection<String> cleanedOutputsOfDeletedSources = deleteCompilerOutputs(
|
||||
depGraph, filter(snapshotDelta.getDeleted(), compiler::canCompile), outSink, new ArrayList<>()
|
||||
);
|
||||
logDeletedPaths(context, cleanedOutputsOfDeletedSources);
|
||||
|
||||
Iterable<@NotNull NodeSource> modified = snapshotDelta.getModified();
|
||||
if (!isEmpty(modified)) {
|
||||
Collection<String> cleaned = deleteCompilerOutputs(depGraph, modified, outSink, new ArrayList<>());
|
||||
for (String toDelete : flat(map(roundCompilers, CompilerRunner::getPathsToDelete))) {
|
||||
Collection<String> cleanedOutputsOfModifiedSources = deleteCompilerOutputs(
|
||||
depGraph, filter(snapshotDelta.getModified(), compiler::canCompile), outSink, new ArrayList<>()
|
||||
);
|
||||
if (!cleanedOutputsOfDeletedSources.isEmpty() || !cleanedOutputsOfModifiedSources.isEmpty()) {
|
||||
// delete additional paths only if there are any changes in the output caused by changes in sources
|
||||
for (String toDelete : compiler.getOutputPathsToDelete()) {
|
||||
if (outSink.deletePath(toDelete)) {
|
||||
cleaned.add(toDelete);
|
||||
cleanedOutputsOfModifiedSources.add(toDelete);
|
||||
}
|
||||
}
|
||||
logDeletedPaths(context, cleaned);
|
||||
}
|
||||
logDeletedPaths(context, cleanedOutputsOfModifiedSources);
|
||||
}
|
||||
|
||||
private static Collection<String> deleteCompilerOutputs(
|
||||
DependencyGraph depGraph, Iterable<@NotNull NodeSource> sourceGroup, OutputSink outSink, Collection<String> deletedPaths
|
||||
DependencyGraph depGraph, Iterable<@NotNull NodeSource> sourcesToCompile, OutputSink outSink, Collection<String> deletedPathsAcc
|
||||
) {
|
||||
for (Node<?, ?> node : filter(flat(map(sourceGroup, depGraph::getNodes)), n -> n instanceof JVMClassNode)) {
|
||||
for (Node<?, ?> node : filter(flat(map(sourcesToCompile, depGraph::getNodes)), n -> n instanceof JVMClassNode)) {
|
||||
String outputPath = ((JVMClassNode<?, ?>) node).getOutFilePath();
|
||||
if (outSink.deletePath(outputPath)) {
|
||||
deletedPaths.add(outputPath);
|
||||
deletedPathsAcc.add(outputPath);
|
||||
}
|
||||
}
|
||||
return deletedPaths;
|
||||
return deletedPathsAcc;
|
||||
}
|
||||
|
||||
private static void logDeletedPaths(BuildContext context, Iterable<String> deletedPaths) {
|
||||
|
||||
+3
@@ -142,6 +142,9 @@ public class BuildContextImpl implements BuildContext {
|
||||
private static @NotNull List<String> buildJavaOptions(Map<CLFlags, List<String>> flags) {
|
||||
// for now, only options available in the flags map can be specified in the build configuration
|
||||
List<String> options = new ArrayList<>();
|
||||
options.add("-encoding"); // todo: for now hardcoded
|
||||
options.add("UTF-8");
|
||||
|
||||
String jvmTarget = CLFlags.JVM_TARGET.getOptionalScalarValue(flags);
|
||||
if (jvmTarget != null) {
|
||||
options.add("-source");
|
||||
|
||||
+5
-8
@@ -18,11 +18,8 @@ import org.jetbrains.jps.javac.ast.api.JavacFileData;
|
||||
import org.jetbrains.jps.javac.ast.api.JavacRef;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.JavaFileManager;
|
||||
import javax.tools.JavaFileObject;
|
||||
import javax.tools.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jps.util.Iterators.*;
|
||||
@@ -249,16 +246,16 @@ public class JavaCompilerRunner implements CompilerRunner {
|
||||
if (diagnostic.getPosition() != Diagnostic.NOPOS) {
|
||||
msgBuilder.append(" (").append(diagnostic.getLineNumber()).append(":").append(diagnostic.getColumnNumber()).append(")");
|
||||
try {
|
||||
int start = (int) diagnostic.getStartPosition();
|
||||
int end = (int) diagnostic.getEndPosition();
|
||||
if (end > start) {
|
||||
int start = (int)(diagnostic.getStartPosition());
|
||||
int end = (int)(diagnostic.getEndPosition());
|
||||
if (start >= 0 && end > start) {
|
||||
CharSequence charContent = source.getCharContent(true);
|
||||
if (end < charContent.length()) {
|
||||
msgBuilder.append("\ncode: \"").append(charContent.subSequence(start, end)).append("\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-4
@@ -107,7 +107,7 @@ public class KotlinCompilerRunner implements CompilerRunner {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> getPathsToDelete() {
|
||||
public Iterable<String> getOutputPathsToDelete() {
|
||||
return myModuleEntryPath != null? List.of(myModuleEntryPath) : List.of();
|
||||
}
|
||||
|
||||
@@ -121,9 +121,15 @@ public class KotlinCompilerRunner implements CompilerRunner {
|
||||
// todo: make sure if we really need to process generated outputs after the compilation and not "in place"
|
||||
List<GeneratedClass> generatedClasses = new ArrayList<>();
|
||||
AbstractCliPipeline<K2JVMCompilerArguments> pipeline = createPipeline(out, generatedFile -> {
|
||||
if (generatedFile instanceof GeneratedJvmClass jvmClass) {
|
||||
String jvmClassName = jvmClass.getOutputClass().getClassName().getInternalName();
|
||||
for (File sourceFile : jvmClass.getSourceFiles()) {
|
||||
String jvmClassName = null;
|
||||
if (generatedFile instanceof KotlinJvmGeneratedFile jvmClass) {
|
||||
jvmClassName = jvmClass.getOutputClass().getClassName().getInternalName();
|
||||
}
|
||||
else if (generatedFile instanceof GeneratedJvmClass jvmClass) {
|
||||
jvmClassName = jvmClass.getOutputClass().getClassName().getInternalName();
|
||||
}
|
||||
if (jvmClassName != null) {
|
||||
for (File sourceFile : generatedFile.getSourceFiles()) {
|
||||
generatedClasses.add(new GeneratedClass(jvmClassName, sourceFile));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ public interface CompilerRunner extends Runner{
|
||||
|
||||
ExitCode compile(Iterable<NodeSource> sources, Iterable<NodeSource> deletedSources, DiagnosticSink diagnostic, OutputSink out);
|
||||
|
||||
default Iterable<String> getPathsToDelete() {
|
||||
default Iterable<String> getOutputPathsToDelete() {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user