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

completion returns no results with pattern matching #2106

Open
snjeza opened this issue Mar 6, 2024 · 10 comments · May be fixed by #2107
Open

completion returns no results with pattern matching #2106

snjeza opened this issue Mar 6, 2024 · 10 comments · May be fixed by #2107
Assignees

Comments

@snjeza
Copy link
Contributor

snjeza commented Mar 6, 2024

The related issues:

From eclipse-jdtls/eclipse.jdt.ls#3068
Consider the following code:

import java.util.ArrayList;
import java.util.List;

public class SimpleJavaClass {
  public static void main(String[] args) {
    Object unknown = new ArrayList<>();

    if (unknown instanceof List things) {
      things.is| // CA doesn't work
      Object nothing = null;
      things.is| // CA works
    }
  }
}

CA returns no results if requested for the first occurrence of things.is. It returns isEmpty(), however, for the second occurrence of thing.is

@iloveeclipse
Copy link
Member

Can you please check with latest 4.32 I-Build?

@snjeza snjeza linked a pull request Mar 6, 2024 that will close this issue
@srikanth-sankaran
Copy link
Contributor

Can you please check with latest 4.32 I-Build?

Unfortunately, the recent work on patterns is pure compiler work and does not cover code completion and #1349 and its cousins are also only focussed on code selection not completion.

@snjeza - the fix proposed in #2107 is suspect. You should never have to fiddle with ExtraCompilerModifiers.AccOutOfFlowScope bits.

@srikanth-sankaran
Copy link
Contributor

srikanth-sankaran commented Mar 7, 2024

The parse tree recovered in the working case you report is:

import java.util.ArrayList;
import java.util.List;
public class SimpleJavaClass {
  String things;
  public SimpleJavaClass() {
  }
  public static void main(String[] args) {
    Object unknown;
    {
      things.is Object;
      if ((unknown instanceof List things))
          <CompleteOnName:things.is>;
    }
  }
}

and the parse tree recovered in the non-working case is:

import java.util.ArrayList;
import java.util.List;
public class SimpleJavaClass {
  String things;
  public SimpleJavaClass() {
  }
  public static void main(String[] args) {
    Object unknown;
    {
      if ((unknown instanceof List things))
          <CompleteOnType:things.is> Object;
    }
  }
}

There in lies the problem.

Completion is being attempted on a Name in both instances. Why do we think it is being attempted on a Type ? I can help with reviewing an alternate fix. Thanks

@srikanth-sankaran
Copy link
Contributor

@snjeza
Copy link
Contributor Author

snjeza commented Mar 7, 2024

Can you please check with latest 4.32 I-Build?

I have reproduced the issue in the master branch - d767ba2

@snjeza
Copy link
Contributor Author

snjeza commented Mar 7, 2024

Completion is being attempted on a Name in both instances. Why do we think it is being attempted on a Type ? I can help with reviewing an alternate fix. Thanks

The parser returns CompletionOnQualifiedNameReference in line 10 (it works) and CompletionOnQualifiedTypeReference in line 8 (it doesn't work)

@srikanth-sankaran
Copy link
Contributor

Completion is being attempted on a Name in both instances. Why do we think it is being attempted on a Type ? I can help with reviewing an alternate fix. Thanks

The parser returns CompletionOnQualifiedNameReference in line 10 (it works) and CompletionOnQualifiedTypeReference in line 8 (it doesn't work)

Right, that is the bug that needs fixing.

@snjeza
Copy link
Contributor Author

snjeza commented Mar 7, 2024

the fix proposed in #2107 is suspect. You should never have to fiddle with ExtraCompilerModifiers.AccOutOfFlowScope bits.

I have restored it at 015c32e#diff-8469e0f05a7f350e7047101a3e20fe0bf4d0f65df01fa0a18eb6378128c5de5aR2364

@snjeza
Copy link
Contributor Author

snjeza commented Mar 7, 2024

I can help with reviewing an alternate fix.
Right, that is the bug that needs fixing.

I will try. Thanks.

@srikanth-sankaran
Copy link
Contributor

I can help with reviewing an alternate fix.
Right, that is the bug that needs fixing.

I will try. Thanks.

Good luck! You may want to compare how the parse tree looks with code select when you control click on things.isEmpty() at both places.

@rgrunber rgrunber moved this to 👀 In review in IDE Cloudaptors Mar 13, 2024
@snjeza snjeza moved this from 👀 In review to 🏗 In progress in IDE Cloudaptors Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants