Skip to content

Conversation

@antonsviridov-src
Copy link
Contributor

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

  • New snapshot results

@antonsviridov-src antonsviridov-src changed the title Go to interface definition Fix: multiple compilation units in a file lead to information loss Aug 20, 2024
.enablePlugins(DocusaurusPlugin)

lazy val javaOnlySettings = List[Def.Setting[_]](
javafmtOnCompile := false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻 Very nice fix!

.enablePlugins(DocusaurusPlugin)

lazy val javaOnlySettings = List[Def.Setting[_]](
javafmtOnCompile := false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting on compile is evil.

Agreed.

@antonsviridov-src antonsviridov-src merged commit 2298a95 into main Aug 20, 2024
@antonsviridov-src antonsviridov-src deleted the go-to-interface-definition branch August 20, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants