Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Java code manipulation
Java code manipulation [message #78876] Tue, 22 July 2003 21:52 Go to next message
Eclipse UserFriend
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 #79034 is a reply to message #78876] Wed, 23 July 2003 05:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: adam_kiezun.ch.ibm.remove.com

you can modify the AST and then pretty print it
we (jdt ui) use ASTRewrite and ASTFlattener to do that (don'y use these classes directly, however - they're internal).

a.
--
eclipse.org
Re: Java code manipulation [message #80814 is a reply to message #79034] Mon, 28 July 2003 10:38 Go to previous messageGo to next message
Eclipse UserFriend
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?

thanks
vijay

"Adam Kiezun" <adam_kiezun@ch.ibm.remove.com> wrote in message
news:bflitt$ejk$1@eclipse.org...
> you can modify the AST and then pretty print it
> we (jdt ui) use ASTRewrite and ASTFlattener to do that (don'y use these
classes directly, however - they're internal).
>
> a.
> --
> eclipse.org
>
>
Re: Java code manipulation [message #81182 is a reply to message #80814] Tue, 29 July 2003 02:51 Go to previous message
Eclipse UserFriend
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.
Previous Topic:export jars
Next Topic:Class File Viewer- classpath problem
Goto Forum:
  


Current Time: Sun May 11 03:15:08 EDT 2025

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

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

Back to the top