8000 More debugging · Arthurm1/scip-java@8f0be2e · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f0be2e

Browse files
committed
More debugging
1 parent ab73d3b commit 8f0be2e

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BazelBuildTool.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ class BazelBuildTool(index: IndexCommand) extends BuildTool("Bazel", index) {
3232
buildCommand += "bazel"
3333
buildCommand += "build"
3434
buildCommand += "--noshow_progress"
35-
buildCommand += "--sandbox_debug"
35+
36+
// The local strategy is required for now because we write SemanticDB and SCIP files
37+
// to the provided targetroot directory.
8000 38+
buildCommand += "--spawn_strategy=local"
3639

3740
val targetSpecs = ListBuffer.empty[String]
3841
if (index.buildCommand.isEmpty) {

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/ScipBuildTool.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
424424
.iterator()
425425
if (compilers.hasNext) {
426426
val classpath = deps.classpath ++ scalaLibrary
427-
val argsfile = tmp.resolve("javacopts.txt")
427+
val argsfile = targetroot.resolve("javacopts.txt")
428428
Files.createDirectories(argsfile.getParent)
429429
Files.write(
430430
argsfile,
@@ -492,7 +492,7 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
492492
AbsolutePath.of(Paths.get(path), index.workingDirectory).toString
493493
)
494494
actualClasspath ++= deps.classpath.map(_.toString)
495-
val argsfile = tmp.resolve("javacopts.txt")
495+
val argsfile = targetroot.resolve("javacopts.txt")
496496
val arguments = ListBuffer.empty[String]
497497
arguments += "-encoding"
498498
arguments += "utf8"

semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbTaskListener.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import com.sun.tools.javac.model.JavacTypes;
88

99
import javax.tools.JavaFileObject;
10+
import java.io.ByteArrayOutputStream;
1011
import java.io.IOException;
12+
import java.io.PrintWriter;
1113
import java.net.URI;
1214
import java.nio.file.Files;
1315
import java.nio.file.Path;
@@ -71,11 +73,20 @@ public void finished(TaskEvent e) {
7173
new CompilationUnitException(
7274
String.valueOf(e.getSourceFile().toUri().toString()), throwable);
7375
}
74-
reporter.exception(throwable, e.getCompilationUnit(), e.getCompilationUnit());
76+
this.reportException(throwable, e);
7577
throw new RuntimeException(ex.getMessage(), throwable);
7678
}
7779
}
7880

81+
// Uses reporter.error with the full stack trace of the exception instead of reporter.exception
82+
// because reporter.exception doesn't seem to print any meaningful information about the
83+
// exception, it just prints the location with an empty message.
84+
private void reportException(Throwable exception, TaskEvent e) {
85+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
86+
exception.printStackTrace(new PrintWriter(baos));
87+
reporter.error(baos.toString(), e.getCompilationUnit(), e.getCompilationUnit());
88+
}
89+
7990
private void onFinishedAnalyze(TaskEvent e) {
8091
Result<Path, String> path = semanticdbOutputPath(options, e);
8192
if (path != null) {
@@ -97,7 +108,7 @@ private void writeSemanticdb(TaskEvent event, Path output, Semanticdb.TextDocume
97108
Files.createDirectories(output.getParent());
98109
Files.write(output, bytes);
99110
} catch (IOException e) {
100-
reporter.exception(e, event.getCompilationUnit(), event.getCompilationUnit());
111+
this.reportException(e, event);
101112
}
102113
}
103114

0 commit comments

Comments
 (0)
0