-
Notifications
You must be signed in to change notification settings - Fork 337
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
feature: go to implementations for dependency sources #5623
feature: go to implementations for dependency sources #5623
Conversation
This is awesome! Thank you for working on this, it's something I was missing when coming from the IntelliJ. 👍 |
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.
That’s an amazing feature! I have few nitpicks
mtags/src/main/scala/scala/meta/internal/mtags/ScalaToplevelMtags.scala
Outdated
Show resolved
Hide resolved
mtags/src/main/scala/scala/meta/internal/mtags/ScalaToplevelMtags.scala
Outdated
Show resolved
Hide resolved
mtags/src/main/scala/scala/meta/internal/mtags/ScalaToplevelMtags.scala
Outdated
Show resolved
Hide resolved
mtags/src/main/scala/scala/meta/internal/mtags/ScalaToplevelMtags.scala
Outdated
Show resolved
Hide resolved
mtags/src/main/scala/scala/meta/internal/mtags/ScalaToplevelMtags.scala
Outdated
Show resolved
Hide resolved
mtags/src/main/scala/scala/meta/internal/mtags/ScalaToplevelMtags.scala
Outdated
Show resolved
Hide resolved
metals/src/main/scala/scala/meta/internal/implementation/ImplementationProvider.scala
Outdated
Show resolved
Hide resolved
symbol: String | ||
)(implicit ec: ExecutionContext): Future[Set[ClassLocation]] = { | ||
val workspaceImplementations = getWorkspaceLocations(symbol) | ||
val enumCasesImplementations = |
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 you add a comment explaining why we have enumCases
here? I feel like I will soon forget it's because they are resolved during indexing
7b716d1
to
37ebd1b
Compare
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.
Great work! Sorry for taking so long to review.
metals/src/main/scala/scala/meta/internal/implementation/ClassLocation.scala
Outdated
Show resolved
Hide resolved
metals/src/main/resources/db/migration/V5__Jar_type_hierarchy.sql
Outdated
Show resolved
Hide resolved
mtags/src/main/scala/scala/meta/internal/mtags/MtagsIndexer.scala
Outdated
Show resolved
Hide resolved
mtags/src/main/scala/scala/meta/internal/mtags/OnDemandSymbolIndex.scala
Outdated
Show resolved
Hide resolved
mtags/src/main/scala/scala/meta/internal/mtags/MtagsIndexer.scala
Outdated
Show resolved
Hide resolved
37ebd1b
to
9b91b06
Compare
9b91b06
to
25bf321
Compare
352fa37
to
83436ad
Compare
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 this work for Scala standard library? I am trying to find implementations of Seq
but nothing is returned. Maybe you could add a test in ImplementationLspSuite?
Ok, it seems when I try it in the Metals repository it works sometimes, but each time it actually generates heaps of errors such as:
och after a while I get an OOM. It seems to have work on very basic Set, on Set in Predef, but not the Set in immutable package. Could you take a look? |
This is amazing, I'm so excited about this feature, thanks a million for your effort! 🎉 |
check( | ||
"java-implementation", | ||
"java-implementation".ignore, |
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 ignored tests with java files. We need to implement info
in java pc. Alternatively, we can force Compilers
to use scala pc for info
(at least for now), this should make go to impl
work in java files that belong to scala build target.
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.
Let's note what still need to be done in the feature request
check( | ||
"java-classes", | ||
"java-classes".ignore, |
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.
To make this work we need JavaMtags
(or JavaTopLevelMatgs
) to return information about overridden symbols. Now we don't know that RuntimeException
implements Exception
, and only MyException
will be found.
688e897
to
f285962
Compare
|
||
import org.eclipse.lsp4j.Location | ||
|
||
class SymbolHierarchyOps( |
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.
All those things are moved from ImplementationProvider
. Those are not needed for go to implementation anymore but are still used by Supermethods
and RenameProvider
. I didn't want to try and remove those in this PR.
0dd0fea
to
8c6fdbc
Compare
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 will still check out it locally to see if we didn't miss anything.
metals/src/main/scala/scala/meta/internal/implementation/ImplementationProvider.scala
Outdated
Show resolved
Hide resolved
mtags-interfaces/src/main/java/scala/meta/pc/PcSymbolInformation.java
Outdated
Show resolved
Hide resolved
mtags-interfaces/src/main/java/scala/meta/pc/PcSymbolInformation.java
Outdated
Show resolved
Hide resolved
mtags-interfaces/src/main/java/scala/meta/pc/PcSymbolInformation.java
Outdated
Show resolved
Hide resolved
mtags-interfaces/src/main/java/scala/meta/pc/PcSymbolInformation.java
Outdated
Show resolved
Hide resolved
mtags-shared/src/main/scala/scala/meta/internal/pc/PcSymbolInformation.scala
Outdated
Show resolved
Hide resolved
check( | ||
"java-implementation", | ||
"java-implementation".ignore, |
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.
Let's note what still need to be done in the feature request
metals/src/main/scala/scala/meta/internal/implementation/ImplementationProvider.scala
Outdated
Show resolved
Hide resolved
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, just a couple of comments
@@ -840,7 +859,8 @@ class Compilers( | |||
} | |||
|
|||
def loadCompiler( | |||
path: AbsolutePath | |||
path: AbsolutePath, | |||
forceScala: 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.
Could you add docs saying why this is needed?
metals/src/main/scala/scala/meta/internal/metals/BuildTargets.scala
Outdated
Show resolved
Hide resolved
@@ -179,6 +179,10 @@ public CompletableFuture<List<SyntheticDecoration>> syntheticDecorations(Synthet | |||
return CompletableFuture.completedFuture(Collections.emptyList()); | |||
} | |||
|
|||
public CompletableFuture<List<PcSymbolInformation>> info(String symbol) { |
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.
When can it return multiple? Is there a known case?
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.
overloaded 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.
Though usually they have a different symbol
method()
method(+1)
etc.
so this should not repeat.
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.
Yes, but I want it to return all. When we search for implementations of methods, we find implementations of owner class/trait and only then implementations of method, needs to be this way since we index only class hierarchy. E.g. if class A extends B
and we're looking for implementations of B.method(+1)
, the searched method will be A.method
but we don't know the disambiguator so I get them all to find the one I need. In Compilers.scala
there is info
and infoAll
, the first one does exactly what you'd expect and returns only info about that exact symbol.
If this is too odd, we can add overloadedSymbols
to PcSymbolInformation
to learn all the overloaded and get info about each one by one.
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.
@tgodzik, would you prefer I change this?
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 get a full method symbol ? This should be possible using Mtags class. 🤔
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! Amazing work!
Go to implementation for dependency sources scalameta/metals-feature-requests#119.
resolves: #1287
We index the type hierarchy using
ScalaTopLevelMtags
, only saving the name of the overridden symbol and its usage position, the actual symbol is resolved lazily.Shortcomings:
follow up: provide solution for handling renamed symbols