Bug 72179

Summary: IJavaProject.findType(..) does not work as expected ...
Product: [Eclipse Project] JDT Reporter: Vikas Trivedi <vtrivedi>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: major    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Vikas Trivedi CLA 2004-08-18 12:25:32 EDT
I have a Java Project "jp1" which contains a package "p1".
p1 contains a single java file jc.java.
The contents of jc.java ...

package p1;

class jc008 {
}

class jc009 {
}

class jc010 extends jc009 {
	jc008 a;
}

While wokring with jc010 I am trying to obtain the SourceType associated with 
jc009. However calling IJavaProject.findType("p1", "jc009") returns null. I am 
able to search (Ctrl+Shift+T) jc009 and browse to it etc.

If all the above classes are defined in separate java files (jc008 in 
jc008.java, jc009 in jc009.java and jc010 in jc010.java) then I do not have 
this problem. IJavaProject.findType(..) returns the correct SourceType.

It should do the same if all classes are defined in the same java file.
Comment 1 Kent Johnson CLA 2004-08-18 13:13:15 EDT
Directly from the spec of findType():

"Note that in order to be found, a type name (or its toplevel enclosing type 
name) must match its corresponding compilation unit name. As a consequence, 
secondary types cannot be found using this functionality. Secondary types can 
however be explicitely accessed through their enclosing unit or found by the 
<code>SearchEngine</code>."

*** This bug has been marked as a duplicate of 36032 ***