Suggest 'var' type variables as auto-completion method arguments. Fix #228 #1567
+15
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What it does
Uses existing logic which has been commented out.
The condition
local.declaration.initialization != null
matches with variables being initialized but also matches var declarations. Then var variables get out of completion candidates. Fortunately, there was existing logic in code's comments that can deal with this problem.This simple changes also fix this issue but are not perfect here. (The problem is that var variables being initialized will appear in proposals, but can this change be better choice?)
78adf91f002a1a9b7d1838c24de08c2d5f608e25
Provides resolved types of var declarations.
When calculating auto-boxing scores, var is considered qualified class type whose name is var. Without the change, primitive type variables declared with var get bad scores; the auto-completion suggests 0 of literal instead of var variables. This change is same as: 3b1eade6257846b964d26359bdcfbc40d6c4bec4
Uses the method with null checks and adds an argument.
I believe it should have null checks.
local.declaringScope
is used to tell whether var keyword is available at the version.How to test
eclipse.jdt.ui/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/MethodParameterGuessingCompletionTest10.java
eclipse.jdt.ui/org.eclipse.jdt.text.tests/src/org/eclipse/jdt/text/tests/contentassist/CompletionTestSetup10.java
These tests will have to be situated in eclipse.jdt.ui, what can I do?
Author checklist
I'm open to changing expressions since I'm not good at English.