-
Notifications
You must be signed in to change notification settings - Fork 330
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
feat: Import missing extension method #4141
Conversation
|
e9d7b19
to
c67ec06
Compare
@@ -142,7 +142,7 @@ trait MtagsIndexer { | |||
definition: m.Position, | |||
kind: s.SymbolInformation.Kind, | |||
properties: Int | |||
): Unit = { | |||
): String = { |
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 changed addSignature
to return the added symbol so we can use those symbols as a next owner.
@@ -415,6 +460,7 @@ object ScalaToplevelMtags { | |||
def owner: String | |||
def acceptMembers: Boolean | |||
def produceSourceToplevel: Boolean | |||
def isExtension: Boolean = false |
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.
- Added
isExntension
flag toExpectTemplate
(andRegion
). - if
ExpectTemplate.isExtension
istrue
on newline or lbrace, asneedsToParseExtension
says, enter to new Region whereextension
istrue
. - In those regions, we will index the symbol of
DEF
s.
Now, ready for review 👍 |
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.
Looks good! TopLevels should also be run on dependency sources, so we should suggest extension methods from dependencies also not only from the workspace.
path, | ||
s"""|package x | ||
|def main = | ||
| println(1.<<incr>>) |
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.
Could we maybe add it to the code actions Scala 3 suite? Or at least it would be nice to see the code action applied to test if it works correctly
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.
Tested check edit 6d49fb9 👍
a3980aa
to
8dcad16
Compare
8dcad16
to
91a3903
Compare
@tgodzik |
@tanishiking I took a look at |
|
Ahhh, I just mistook So, you mean While @dos65 talks about TopLevelSuite to work on Scala3. In metals/tests/unit/src/test/scala/tests/ToplevelSuite.scala Lines 39 to 40 in a163e22
|
There is suspicious clause and comment but I'm not sure how it affects this test. metals/tests/unit/src/test/scala/tests/ToplevelSuite.scala Lines 30 to 31 in f9660d5
|
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.
Added super minor comments, which we can fix later on. LGTM! Great feature to have, we can comment on the issue to document what is added and what still needs to be done.
Co-authored-by: Tomasz Godzik <tgodzik@users.noreply.github.com>
Hmm, right I'll take a look in another PR 👀 |
close scalameta#4212 In scalameta#4141 we started indexing the extension methods (for auto-import missing extension methods) in `workspaceSymbolIndex` where we should index only top-level symbols. Later in scalameta#4183 we decided to index those extension method symbols in a separate index (see more details around here: scalameta#4183 (review)). This PR refactor import missing extension method to use the index only for extension method symbols. This change slightly improve the performance of symbol search and reduce the memory footprint for symbol index.
close #4212 In #4141 we started indexing the extension methods (for auto-import missing extension methods) in `workspaceSymbolIndex` where we should index only top-level symbols. Later in #4183 we decided to index those extension method symbols in a separate index (see more details around here: #4183 (review)). This PR refactor import missing extension method to use the index only for extension method symbols. This change slightly improve the performance of symbol search and reduce the memory footprint for symbol index.
refer scalameta/metals-feature-requests#141
This PR enables Metals to auto-import missing extension method from the workspace (it doesn't support import from third-party libraries).
This is done by
ScalaToplevelMtags
value xxx is not a member of yyy
.What I didn't in this PR