Bug 29601

Summary: TypeHierarchy: Avoid to use 'isInterface' / 'isClass'
Product: [Eclipse Project] JDT Reporter: Martin Aeschlimann <martinae>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.1   
Target Milestone: 2.1 M5   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Martin Aeschlimann CLA 2003-01-16 04:06:32 EST
20030115

The type hierarchy offers the method getFlags(IType) where it can be tested if 
a type is an interface or class. (Flags.isInterface). This API was added to 
allow us to get information about the type without creating an element info.

While debugging I saw that the implementation code in TypeHierarchy uses 
type.isInterface (throwing a JavaModelException):
public IType getSuperclass(IType type) {
	try {
		if (type.isInterface()) {
			return null;
		}
		return (IType) this.classToSuperclass.get(type);

	} catch (JavaModelException npe) {
		return null;
	}
}
Is this intended? Wouldn't it be possible to use the cached information to 
avoid the creation of the type info?
Comment 1 Philipe Mulet CLA 2003-01-16 04:23:05 EST
Indeed. Good find.
Comment 2 Jerome Lanneluc CLA 2003-01-20 05:35:59 EST
Changed all references in TypeHiearchy to use getCacheFlags(...) (when a type 
is cached) instead of isInterface()/isClass(). 
Comment 3 David Audel CLA 2003-02-10 10:32:44 EST
Verified.