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

When code completion includes an import, conflicting names are not considered #439

Closed
eric-milles opened this issue Jan 25, 2018 · 3 comments
Assignees
Labels
Milestone

Comments

@eric-milles
Copy link
Member

Related to #367, #435 and #438 -- when code completion includes an import, conflicting names are not considered. This results in an import that shadows or is shadowed by another name in the scope.

//import static x.y.z.VALUE as NAME
//import static x.y.z.NAME
class C {
  //static Object NAME
  //Object NAME
  //static def NAME() {}
  // def NAME() {}
  void meth(/*def NAME*/) {
    //def NAME
   util(NA|) // completion on "NAME : E" proposal introduces static import that conflicts with any of the NAME declarations above
  }
  void util(E e) {}
}
package p;
enum E {
  NAME
}

A similar situation may exist if completion inserts "E.NAME" and "import p.E" and there is a name "E" in scope.

Partially- or fully-qualified names should be inserted in cases of conflict.

@eric-milles eric-milles added this to the v3.0.0 milestone Jan 25, 2018
@eric-milles eric-milles self-assigned this Jan 25, 2018
@eric-milles eric-milles modified the milestones: v3.0.0, v3.1.0 Jun 15, 2018
@eric-milles eric-milles modified the milestones: v3.1.0, v3.2.0 Aug 18, 2018
@eric-milles
Copy link
Member Author

If org.eclipse.jdt.internal.corext.codemanipulation.ContextSensitiveImportRewriteContext.findInContext(String, String, int) can return a conflicting binding, then a qualifier will be used instead. This already occurs for types, fields, methods, properties.

@eric-milles
Copy link
Member Author

TODO

  1. static imports
  2. for, catch, closure, try-with-resources parameters

@eric-milles
Copy link
Member Author

Import conflicts are not handled by Java editor either. Bug filed with eclipse.org: https://bugs.eclipse.org/bugs/show_bug.cgi?id=542815

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant