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

Autocompletion with unimported types #1123

Closed
anthonyvdotbe opened this issue Oct 29, 2019 · 12 comments
Closed

Autocompletion with unimported types #1123

anthonyvdotbe opened this issue Oct 29, 2019 · 12 comments

Comments

@anthonyvdotbe
Copy link

When trying to invoke a static/instance method on an unimported type, VS Code should be more helpful.

Environment
  • Operating System: Windows_NT x64 10.0.18362
  • JDK version: openjdk full version "13.0.1+9"
  • Visual Studio Code version: 1.39.2 (user setup)
  • Java extension version: 0.52.0
Steps To Reproduce

Consider the code snippets below. When invoking code completion after the dot, I'd expect VS Code to help me somehow, e.g. by proposing all possible completions of all applicable types it knows of. Or by proposing to import the unknown types.

class Foo {
    void foo() {
        IntStream.
    }
}
class Foo {
    void foo() {
        new ArrayList().
    }
}
Current Result

For the first example, I need to first type something like IntStream i;, then trigger imports, then go back to IntStream. to trigger autocompletion.

Expected Result

I'd expect VS Code to help me somehow, e.g. by proposing all possible completions of all applicable types it knows of. Or by proposing to import the missing types.

Additional Informations

For comparison, when invoking the samples above in Apache NetBeans 11.0, I get the following:

image

image

@fbricon
Copy link
Collaborator

fbricon commented Oct 29, 2019

That's an interesting feature, but we might be limited by JDT's capabilities. @snjeza can you please investigate whether this needs fixing upstream JDT or if it's doable from jdt.ls?

@snjeza
Copy link
Contributor

snjeza commented Oct 30, 2019

Eclipse works the same way.

@mickaelistria
Copy link
Contributor

Eclipse works the same way.

Can you please report the issue upstream in JDT then?

@snjeza
Copy link
Contributor

snjeza commented Oct 21, 2023

The following works in VS Code >= 1.23.0

void foo() {
    IntStream.|
}

vscode3

@snjeza
Copy link
Contributor

snjeza commented Oct 23, 2023

Can you please report the issue upstream in JDT then?

@mickaelistria You may want to take a look at eclipse-jdt/eclipse.jdt.core#1502

@mickaelistria
Copy link
Contributor

thank you

@snjeza
Copy link
Contributor

snjeza commented Oct 23, 2023

The issue can be reproduced in Oracle Java Platform Support

1123

@snjeza
Copy link
Contributor

snjeza commented Oct 29, 2023

I have tried Netbeans 19 and IntelliJ IDEA 2022.2.5. They work like eclipse

Netbeans 19

netbeans

IntelliJ IDEA 2022.2.5- (works with enabled enable Add unambiguous imports on the fly

idea

cc @fbricon @mickaelistria @anthonyvdotbe

@anthonyvdotbe
Copy link
Author

For NetBeans: yes, ArrayList broke somewhere between 11 and 19; IntStream still works.
For IntelliJ: enable Add unambiguous imports on the fly.

@snjeza
Copy link
Contributor

snjeza commented Oct 29, 2023

IntStream still works.

It works in Eclipse/VS Code, too

@snjeza
Copy link
Contributor

snjeza commented Oct 30, 2023

For IntelliJ: enable Add unambiguous imports on the fly.

+1

@rgrunber rgrunber added this to the Mid December 2024 milestone Dec 9, 2024
@rgrunber
Copy link
Member

rgrunber commented Dec 9, 2024

Just tried this out in our pre-releases, since the fix was merged upstream (thanks to @snjeza ), and it seems we've picked it up as well now :

Image

Marking as closed for now.

@rgrunber rgrunber closed this as completed Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants