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

Suggest 'var' type variables as auto-completion method arguments. Fix #228 #1567

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

hotspotoq
Copy link

@hotspotoq hotspotoq commented Nov 7, 2023

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.

@hotspotoq

This comment was marked as resolved.

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 this pull request may close these issues.

'var' types are not suggested as auto-completion method arguments
1 participant