Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Add Interface Type to Class type
icon3.gif  Add Interface Type to Class type [message #831154] Wed, 28 March 2012 14:45 Go to next message
Bernd Meyer is currently offline Bernd MeyerFriend
Messages: 2
Registered: March 2012
Junior Member
I want to create an Eclipse plugin which programmatically extends a set of classes through an Interface. For example, I want to make the class A:

class A {
 // some code here
}


look like this
class A implements AnInterface {
 // some code here
}


I got the IType and ICompilationUnit of all classes I want to extend with an interface but how do I do it? (There are only methods available in IType which let you create fields and other methods..)

Very much thanks in advance to whoever can help me here Smile
Bernd
Re: Add Interface Type to Class type [message #831884 is a reply to message #831154] Thu, 29 March 2012 13:36 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
Creation of code using IType/ICompilationUnit and its methods are good if you have the complete code as part of string. If you look at ICompilation#CreateType(..), it takes the full contents of the class. You could either use this in your case or use ASTRewrite.
Re: Add Interface Type to Class type [message #832002 is a reply to message #831884] Thu, 29 March 2012 16:18 Go to previous messageGo to next message
Bernd Meyer is currently offline Bernd MeyerFriend
Messages: 2
Registered: March 2012
Junior Member
Thanks, I use AST now and it works just fine Smile
Re: Add Interface Type to Class type [message #1005535 is a reply to message #832002] Sat, 26 January 2013 08:51 Go to previous message
standfox will is currently offline standfox willFriend
Messages: 1
Registered: January 2013
Junior Member
hi,could you tell me how you solved this problem?
Previous Topic:Adding variables to Java editor templates?
Next Topic:Eclipse 4.2.1 - can't import classes after some time
Goto Forum:
  


Current Time: Tue Apr 16 12:56:52 GMT 2024

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

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

Back to the top