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 10:45 Go to next message
Bernd Meyer is currently offline Bernd Meyer
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 09:36 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam Kandula
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 12:18 Go to previous messageGo to next message
Bernd Meyer is currently offline Bernd Meyer
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 03:51 Go to previous message
standfox will is currently offline standfox will
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: Wed Jul 30 05:04:53 EDT 2014

Powered by FUDForum. Page generated in 0.09428 seconds