Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-dev] Displaying only certain types

Are you talking about the actual class of the ICompilationUnit or the
public class/interface that is within the source code file the
ICompilationUnit refers too??

I suspect the latter, really this is complicated by files declaring more
than a single class (or interface) and nested classes.  In the most
general case, you probably need to generate the CompilationUnit and go
through the ASTNodes, but try this:

Say your ICompilationUnit is javaFile:

   IType[] declaredTypes = javaFile.getAllTypes();

Now you have the types declared in the file (look at the JavaDoc for
IType) and can examine the superclass or interface hierarchy for each of
the IType's you found in the ICompilationUnit via getSuperclassName() or
getSuperInterfaceNames() -- the problem is these may not be qualified to
the level you might expect (read the JavaDoc carefully here).

If you care about nested classes you need to go through each IType's
getTypes() list of IType(s).

I've never tried this..I usually use CompilationUnit(s) with binding,
but then the software actually has to build...Good luck

Tim Halloran
Carnegie Mellon University
On Wed, 2002-08-14 at 12:28, philipborlin@xxxxxxxxxxxxxxxxxxxxx wrote:
> I am trying to write a specialized IViewPart that only displays certain
> classes in a proprietory internal company framework.  I am using a
> TreeViewer and have created a custom ITreeContentProvider.  In my
> getChildren(Object parent) method I have recursed through the various units
> and am correctly displaying ICompilationsUnits as desired.
> 
> What I want to be able to do is to only display an ICompilationUnit if it
> is a subclass of one of our framework's baseclasses.  I was wondering if
> anyone knew the best way to figure out the class name of a particular
> ICompilationUnit.
> 
> Thanks,
> -Phil
> 
> _______________________________________________
> jdt-dev mailing list
> jdt-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/jdt-dev
> 



Back to the top