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

Perfect!

Through the IType I was able to get all the superclasses with a call to
iType.newSuperclassHierarchy().  By looping through the ITypeHierarchy I
was able to determine if the underlying Java file represented by the
ICompilationUnit was a subclass of a particular class.  I was then able to
selectively display the types I wanted.

Thanks,
-Phil



                                                                                           
                    Timothy Halloran                                                       
                    <thallora@xxxxxxxx        To:     jdt-dev@xxxxxxxxxxx                  
                    I.CMU.EDU>                cc:                                          
                    Sent by:                  Subject:     Re: [jdt-dev] Displaying only   
                    jdt-dev-admin@ecli        certain types                                
                    pse.org                                                                
                                                                                           
                                                                                           
                    08/14/2002 12:19                                                       
                    PM                                                                     
                    Please respond to                                                      
                    jdt-dev                                                                
                                                                                           
                                                                                           




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
>

_______________________________________________
jdt-dev mailing list
jdt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/jdt-dev






Back to the top