-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
record end markers in trees and semanticdb, exclude top level def wrappers #12541
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Edit now it works |
also added fixes for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should take the time to discuss the overall approach here at the next Monday meeting. I think it's fine but it's worth asking whether this is ideal.
I have thought that this isn't going to work when compiling from tasty - although we have never tested semanticdb idempotency from tasty anyway |
True, we'd need to store the EndIndex in tasty too to support that (by the way, do we actually need the offset? Seems like we could get by with only one boolean to know whether there is an end marker or not, then just assume the offset corresponds to the tree span end offset). |
This does not work presently, unless we modify the span of the tree after checking that the end marker is correctly positioned (otherwise the end of the tree span is before the end marker) |
Ah, I didn't know that, I would expect it to be part of the span indeed, that could be useful for other IDE operations like commenting out a whole definition |
d839dde
to
049904a
Compare
I have changed so that now all statements will receive a modified span, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but we should still strive to have all IDE-relevant information in Tasty, so maybe open an issue about how to preserve WithEndMarker? Maybe we could use a flag for that.
I get that recording this occurrence isn't particularly useful, but its it incorrect to have it in semanticdb? The occurence is real, it's just not visible at source-level, but the same is true for many other things generated by the compiler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
As far as I know - occurrences are only for visible references in the source code - many things are excluded because of this - we still record that the wrapper exists in the |
Edit: Or symbols as Jamie explained. |
perhaps we kept it in the past because there was (still is at this time) no synthetics section? |
Most likely, but they were not used by Metals or any other tool using semanticdb. |
compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala
Outdated
Show resolved
Hide resolved
set the Synthetic flag on top level wrapper objects. fixes scala#11693, top level definition wrapper objects no longer appear as a definition occurrence in semanticdb, but are still recorded as a symbol
fixes #12326
fixes #11693
modify spans of all trees with end markers.
record an end marker was present for trees that reference symbols
also prevent top level definition wrapper objects appearing in occurrences (as a definition, but record explicit references)