-
Notifications
You must be signed in to change notification settings - Fork 333
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
Range selection for scala 3 #6485
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.
In Scala 2 val _ = locateUntyped(pos)
will set lastVisitedParentTrees
to the correct thing. Just wrap def
in an object. Also for Scala 3, it seems we already have a fix that just needs to be ported from compiler repo: scala/scala3#19777.
Ah - I think I see. I asked the wrong question. I think you're telling me that the Whether or not is should need to compile for this to work? Let's set that to one side as I guess it opens a bit can of horrible that I would doubt I can deal with. Thankyou for your response 🙏 . I'll have another go with this in mind. Finally: In the scala3 case should I be attempting to "sniff" if we're using scala3 and delegate to the presentation compiler directly, or do you in fact mean the much blunter "copy that code into metals" strategy? |
It doesn't need to compile. Interactive driver can deal with some errors/missing code but apparently not with that.
Yes, this one. So presentation compiler for Scala 3 is being moved from metals to the compiler, so currently for newer Scala 3 versions e.g. |
Thanks for the responses - which make sense. Given the opportunity to copy and paste someone else's code to make a glorious first contribution, I figured best to start with that, and scala 3. I've adjusted the tests, to your excellent suggestions above (thanks)... and I've manage to write a successful test, for scala 3 braceless syntax (yey!). to my dismay (!), the "braced" version of scala 3 failed though. I've stared at it quite a lot, and I honestly think the test I've written, is the behaviour I'd expect. Here the region encloses Should contain one or two extra entries in the list, which I think the current implementation would fail. Given the relative "value added" of getting that last brace... I'm open to simply truncating my own test, to match the compiler repo. It feels naught though - I'd accept advice. |
Looking at the other tests, that seems to have been the case for Scala 3 all along. Though, it does seem more sensible to include the brace IMO. However, even if so, it can be treated as a separate issue and you can just truncate the test for this PR. |
So, my "contribution" thus far is essentially copying and pasting the code you've linked into metals and adding the tests in scala-3 compatibility mode. I would note that I did, in good faith spend some hours looking at the scala-2 version - I struggled. It looks "hard" to me without quite a clear semantic understanding of the scala-2 Said differently, I don't think I can make this better, without some heavyweight help, which I'm not sure would make sense for either of us. So I think I would choose to tie this off here. A little embarrassing perhaps, but I don't think this "makes things worse", and it should be mergeable as is, given that it's someone else code! Thanks for the time you've offered :-), it's much appreciated |
Sure, if you don't want to continue working on this that's fine. Thanks for giving it a try and porting things from dotty. I see some tests are failing on CI, the |
Yes :-) ... I'll look in the coming days and see if I can figure it out. |
Well, I had a first look at this bonus problem, and left rather confused! It seems, that the struggle lies in the
Confusingly VSCode does resolve this symbol, and from what I can tell of the build, mtags-shared depends on tags interface, leaving unclear on where the error above comes from. I strongly suspect, that I am diagnosing the wrong problem here :-(. However, without being able to reproduce locally, I'm scratching my head a little about what to do next. |
mtags/src/main/scala-3/scala/meta/internal/pc/SelectionRangeProvider.scala
Outdated
Show resolved
Hide resolved
I'm still occasionally merging the main branch into this in the hope of getting CI green again... |
Mill might break, but that should not be related. I have a fix ready. |
🥳 successful code copying 🚀 ! |
@tgodzik thanks for the feedback :-) - I've removed the comment, created a new issue, tagged the tests scala 3 and updated this against main. |
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.
Some minor stuff from I noticed, sorry for not mentioning that yesterday!
mtags/src/main/scala-3/scala/meta/internal/pc/SelectionRangeProvider.scala
Outdated
Show resolved
Hide resolved
mtags/src/main/scala-3/scala/meta/internal/pc/SelectionRangeProvider.scala
Outdated
Show resolved
Hide resolved
mtags/src/main/scala-3/scala/meta/internal/pc/SelectionRangeProvider.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.
LGTM!
@kasiaMarek @tgodzik Thankyou very much for your collective support. I hope that this was ultimately helpful. |
I had a look at the good first issues list, and settled on this,
#5894
I believe the 15 lines of code I have thus far, are a failing test. Reading the issue, it is suggested that
Would anyone be able to offer me a hint on this. I can see that in the example below, the
Tree
is actually empty - it's essentially the entire line. It's not clear to me, how I could decompose it further?