Skip to content
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

Content assist does not activate, inside if() within a switch #1561

Closed
lukeu opened this issue Nov 6, 2023 · 11 comments · Fixed by #1953
Closed

Content assist does not activate, inside if() within a switch #1561

lukeu opened this issue Nov 6, 2023 · 11 comments · Fixed by #1953
Assignees
Labels
bug Something isn't working regression Something was broken by a previous change

Comments

@lukeu
Copy link

lukeu commented Nov 6, 2023

I'm migrating bugzilla 576934 here, as requested in (the closely-related) github issue #341

I had upgraded from Eclipse 4.20 > 4.21 to pick up fixes for content assist regressions, but I ran into this still-failing case:

public class Snippet {
  final String name = "test";
  enum Type { A }

  private void go(Type a) {
    switch (a) {
    case A:
      if (nam)
      break;
    }
  }
}

Trying ctrl+space after 'nam' in the incomplete 'if' statement still shows nothing, similarly to bugzilla 573632

Also per a workaround mentioned in there, adding another symbol after the identifier gets completion working again:

if (nam <)

Deleting the closing ')' also kicks it into working:

if (nam

Note, however, that Eclipse by default inserts that closing ')' for us.

I have confirmed this is still present in a recent nightly - Eclipse 2023-12 (4.30) Build id: I20231024-1800

@jukzi
Copy link
Contributor

jukzi commented Nov 20, 2023

@jjohnstn is such code completion ui?

@humphreygao
Copy link

also encountered this problem yesterday

@jjohnstn
Copy link
Contributor

@jukzi Nearly all such completion bugs are due to parsing (e.g. fails only inside a case of a switch inside a foreach) and are fixed in core. That said, if debugging proves otherwise, it can be thrown over to JDT UI.

@jukzi
Copy link
Contributor

jukzi commented Nov 21, 2023

@mpalat 4.21 introduced JEP 406: Pattern Matching for switch (Preview) so this is probably a regression from that. Who is familiar with that parsing?

@jukzi jukzi added bug Something isn't working regression Something was broken by a previous change labels Nov 21, 2023
@jukzi
Copy link
Contributor

jukzi commented Nov 21, 2023

A similar problem was fixed with #1312 @gayanper can you look at this too?

@gayanper
Copy link
Contributor

gayanper commented Nov 22, 2023

This is cause by a parser error:

In this case we should be expecting:
astNode : CompletionOnNameReference
astNodeParent : IfStatement
enclosingNode: May be SwitchStatement

But instead we get

astNode : CompletionOnNameReference
astNodeParent : SwitchStatment

which is wrong, I can have a look at this for the next release. ideally we should not get. a parent in this scenario which makes me to doubt the recent switch expression related changes we did at CompletionNodeDetector.

@gayanper gayanper self-assigned this Nov 22, 2023
gayanper added a commit to gayanper/eclipse.jdt.core that referenced this issue Nov 24, 2023
gayanper added a commit to gayanper/eclipse.jdt.core that referenced this issue Nov 25, 2023
@jukzi jukzi linked a pull request Nov 27, 2023 that will close this issue
3 tasks
@jukzi
Copy link
Contributor

jukzi commented Nov 27, 2023

@lukeu please test if #1561 solves your problems.

@lukeu
Copy link
Author

lukeu commented Nov 28, 2023

@lukeu please test if #1561 solves your problems.

Well that was quite the ride. It's been 4-5 years since my one tiny Eclipse (Buildship) contribution. But after a few hours of following the bread-crumbs & trying to do things the "new ways", I see there's been quite a bit of effort put into helping devs get set up to contribute changes to certain specific modules of this gigantic jigsaw puzzle software. :-) Wrangling with Ooomph and MyLyn & github pull requests. (I never use any of these things for my own Java development. Simple git command-line for me, normally.)

And eventually I can confirm: ctrl+space did indeed work as advertised, in the posted code sample. Many thanks!

@gayanper
Copy link
Contributor

gayanper commented Nov 28, 2023

Give me some time, I might be able to share a very simple solution for getting JDT up and running. I have to clean that workspace setup a bit and also test with Eclipse it self.

Eclipse if self ?

Thats is because nowadays I use vscode with JDT.LS with few of extensions to develop in JDT as well :). But I think the same target environment setup should work fine in a pure eclipse setup as well. Will post one I get the chance to push to a GitHub repo.

gayanper added a commit to gayanper/eclipse.jdt.core that referenced this issue Nov 28, 2023
@lukeu
Copy link
Author

lukeu commented Nov 28, 2023

Give me some time, I might be able to share a very simple solution for getting JDT up and running. I have to clean that workspace setup a bit and also test with Eclipse it self.

Hey, thanks for the offer. But I'm actually pretty happy with the path I ended up walking, because it took me through some areas I've been ignoring over the years - I now have one "Eclipse For Committers" installation to browse the JDT source. It launches another (basic) Eclipse with JDT for debugging - just like any other app. The steps are simpler than most of the documentation I'd found made it sound, in the end "following my nose" was easier:

  1. Install the Ooomph installer > Advanced > Eclipse For Committers > Latest
  2. In the 2nd page, select all JDT modules for "Procurement" - I had no idea what this meant. It turns out that after "Eclipse For Commiters" starts, this proceeds to check-out these repos from github and organizes them nicely into the default workspace - Nice!
  3. In fact the bit I probably struggled with most was how to download a PR/commit from github. Mylyn was a distraction - what I needed was just in the Teams context menu, and after (quite) a few guesses at what URL to use, I was up and running

I'm glad JDT has found a 2nd use in VSCode as that's obviously a very popular editor these days. Maybe some short "cheat-sheet" steps could well help lower the barriers for other VSCode-using contributors?

@srikanth-sankaran
Copy link
Contributor

See also : #2106 not involving switches,

stephan-herrmann added a commit to stephan-herrmann/eclipse.jdt.core that referenced this issue Mar 14, 2024
stephan-herrmann added a commit that referenced this issue Mar 14, 2024
robstryker pushed a commit to robstryker/eclipse.jdt.core that referenced this issue Jul 18, 2024
gayanper added a commit to gayanper/eclipse.jdt.core that referenced this issue Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Something was broken by a previous change
Projects
None yet
6 participants