Bug 29601 - TypeHierarchy: Avoid to use 'isInterface' / 'isClass'
Summary: TypeHierarchy: Avoid to use 'isInterface' / 'isClass'
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-16 04:06 EST by Martin Aeschlimann CLA
Modified: 2003-02-10 10:32 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 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.