Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 370862 - Bad code in org.eclipse.dltk.ui.ScriptElementLabels.appendTypeQualification
Summary: Bad code in org.eclipse.dltk.ui.ScriptElementLabels.appendTypeQualification
Status: NEW
Alias: None
Product: DLTK
Classification: Technology
Component: Common (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: dltk.common-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-07 13:17 EST by Bruno Medeiros CLA
Modified: 2012-02-07 13:17 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Medeiros CLA 2012-02-07 13:17:04 EST
It seems some bad Element Labels are being generated for types.
If there is a ClassA in moduleM in packageP in source folder "src", one would expect a sensible default element label to be:
"packageP.ModuleM.ClassA"
however what we get is:
"src ModuleM.ClassA"
The source folder name gets added instead of the package name. This is presented as a minor UI issue, but also a bigger issue as the default text selection in the DLTK Search page. The Search Page will use the element labels as the default text, so if you have ClassA selected in the editor, you will get "src ModuleM.ClassA" instead of "packageP.ModuleM.ClassA", which should be the default, probably.

It seems the problem is in
org.eclipse.dltk.ui.ScriptElementLabels.appendTypeQualification(IType, long, StringBuffer)
where probably the code should be something similar to this:

protected void appendTypeQualification(IType type, long flags, StringBuffer buf) {
	try {
		final INamespace namespace = type.getNamespace();
		if (namespace != null) {
			buf.append(namespace.getQualifiedName("."));
			if(!namespace.isRoot()) {
				buf.append(".");
			}
			return;
		}
	} catch (ModelException e) {
		// ignore
		return;
	}
	IScriptFolder pkg = type.getScriptFolder();
	
	getScriptFolderLabel(pkg, (flags & QUALIFIER_FLAGS), buf);
	buf.append(".");
}
This is easy to workaround as each language can provide their own ScriptElementLabels and fix the behavior above, but still it would be nice to have a better default.