Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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: Sun Jul 20 17:18:44 EDT 2025

Powered by FUDForum. Page generated in 0.03869 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top