Java code manipulation [message #78876] |
Tue, 22 July 2003 21:52  |
Eclipse User |
|
|
|
Hello,
I need to change the signature of existing methods (adding/removing
parameters, modifiers, exception, ...)
in a programatic way.
What is the advised way to do it?
I saw the AST, the Scanner and the JDom APIs but none of them seem to
support easily these kinds of modifications.
Thank you
Estelle
|
|
|
|
|
Re: Java code manipulation [message #81182 is a reply to message #80814] |
Tue, 29 July 2003 02:51  |
Eclipse User |
|
|
|
Originally posted by: scheglov_ke.nlmk.ru
Vijay <vijay@mindspring.com> wrote:
> Is it possible to preserve comment lines when reconstructing a java file
> from it's AST?
> Also, if you just want to change method signatures, can't you just use the
> jdt core APIs for it without having to deal directly with the AST?
You can use AST to find _place_ in source, where you need to make your
changes. Then get IBuffer and replace needed pieces directly in source:
ICompilationUnit wc = m_Method.getCompilationUnit();
IBuffer buffer = wc.getBuffer();
buffer.replace(start, oldLength, value);
--
SY, Konstantin.
|
|
|
Powered by
FUDForum. Page generated in 0.02822 seconds