-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
-no-relative-path:
flag to control indexing of generated files
Previously, the SemanticDB compiler plugin errored when indexing auto-generated files outside of the configured `-sourceroot` directory (which is automatically inferred for Bazel builds). This behavior was undesirable because: - There's no good workaround for the issue - The error message was cryptic making it difficult to understand what went wrong For some cases, we were able to detect this situation for Bazel and ignore the indexed file while printing an informative message, but this behavior was also undesirable because we skipping these files means that we can't render hover messages for symbols in those generated files. This PR fixes the issue by adding a configurable `-no-relative-path:` flag with the following valid options: - `index_anyways` (default): indexes the file but with no guarantee that it's possible to recover the location of the original generated file. This allows us to display accurate hover tooltips for symbols in these files even if "Go to definition" won't work. - `skip`: silently ignored these files. - `warning`: ignore these files and print a message explaining it was skipped. - `error`: fail the compilation process (old default).
- Loading branch information
Showing
5 changed files
with
117 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/NoRelativePathMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.sourcegraph.semanticdb_javac; | ||
|
||
/** | ||
* Configuration options to determine how semanticdb-javac should handle files that have no good | ||
* relative paths. | ||
* | ||
* <p>When indexing a file at an absolute path /project/src/main/example/Foo.java, SemanticDB needs | ||
* to know the "sourceroot" path /project in order to relativize the path of the source file into | ||
* src/main/example/Foo.java. This configuration option determines what the compiler plugin should | ||
* do when it's not able to find a good relative path. | ||
*/ | ||
public enum NoRelativePathMode { | ||
|
||
/** | ||
* Come up with a unique relative path for the SemanticDB path with no guarantee that this path | ||
* corresponds to the original path of the generated source file. | ||
*/ | ||
INDEX_ANYWAY, | ||
|
||
/** Silently ignore the file, don't index it. */ | ||
SKIP, | ||
|
||
/** Report an error message and fail the compilation. */ | ||
ERROR, | ||
|
||
/** Ignore the file, but print a message explaining it's ignored. */ | ||
WARNING | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters