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

No type completions after case keyword in switch expressions/statements with type pattern matching #2260

Open
gayanper opened this issue Mar 31, 2024 · 2 comments

Comments

@gayanper
Copy link
Contributor

Given the source code

Number n;

switch(n) {
   case 
}

No type completions are provided after case

@gayanper
Copy link
Contributor Author

@stephan-herrmann test case we can use

	public void testGH2260() throws JavaModelException {
		this.workingCopies = new ICompilationUnit[1];
		this.workingCopies[0] = getWorkingCopy("/Completion/src/SwitchTypePattern.java", """
				public class SwitchTypePattern  {
					public foo(Number n) {
						switch(n) {
							case I
						}
					}
				}\
				""");
		CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
		requestor.allowAllRequiredProposals();
		String str = this.workingCopies[0].getSource();
		String completeBehind = "case I";
		int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
		this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
		assertResults("""
				Integer[TYPE]{Integer, null, null, Ljava.lang.Integer, null, 49}\
					""", requestor.getResults());
	}	

@stephan-herrmann
Copy link
Contributor

I prefer to first get an overview of the big picture before resolving individual test cases, because otherwise we will have to refactor the same code region over and over again. But surely we can use this test case as one example in #1531 :)

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

No branches or pull requests

2 participants