-
Notifications
You must be signed in to change notification settings - Fork 136
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 #1953
Content assist does not activate, inside if() within a switch #1953
Conversation
@stephan-herrmann This approach is much elegant. I think we should go ahead with this. |
Thanks. Would you care to resolve the TODOs mentioned above? |
@@ -5951,7 +5951,7 @@ public void testBug574823_completeOn_methodInvocationWithParams_inIfConidtion_in | |||
|
|||
String result = requestor.getResults(); | |||
assertTrue(String.format("Result doesn't contain method forEach (%s)", result), | |||
result.contains("forEach[METHOD_REF]{forEach(), Ljava.lang.Iterable<Ljava.lang.String;>;, (Ljava.util.function.Consumer<-Ljava.lang.String;>;)V, null, null, forEach, (arg0), replace[149, 149], token[149, 149], 60}")); | |||
result.contains("forEach[METHOD_REF]{forEach(), Ljava.lang.Iterable<Ljava.lang.String;>;, (Ljava.util.function.Consumer<-Ljava.lang.String;>;)V, null, null, forEach, (arg0), replace[149, 149], token[149, 149], 55}")); |
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.
@stephan-herrmann Could this be due to poping out the interestingEnclosings
?
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.
@stephan-herrmann Could this be due to poping out the
interestingEnclosings
?
To assess the change in relevance I'd first check which ingredient to this number got lost.
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 answer my own question: with this change R_VOID
is "added" to the relevance, which in fact is the penalty -5
.
This happens during computeRelevanceForExpectingType()
, where previously no expected types were known, but now we recognize that in this condition position type boolean should be expected. This lets us detect that the method return type void
is a bad match.
I confirmed, that without the current change, no expected types were available, and R_VOID
was never raised.
I tried to see if we are missing any control conditions, I see we don't have a endVisit for ForStatement, But even without it our unit test pass with following test snippet
Do you think we are missing any ? |
To parallel the original test case I'd try smth like this:
i.e., completion on a direct child in the ForStatement.condition location (currently you have an intermediate binary expression). Another check for completeness: if we have a method in scope that returns boolean and has a name starting with 'nam': do we propose it with relevance |
@stephan-herrmann I added a additional test for testing the scenarios you mentioned in above comment #1953 (comment) |
b49354b
to
1b9c9da
Compare
…e-jdt#1953) fixes eclipse-jdt#1561 --------- Co-authored-by: Gayan Perera <[email protected]>
…e-jdt#1953) fixes eclipse-jdt#1561 --------- Co-authored-by: Gayan Perera <[email protected]>
fixes #1561
Simpler approach, using new tests from #1625
@gayanper I tried to explain with minimal code comments. LMK if this is sufficient to understand the approach.
This change is not quite complete yet: