Refactoring: right way? [message #124434] |
Thu, 04 December 2003 08:12  |
Eclipse User |
|
|
|
Originally posted by: scheglov_ke.nlmk.ru
I write some new refactoring, it should create new CompilationUnit and
also change existing CompilationUnit. How to implement these functions in
right way? Give me please just short scenario and/or class names to use.
Currently I use CreateTextFileChange, generate unformated source code and
format it using following code:
return CodeFormatterUtil.format(CodeFormatter.K_CLASS_BODY_DECLARAT IONS,
src, 0, null, getLineSeperator(), null);
But I feel that this is not very good method.
Also for changing CU I am going to use CompilationUnitChange and then
create several TextEdit's. But I see that there are also class ASTRewrite
that is used in many refactorings, so not sure that I am going to use
best method.
--
SY, Konstantin.
Advanced Eclipse SWT Designer (http://www.swt-designer.com)
|
|
|
Re: Refactoring: right way? [message #124674 is a reply to message #124434] |
Thu, 04 December 2003 18:05   |
Eclipse User |
|
|
|
Konstantin,
I recommend that you use the ASTRewrite to perform changes on the
compilation unit.
A rewirte creates edits which can then be attached to the
CompilationUnitChange. The
rewriter is aware of changing Java code. So it helps you dealing with
comments, formatting
and so on. If you use text edits directly you are on your own...
Regards
Dirk
"Konstantin Scheglov" <scheglov_ke@nlmk.ru> wrote in message
news:B33x5gmuDHA.3348@fairy.ao.nlmk...
> I write some new refactoring, it should create new CompilationUnit and
> also change existing CompilationUnit. How to implement these functions in
> right way? Give me please just short scenario and/or class names to use.
>
> Currently I use CreateTextFileChange, generate unformated source code
and
> format it using following code:
> return CodeFormatterUtil.format(CodeFormatter.K_CLASS_BODY_DECLARAT IONS,
> src, 0, null, getLineSeperator(), null);
> But I feel that this is not very good method.
>
> Also for changing CU I am going to use CompilationUnitChange and then
> create several TextEdit's. But I see that there are also class ASTRewrite
> that is used in many refactorings, so not sure that I am going to use
> best method.
>
> --
> SY, Konstantin.
> Advanced Eclipse SWT Designer (http://www.swt-designer.com)
|
|
|
Re: Refactoring: right way? [message #124759 is a reply to message #124674] |
Thu, 04 December 2003 23:30  |
Eclipse User |
|
|
|
Originally posted by: scheglov_ke.nlmk.ru
"Dirk BДumer" <dirk_baeumer@ch.ibm.com> wrote:
Thank you.
> I recommend that you use the ASTRewrite to perform changes on the
> compilation unit.
> A rewirte creates edits which can then be attached to the
> CompilationUnitChange. The
> rewriter is aware of changing Java code. So it helps you dealing with
> comments, formatting
> and so on. If you use text edits directly you are on your own...
> Regards
> Dirk
> "Konstantin Scheglov" <scheglov_ke@nlmk.ru> wrote in message
> news:B33x5gmuDHA.3348@fairy.ao.nlmk...
>> I write some new refactoring, it should create new CompilationUnit and
>> also change existing CompilationUnit. How to implement these functions in
>> right way? Give me please just short scenario and/or class names to use.
>>
>> Currently I use CreateTextFileChange, generate unformated source code
> and
>> format it using following code:
>> return CodeFormatterUtil.format(CodeFormatter.K_CLASS_BODY_DECLARAT IONS,
>> src, 0, null, getLineSeperator(), null);
>> But I feel that this is not very good method.
>>
>> Also for changing CU I am going to use CompilationUnitChange and then
>> create several TextEdit's. But I see that there are also class ASTRewrite
>> that is used in many refactorings, so not sure that I am going to use
>> best method.
>>
>> --
>> SY, Konstantin.
>> Advanced Eclipse SWT Designer (http://www.swt-designer.com)
--
SY, Konstantin.
Advanced Eclipse SWT Designer (http://www.swt-designer.com)
|
|
|
Powered by
FUDForum. Page generated in 0.04693 seconds