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

Completion for unimported types doesn't work #1502

Closed
snjeza opened this issue Oct 23, 2023 · 6 comments · Fixed by #1503
Closed

Completion for unimported types doesn't work #1502

snjeza opened this issue Oct 23, 2023 · 6 comments · Fixed by #1503
Labels
content assist Content assist related issues
Milestone

Comments

@snjeza
Copy link
Contributor

snjeza commented Oct 23, 2023

The related issue - redhat-developer/vscode-java#1123

Steps to reproduce:

  • create the following class
public class X {
	void foo() {
		new ArrayList<>().|
	}
}
  • call CA
@stephan-herrmann
Copy link
Contributor

As @fbricon mentioned in redhat-developer/vscode-java#1123: an interesting feature :)

@snjeza could you specify what exactly you expect JDT to do?

When you observed that other tools give meaningful proposals, does this work for any type, or are well-known classes (e.g., in java.util) treated specially?

What should JDT do, if the simple type name has multiple candidates in the workspace?

Another question is about the relevance of such feature? Is it common practice to manually type expressions like "new ArrayList<>()" (using completion already at that level would have inserted the import), and only then invoking content assist?

@snjeza
Copy link
Contributor Author

snjeza commented Oct 29, 2023

@snjeza could you specify what exactly you expect JDT to do?

without the PR

withoutpr

with the PR

withpr

@snjeza
Copy link
Contributor Author

snjeza commented Oct 29, 2023

When you observed that other tools give meaningful proposals, does this work for any type, or are well-known classes (e.g., in java.util) treated specially?
What should JDT do, if the simple type name has multiple candidates in the workspace?

You may want to take a look at

return (char[][][])results.toArray(new char[results.size()][0][0]);

@stephan-herrmann
Copy link
Contributor

@snjeza your screencasts show the behavior for one very specific situation, not the general story.

You may want to take a look at ...

sure the code is the ultimate truth, but perhaps a reviewer (not necessarily me) may want to compare the implementation against the intention. That's why I asked about your expectations / intentions.

@snjeza
Copy link
Contributor Author

snjeza commented Oct 29, 2023

sure the code is the ultimate truth, but perhaps a reviewer (not necessarily me) may want to compare the implementation against the intention. That's why I asked about your expectations / intentions.

What should JDT do, if the simple type name has multiple candidates in the workspace?

MissingTypesGuesser selects all missing types and offers their completion.
withpr2

@snjeza
Copy link
Contributor Author

snjeza commented Oct 29, 2023

When you observed that other tools give meaningful proposals, does this work for any type, or are well-known classes (e.g., in java.util) treated specially?

I have tried Netbeans 19 and IntelliJ IDEA 2022.2.5. Please see redhat-developer/vscode-java#1123 (comment)

snjeza added a commit to snjeza/eclipse.jdt.core that referenced this issue Dec 5, 2023
- use MissingTypesGuesser to select all missing types and offer their completion

The related issue: eclipse-jdt#1502
@stephan-herrmann stephan-herrmann added the content assist Content assist related issues label Sep 15, 2024
rgrunber pushed a commit that referenced this issue Dec 3, 2024
- use MissingTypesGuesser to select all missing types and offer their completion
- Fixes #1502
@rgrunber rgrunber added this to the 4.35 M1 milestone Dec 3, 2024
jarthana added a commit that referenced this issue Dec 6, 2024
* Remove nolonger support converterJclMin (#3332)

Versions older than 1.8 are not supported and thus shouldn't be needed
anymore.

* Fix and enable Java50Tests#testMissingRequiredBinaries

* Version bump(s) for 4.35 stream

* Test failures in I-Builds due to less diagnostics being emitted (#3357)

* Fixes #3356

* Textual problem indicator goes wild with lamda (#3358)

* jclMin23: ignore missing serializable problem

"The serializable class Long does not declare a static final
serialVersionUID field of type"

* Fix FieldLocator and MethodLocator to support local/anonymous classes (#3314)

- Fix FieldLocator.reportDeclaration() and
  MethodLocator.reportDeclaration() to find the anonymous or local
  type for the declaration rather than to return
- add new tests to JavaSearchBugsTests
- fixes #3308

* Codegen Primitives in record comonent patterns to be enabled with null check before calling accessor(#3361)

Before generating an invoke of accessor of a record component, do a null check if primitive conversions are involved.

* java.lang.StackOverflowError during "Requesting Java AST from selection" (#3373)

+ resilience: avoid accepting a sourceType being completed already
+ better hiding of modules seen via the classpath

Fixes #3273

* Add NoSuchFieldError to converterJclMin18 (#3368)

Add NoSuchFieldError to converterJclMin18
 + build the jar
 + avoid new warning

Enable couple of tests fixed by this.

---------
Co-authored-by: Stephan Herrmann <stephan.herrmann@berlin.de>

* Incorrect control flow analysis causes statement subsequent to a switch statement to be flagged unreachable under some circumstances(#3377)

* Fixes #3376

* Remove unused api problem filter

* Update tycho build to 4.0.10

* Completion for unimported types doesn't work.

- use MissingTypesGuesser to select all missing types and offer their completion
- Fixes #1502

* [Enhanced Switch] Wrong error message: Cannot switch on a value of type Integer... at levels that don't support enhanced switch (#3380)

* Fixes #3379

---------

Co-authored-by: Александър Куртаков <akurtakov@gmail.com>
Co-authored-by: Eclipse JDT Bot <jdt-bot@eclipse.org>
Co-authored-by: Srikanth Sankaran <131454720+srikanth-sankaran@users.noreply.github.com>
Co-authored-by: Jörg Kubitz <jkubitz-eclipse@gmx.de>
Co-authored-by: Jeff Johnston <jjohnstn@redhat.com>
Co-authored-by: Manoj  N Palat <manoj.palat@in.ibm.com>
Co-authored-by: Stephan Herrmann <stephan.herrmann@berlin.de>
Co-authored-by: Snjeza <snjezana.peco@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content assist Content assist related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants