Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 317971

Summary: Code completion inserts unnecessary qualified name
Product: [Modeling] TMF Reporter: Sebastian Benz <sebastian.benz>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow, sven.efftinge
Version: 1.0.0Flags: sebastian.zarnekow: helios+
Target Milestone: SR1   
Hardware: All   
OS: All   
Whiteboard:

Description Sebastian Benz CLA 2010-06-25 09:23:19 EDT
When importing a namespace and its subnamespace, the code completion inserts a qualified name for an referenced element even though the subnamespace is imported. 

Example:
...
import datatypes.*
import datatypes.subtypes.*

interface senderReceiver MyTest {
  data subtypes.MyUInt8 <- inserted by code completion
       ################  
}

The problem is that in:
ImportedNamespaceAwareLocalScopeProvider#getImportedElements(...)

...
for (ImportNormalizer normalizer : normalizers) {
  final String newName = normalizer.longToShortName(input.getName());
  if (newName != null) {
    return new AliasedEObjectDescription(newName, input);
   ...

the first shortened name is returned (which might not be the shortest one). A workaround is to store the importNormalizers in a Set that is ordered by the length of the imported name.
Comment 1 Sven Efftinge CLA 2010-08-03 05:05:53 EDT
The precedence has been inverted, such that given your example the shorter name comes first (i.e. precedence is bottom up). 
This allows to reference using the longer name as well, and lets the user control the precedence of imports.
Comment 2 Karsten Thoms CLA 2017-09-19 16:03:42 EDT
Closing bug which were set to RESOLVED before Eclipse Neon.0.