Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to check type hierarchy of a Java Class ?(Validation of query hierarchy for EMF Facet project)
How to check type hierarchy of a Java Class ? [message #684260] Wed, 15 June 2011 06:00 Go to next message
Nicolas Guyomar is currently offline Nicolas Guyomar
Messages: 29
Registered: February 2010
Location: Nantes (France)
Junior Member
Hi,

I'm trying to implement the builder validation process for EMF Facet project.

We need the EMF Facet query to implement IJavaModelQuery interface.
Until now, our builder was checking that the query class was directly implementing this interface.

Using:
IType type = myJavaProject.findType(query.getImplementationClassName());
String[] superInterfaceTypeSignatures = type.getSuperInterfaceTypeSignatures();
for (String superInterfaceTypeSignature : superInterfaceTypeSignatures) {
   String typeErasure = Signature.getTypeErasure(superInterfaceTypeSignature);
   String implementedInterface = Signature.getSignatureSimpleName(typeErasure);
}

I was able to check that implementedInterface contains 'IJavaModelQuery ' String

The 'IJavaModelQuery' might also be implemented by the query superClass.
So this is what I try :
 IType type = myJavaProject.findType(query.getImplementationClassName());
// SuperClass resolution
String[][] resolutionResult = type.resolveType(type.getSuperclassName());

String superClassName = Signature.toQualifiedName(resolutionResult[0]);
IType superClassType = myJavaProject.findType(superClassName);


This piece of code works as long as my hierarchy is simple.
ClassA extends ClassB
ClassB implements IJavaModelQuery


As soon as I add a hierarchy level, 'resolutionResult ' is null when I try to resolve ClassC from ClassB, but I can't figure out why
ClassA extends ClassB
ClassB extends ClassC
ClassC implements IJavaModelQuery


Is there an easiest way to check a class hierarchy ?
Does someone know why the class resolution is not working for ClassC ?

Regards,
Nicolas Guyomar


icon14.gif  Re: How to check type hierarchy of a Java Class ? [message #684367 is a reply to message #684260] Wed, 15 June 2011 09:46 Go to previous messageGo to next message
Nicolas Guyomar is currently offline Nicolas Guyomar
Messages: 29
Registered: February 2010
Location: Nantes (France)
Junior Member
Ok .... My mistake, ClassC was not resolved because I forgot to copy the class in the junit workspace ...

I would still really like to find an easiest way to check a class hierarchy, but this thread is resolved.

Nicolas


Re: How to check type hierarchy of a Java Class ? [message #684750 is a reply to message #684367] Thu, 16 June 2011 03:10 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam Kandula
Messages: 444
Registered: July 2009
Senior Member
IType.newSupertypeHierarchy().getAllSuperTypes() could help you.
Re: How to check type hierarchy of a Java Class ? [message #684766 is a reply to message #684750] Thu, 16 June 2011 03:56 Go to previous message
Nicolas Guyomar is currently offline Nicolas Guyomar
Messages: 29
Registered: February 2010
Location: Nantes (France)
Junior Member
Thank you Satyam, that's exactly what I was looking for.

Previous Topic:How to stop comments from collapsing with function
Next Topic:merge or change workspace
Goto Forum:
  


Current Time: Wed Aug 20 22:42:12 EDT 2014

Powered by FUDForum. Page generated in 0.01930 seconds