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

Bug 332500

Summary: Case insensitive imports not completely implemented
Product: [Modeling] TMF Reporter: Mark Christiaens <mark.g.j.christiaens>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: mark.g.j.christiaens, sebastian.zarnekow, sven.efftinge
Version: 2.0.0Flags: sebastian.zarnekow: indigo+
Target Milestone: M7   
Hardware: All   
OS: All   
Whiteboard:

Description Mark Christiaens CLA 2010-12-14 04:50:07 EST
Build Identifier: I20101028-1441

Case insensitive imports don't seem to be fully supported yet.  For example in ImportScope.getLocalElements:

...
Function<IEObjectDescription, IEObjectDescription> aliaser = new Function<IEObjectDescription, IEObjectDescription>() {
	public IEObjectDescription apply(IEObjectDescription from) {
		final QualifiedName deresolved = normalizer.deresolve(from.getName());
		if (deresolved==null)
			throw new IllegalStateException("Couldn't deresolve "+from.getName()+" with import "+normalizer);
		return new AliasedEObjectDescription(deresolved, from, ignoreCase);
	}
};
...

The IllegalStateException is thrown.  It seems that the ImportNormalizer thinks it can handle the from.getName but then tries to deresolve with a namespace prefix with the wrong case.

Reproducible: Always
Comment 1 Mark Christiaens CLA 2011-01-24 03:49:09 EST
Maybe have a look also at ImportedNamespaceAwareLocalScopeProvider.getWildCard(). It returns by default a "*".  I think, after that, the "*" is not dealt with in a case-insensitive manner.  So if I override the getWildcard to return "all" (which is the wildcard in VHDL) then things seem to go wrong.
Comment 2 Sebastian Zarnekow CLA 2011-01-25 03:09:25 EST
Pushed to master.
Comment 3 Mark Christiaens CLA 2011-03-23 11:52:15 EDT
I think this bug needs a little more work.  When I do two consecutive imports that are identical except for the capitalization of the importedNamespacePrefix then the resulting ImportScopes are different.  That in turn results in linking warnings.  The culprit is:

@Override
	public boolean equals(Object obj) {
		if (this==obj)
			return true;
		if (obj==null)
			return false;
		if (obj instanceof ImportNormalizer) {
			ImportNormalizer other = (ImportNormalizer)obj;
			//TODO not ignore case aware
			return other.hasWildCard==hasWildCard &&
				other.ignoreCase==ignoreCase &&
				other.importedNamespacePrefix.equals(importedNamespacePrefix);
		}
		return false;
	}

The final "equals" should convert both the importedNamespacePrefixes to lower or upper case while comparing when dealing with case-insensitive imports.
Comment 4 Sebastian Zarnekow CLA 2011-03-29 08:17:32 EDT
Pushed to master
Comment 5 Karsten Thoms CLA 2017-09-19 17:20:13 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 6 Karsten Thoms CLA 2017-09-19 17:31:37 EDT
Closing all bugs that were set to RESOLVED before Neon.0