eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Type content assist fails to add disambiguating import
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 49
Description
Given:
```java
package foo.bar;
public class Compiler {
}
```
Consider the following:
```java
import foo.bar.*;
class C {
void test() {
Comp // Ctrl+Space here and choose "java.lang.Compiler"
}
}
```
If "foo.bar.Compiler" is chosen from content assist, "import foo.bar.Compiler" is added to the source unit. If "java.lang.Compiler" is chosen, no additional imports are added and error "The type Compiler is ambiguous" is produced.
Any type name that is present in `java.lang` package will do this. `org.eclipse.jdt.internal.core.dom.rewrite.imports.ConflictIdentifier#identifyConflicts` does not seem to be able to work out the name conflict with the implicit import(s).
Contributor guide
Research direction
Reproduce the content-assist case with foo.bar.Compiler and java.lang.Compiler, then inspect org.eclipse.jdt.internal.core.dom.rewrite.imports.ConflictIdentifier#identifyConflicts. Trace how implicit java.lang imports are handled when choosing the completion. Done means selecting java.lang.Compiler adds the required disambiguating import and no ambiguity error remains.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100