@@ -59,9 +59,12 @@ public void finished(TaskEvent e) {
5959 try {
6060 onFinishedAnalyze (e );
6161 } catch (Throwable ex ) {
62- // Catch exceptions because we don't want to stop the compilation even if this plugin has a
63- // bug. We report the full stack trace because it's helpful for bug reports. Exceptions
64- // should only happen in *exceptional* situations and they should be reported upstream.
62+ // Catch exceptions because we don't want to stop the compilation even if this
63+ // plugin has a
64+ // bug. We report the full stack trace because it's helpful for bug reports.
65+ // Exceptions
66+ // should only happen in *exceptional* situations and they should be reported
67+ // upstream.
6568 Throwable throwable = ex ;
6669 if (e .getSourceFile () != null ) {
6770 throwable =
@@ -110,12 +113,17 @@ public static Path absolutePathFromUri(SemanticdbJavacOptions options, JavaFileO
110113 throw new IllegalArgumentException ("unsupported URI: " + uri );
111114 }
112115 } else if (options .uriScheme == UriScheme .BAZEL ) {
113- // This solution is hacky, and it would be very nice to use a dedicated API instead.
114- // The Bazel Java compiler constructs `SimpleFileObject/DirectoryFileObject` with a
115- // "user-friendly" name that points to the original source file and an underlying/actual
116- // file path in a temporary directory. We're constrained by having to use only public APIs of
117- // the Java compiler and `toString()` seems to be the only way to access the user-friendly
118116 String toString = file .toString ().replace (":" , "/" );
117+ // This solution is hacky, and it would be very nice to use a dedicated API
118+ // instead.
119+ // The Bazel Java compiler constructs `SimpleFileObject/DirectoryFileObject`
120+ // with a
121+ // "user-friendly" name that points to the original source file and an
122+ // underlying/actual
123+ // file path in a temporary directory. We're constrained by having to use only
124+ // public APIs of
125+ // the Java compiler and `toString()` seems to be the only way to access the
126+ // user-friendly
119127 // path.
120128 String [] knownBazelToStringPatterns =
121129 new String [] {"SimpleFileObject[" , "DirectoryFileObject[" };
@@ -144,11 +152,11 @@ private void inferBazelSourceroot(JavaFileObject file) {
144152 // /private/var/tmp/com/example/Hello.java
145153 //
146154 // We infer sourceroot by iterating the names of both files in reverse order
147- // and stop at the first entry where the two paths are different. For the
155+ // and stop at the first entry where the two paths are different. For the
148156 // example above, we compare "Hello.java", then "example", then "com", and
149157 // when we reach "repo" != "tmp" then we guess that "/home/repo" is the
150- // sourceroot. This logic is brittle and it would be nice to use more
151- // dedicated APIs, but Bazel actively makes an effort to sandbox
158+ // sourceroot. This logic is brittle and it would be nice to use more
159+ // dedicated APIs, but Bazel actively makes an effort to sandbox
152160 // compilation and hide access to the original workspace, which is why we
153161 // resort to solutions like this.
154162 int relativePathDepth = 0 ;
@@ -199,6 +207,7 @@ private Result<Path, String> semanticdbOutputPath(SemanticdbJavacOptions options
199207 // TODO:
200208 }
201209 }
210+
202211 return Result .error (
203212 String .format (
204213 "sourceroot '%s does not contain path '%s'. To fix this problem, update the -sourceroot flag to "
0 commit comments