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

Bug 126613

Summary: API request for class SourceType
Product: [Eclipse Project] JDT Reporter: Eugene Chan <ewchan>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED INVALID QA Contact:
Severity: blocker    
Priority: P3 CC: popescu
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Bug Depends on:    
Bug Blocks: 126587    

Description Eugene Chan CLA 2006-02-06 13:19:01 EST
Internal class org.eclipse.jdt.internal.core.SourceType is required in TPTP for  Source Opening Action. We would like to request that this be made public API.

Here is how it is used:
/**
	 * Returns the specified inner class from the given java element.
	 * 
	 * @param je the java element containing the inner class.
	 * @param innerClassType the inner class to get.
	 * @return an IType representing the inner class.
	 */
	private static IType getInnerType(IJavaElement je, InnerClassType innerClassType) {
		try {
			if (je instanceof SourceType) {
				SourceType type = (SourceType) je;
				if (type.isAnonymous() == innerClassType.isAnonymous()
						&& ((innerClassType.isAnonymous() && innerClassType.getAnonymousNumber() == type.getOccurrenceCount())
								|| (!innerClassType.isAnonymous() && type.getElementName().equals(innerClassType.getName()))))
					return type;
			}
			
			if (je instanceof IParent) {
				IParent parentElement = (IParent)je;
				IJavaElement[] children = parentElement.getChildren();
				
				for (int i = 0; i < children.length; i++) {
					IType result = getInnerType(children[i], innerClassType);
					if (result != null)
						return result;
				}
			}
		}
		catch (Exception e) {
			HyadesUIPlugin.logError(e);
		}
		return null;
	}

This is a blocking defect on TPTP.
Comment 1 Jerome Lanneluc CLA 2006-02-06 13:23:01 EST
*** Bug 126614 has been marked as a duplicate of this bug. ***
Comment 2 Jerome Lanneluc CLA 2006-02-06 13:25:04 EST
From this code snippet, you're using isAnonymous(), getOccurrenceCount() and getElementName() which are all available as existing APIs on IType or its super interfaces. Did I miss something ?
Comment 3 Eugene Chan CLA 2006-02-06 14:29:06 EST
Thanks for your comment, this bug is no longer valid.
Comment 4 Eugene Chan CLA 2007-06-21 10:48:41 EDT
close bug.