Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to get (or set) what a class extends?
How to get (or set) what a class extends? [message #1265713] Thu, 06 March 2014 13:07 Go to next message
Christer Jansson is currently offline Christer JanssonFriend
Messages: 1
Registered: March 2014
Junior Member

I'd like my refactoring application to get what a class extends. I've succeeded to get the proper ICompilationUnit and I can list all the methods. Now I'd like to see if the class extends something. I can't find a getter for that so how can this be done?

I also would like to refactor the class so it extends with a specific class. How can I do this?

Best Regards,

Refactor from:
public class OriginTestClass extends BeforeChange {

public class OriginTestClass extends TestAfterChange, BeforeChange {
Re: How to get (or set) what a class extends? [message #1273000 is a reply to message #1265713] Wed, 19 March 2014 09:26 Go to previous messageGo to next message
shankha banerjee is currently offline shankha banerjeeFriend
Messages: 40
Registered: February 2013
Is it possible for you to get the type of the class and get it's superclass.
Re: How to get (or set) what a class extends? [message #1369889 is a reply to message #1273000] Tue, 20 May 2014 19:46 Go to previous message
Noopur Gupta is currently offline Noopur GuptaFriend
Messages: 34
Registered: December 2012
Location: Bangalore, India
- A class cannot extend more than one class in Java. So, your expected result is not valid.

- To get the hierarchy of a type, first get that Type using ICompilationUnit#getAllTypes().
Then use the APIs IType#getSuperclass* and IType#getSuperInterface*s.
Previous Topic:How to use default and static methods on interfaces w Eclipse Kepler / JDK 8?
Next Topic:@Nullable field annotations when backporting to Eclipse 3.8
Goto Forum:

Current Time: Tue Mar 28 23:53:07 GMT 2017

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

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