From 69699b6ce4b61087c8401db1886cde2171bff4c3 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Tue, 20 Aug 2024 10:15:00 +0100 Subject: [PATCH] Call inferBazelSourceroot defensively --- .../sourcegraph/semanticdb_javac/SemanticdbTaskListener.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbTaskListener.java b/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbTaskListener.java index 46ad5eab..02fe4164 100644 --- a/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbTaskListener.java +++ b/semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbTaskListener.java @@ -50,6 +50,7 @@ public void started(TaskEvent e) { // we remove the semanticdb file for this source file to ensure // stale data doesn't cause problems if (e.getKind() == TaskEvent.Kind.ENTER) { + inferBazelSourceroot(e.getSourceFile()); Result semanticdbPath = semanticdbOutputPath(options, e); if (semanticdbPath.isOk()) { try { @@ -283,8 +284,6 @@ private void inferBazelSourceroot(JavaFileObject file) { private Result semanticdbOutputPath(SemanticdbJavacOptions options, TaskEvent e) { Path absolutePath = absolutePathFromUri(options, e.getSourceFile()); - if (absolutePath == null) - return Result.error("Failed to produce absolute path for " + e.getSourceFile()); if (absolutePath.startsWith(options.sourceroot)) { Path relativePath = options.sourceroot.relativize(absolutePath); String filename = relativePath.getFileName().toString() + ".semanticdb";