-
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
Semanticdb usability enhancements #9768
Semanticdb usability enhancements #9768
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.
Thanks for the great work! LGTM I left just a single question, though that might be obvious.
suit/*->_empty_::Enums.Suits.extension_isRed().(suit)*/ ==/*->scala::Any#`==`().*/ Hearts/*->_empty_::Enums.Suits.Hearts.*/ ||/*->scala::Boolean#`||`().*/ suit/*->_empty_::Enums.Suits.extension_isRed().(suit)*/ ==/*->scala::Any#`==`().*/ Diamonds/*->_empty_::Enums.Suits.Diamonds.*/ | ||
|
||
extension (suit/*<-_empty_::Enums.Suits.extension_isBlack().(suit)*/: Suits/*->_empty_::Enums.Suits#*/) def isBlack: Boolean /*<-_empty_::Enums.Suits.extension_isBlack().*//*->scala::Boolean#*/= suit/*->_empty_::Enums.Suits.extension_isBlack().(suit)*/ match | ||
extension (suit/*<-_empty_::Enums.Suits.extension_isBlack().(suit)*/: Suits/*->_empty_::Enums.Suits#*/) def isBlack/*<-_empty_::Enums.Suits.extension_isBlack().*/: Boolean/*->scala::Boolean#*/ = suit/*->_empty_::Enums.Suits.extension_isBlack().(suit)*/ match |
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.
Should the name be something like extension-isBlack().
? I think we can't name a method like that, but we can name a method extension_isBlack
Or is that not an issue?
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.
Sorry, I'm not sure what you mean
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 am just wondering what is the string representation for extension methods (since basically everything is represented by string in semanticdb) and can it not conflict with a normal method in the class prefixed with extension_
It is highly unlikely that a method like that will be created, but I wonder if we should maybe change the string representation for extension methods.
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 see, there is a check in desugaring that proves only extension methods can have that prefix, although its probably not been enforced in macros
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.
actually it seems val/vars can also have this name 😕
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.
what do you think about using extension-
to signal it's an extension? We can't use -
in the name so it should be good.
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.
so extension [T,U](t: T) def <*>: (T,U) = ???
would be extension-`<*>`().
?
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.
the other alternative is that we add another Property kind (alongside FINAL, SEALED, etc.)
compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala
Outdated
Show resolved
Hide resolved
var length = realName.length | ||
if symbol.is(ExtensionMethod) && name.isExtensionName then | ||
length -= "extension_".length |
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.
Not essential but it might be nicer to have a stripExtensonMethodPrefix just like we have a stripModuleClassSuffix (are there other situations where we need to strip the extenson_ prefix?)
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.
there is the dropExtension
method but its only used for import suggestions so far
|
Try rebasing, it should be fixed now |
Also, proxy wrappers for main annotated methods get a synthetic span
dd87339
to
bc94382
Compare
rebased and added a check to look in the mods also |
else { | ||
val realName = name.stripModuleClassSuffix.lastPart | ||
Span(point, point + realName.length, point) | ||
var length = realName.length | ||
if (mods.is(ExtensionMethod) || symbol.is(ExtensionMethod)) && name.isExtensionName then |
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.
Is the symbol.is(ExtensionMethod)
check necessary?
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 was told once that mods may not always be copied over beyond some phase but I'm not sure about this
This PR breaks the master. |
This has a bunch of enhancements,
nameSpan
@main def
proxy wrappers now have synthetic spansnameSpan
shortened inExtractSemanticDB
to remove the hiddenextension_
offset