Fix: multiple compilation units in a file lead to information loss#738
Merged
antonsviridov-src merged 9 commits intomainfrom Aug 20, 2024
Merged
Fix: multiple compilation units in a file lead to information loss#738antonsviridov-src merged 9 commits intomainfrom
antonsviridov-src merged 9 commits intomainfrom
Conversation
| .enablePlugins(DocusaurusPlugin) | ||
|
|
||
| lazy val javaOnlySettings = List[Def.Setting[_]]( | ||
| javafmtOnCompile := false, |
Contributor
Author
There was a problem hiding this comment.
This was doing my head in – IntelliJ was formatting one way, running SBT session (~snapshots/run) another way, and IJ constantly producing a warning to load filesystem changes.
Formatting on compile is evil.
Contributor
There was a problem hiding this comment.
Formatting on compile is evil.
Agreed.
Comment on lines
+49
to
+51
| // Upon first encounter with a file (before any other tasks are run) | ||
| // we remove the semanticdb file for this source file to ensure | ||
| // stale data doesn't cause problems |
Contributor
Author
There was a problem hiding this comment.
Now that we read previous state, we shouldn't expect the folder to be clean – without doing so I was getting very confusing results when running snapshots.
olafurpg
approved these changes
Aug 20, 2024
| .enablePlugins(DocusaurusPlugin) | ||
|
|
||
| lazy val javaOnlySettings = List[Def.Setting[_]]( | ||
| javafmtOnCompile := false, |
Contributor
There was a problem hiding this comment.
Formatting on compile is evil.
Agreed.
semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbTaskListener.java
Outdated
Show resolved
Hide resolved
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes GRAPH-753
We discovered that javac issues multiple events per file if there are multiple top level definitions that match what javac considers to be a compilation unit - interfaces or classes for example.
These multiple invocations produce slightly different results, and all writing to the same file, meaning the information gets lost.
To fix this, we defensively read the file if it already exists and carefully deduplicate symbols/occurrences/synthetics before writing back.
Test plan