Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Check if ITypes are assignable
Check if ITypes are assignable [message #763870] Sat, 10 December 2011 19:34 Go to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

I have ITypes (*A* and *B*) and need to find out if I can assign type
*B* on type *A*. How can i do this?

Tom
Re: Check if ITypes are assignable [message #764572 is a reply to message #763870] Mon, 12 December 2011 13:04 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
Two ways that I can think of:
1. Get the typehierarchy (IType->newSupertypeHierarchy() or IType->newTypeHierarchy()) and call the appropriate functions in the hierarchy to see if one is contained in another.
2. Get the bindings using ASTParser->CreateBindings() and call ITypeBinding->isAssignmentCompatible().
Re: Check if ITypes are assignable [message #764579 is a reply to message #764572] Mon, 12 December 2011 13:20 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 12.12.11 14:04, schrieb Satyam Kandula:
> Two ways that I can think of:
> 1. Get the typehierarchy (IType->newSupertypeHierarchy() or
> IType->newTypeHierarchy()) and call the appropriate functions in the
> hierarchy to see if one is contained in another. 2. Get the bindings
> using ASTParser->CreateBindings() and call
> ITypeBinding->isAssignmentCompatible().

Using the ASTParser was the solution i used until now but this is
extremly slow unless I used it inappropriately.

So I'll give solution 1 a try.

Tom
Re: Check if ITypes are assignable [message #764595 is a reply to message #764579] Mon, 12 December 2011 13:55 Go to previous message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
Using ASTParser#setIgnoreMethodBodies(true) could make it faster.
Previous Topic:Customize add unimplemented method in eclipse
Next Topic:Indigo
Goto Forum:
  


Current Time: Thu Apr 25 23:27:12 GMT 2024

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

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

Back to the top