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

Bug 325868

Summary: [QualifiedName] Introduce first class concept for qualified names
Product: [Modeling] TMF Reporter: Sebastian Zarnekow <sebastian.zarnekow>
Component: XtextAssignee: Jan Koehnlein <jan>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: jan, sven.efftinge, tmf.xtext-inbox
Version: 2.0.0Flags: sebastian.zarnekow: indigo+
Target Milestone: M3   
Hardware: All   
OS: All   
Whiteboard:

Description Sebastian Zarnekow CLA 2010-09-21 11:30:39 EDT
Qualified names are currently plain strings which makes it not that easy to work with them. We should introduce an immutable type for this concept similar to

QualifiedName {
  String toString();
  int getSegmentCount();
  String getSegment(int);
  Iterable<String> getSegments();
  isPrefixOf(IQualifiedName)
  endsWithWildcard()
  getDelimiter()
}

This would make qualified names more independent from their concrete syntax, e.g. the index representation could be different from the language specific representation.

What do others think?
Comment 1 Sven Efftinge CLA 2010-09-21 12:47:43 EDT
Yeah, that one should be used in IEObjectDescription as well.
In case a qualified name is not that "simple" (i.e. URI), one simply can't leverage the segments and delimiter stuff. But that should be rare and also not a big problem.
I can imagine that this becomes kind of mandatory in order to solve the outstanding enhancements regarding namespace imports.
Comment 2 Jan Koehnlein CLA 2010-10-14 06:01:00 EDT
The QualifiedName should be an immutable list/array of Strings internally. It should offer factory methods to create new QNs based on existing ones. 

The QN should be used in the IQualifiedNameProvider and in EObjectDescriptions and in their clients. We have not agreed yet if the separator is integral part of the QN itself or passed in with regard to the context. 

There should also be an EDataType for QNs to be used e.g. in the EObjectDescriptions, but languages leveraging qualified names should not necessarily depend on this EDataType and rather stick to EString, at least for simple names. 

We should investigate if we can save memory by pooling the strings.
Comment 3 Sven Efftinge CLA 2010-10-14 06:05:59 EDT
(In reply to comment #2)
> We have not agreed yet if the separator is integral part
> of the QN itself or passed in with regard to the context. 
> 

Let's start without this information and see whether we are going to miss it.
Comment 4 Jan Koehnlein CLA 2010-10-20 09:39:43 EDT
Pushed to master.

QualifiedNames can be created 
1) using the IQualifiedNameProvider for global (fully-qualified) names
2) using the IQualifiedNameConverter parsing a String into a QualifiedName respecting the language specific delimiter
3) by appending/triming existing QualifiedNames
4) by using the QualifiedName.create() method when the segments are already known.

The new IQualifiedNameConverter also converts QualifiedNames back to String taking the delimiter into account. The delimiter is now an implementation detail of this component only. Similarly, the wildcard has become a property of the ImportedNamespaceAwareScopeProvider. 

Updated scopes and content assist to use QualifiedNames, as well as the JVM types and MWE. Added a bunch of tests for the new classes.
Comment 5 Karsten Thoms CLA 2017-09-19 17:13:03 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 6 Karsten Thoms CLA 2017-09-19 17:24:31 EDT
Closing all bugs that were set to RESOLVED before Neon.0