Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » get information about TextEdit
get information about TextEdit [message #259289] Thu, 02 April 2009 03:09 Go to next message
Liming Zhao is currently offline Liming ZhaoFriend
Messages: 9
Registered: July 2009
Junior Member
can I get the number of changed lines of code, names of changed method
from a TextEdit (resulted from a refactoring, for example) before the
refactoring taking
place (preview)?

Any suggestions? Thanks in advance.
Re: get information about TextEdit [message #259407 is a reply to message #259289] Tue, 07 April 2009 14:31 Go to previous messageGo to next message
Markus KellerFriend
Messages: 294
Registered: July 2009
Senior Member
On 2009-04-02 05:09, Leon Zhao wrote:
> can I get the number of changed lines of code, names of changed method
> from a TextEdit (resulted from a refactoring, for example) before the
> refactoring taking place (preview)?

Not directly. You would have to apply the TextEdit on a copy of the
original document and then do the comparison yourself.

Markus
Re: get information about TextEdit [message #259541 is a reply to message #259407] Tue, 14 April 2009 00:05 Go to previous message
Liming Zhao is currently offline Liming ZhaoFriend
Messages: 9
Registered: July 2009
Junior Member
Yeah. Thanks.

It seems not easy to do the comparison.

Assume a MultiTextEdit has multiple children edit - which edit happens
first - the first in list? when three edits (delete and inserts) happens
on the same line
- this looks complicated.

I am trying to work out a CustomEditVisitor to do it but need to figure
out how these edits work exactly first.For example for an insert Edit, my
thought is
public boolean visit(InsertEdit edit) {
int offset = edit.getOffset();
int length = edit.getLength();

try {
int offsetLine = document.getLineOfOffset(edit.getOffset());
int lengthLine = document.computeNumberOfLines(edit.getText());

String content = edit.getText();
setFSizeLine(getFSizeLine() + lengthLine);

} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


return false; //super.visit(edit);
}

Below is an Edit I got from an indirection refactoring on a toy program

{MultiTextEdit} [568, 603] [undefined]
{MultiTextEdit} [568, 603]
{InsertEdit} [568,0]<<Person.debug(
{MoveTargetEdit} [568,0]
{InsertEdit} <<)
{DeleteEdit} [568,41]
{DeleteEdit} [583,25]
{MoveSourceEdit} [583,25]
{InsertEdit} [1130,0] <<Person.debug(
{MoveTargetEdit} [1130,0]
{InsertEdit} [1130,0] <<)
{DeleteEdit} [1130,41]
{DeleteEdit} [1145,25]
{MoveSourceEdit} [1145,25]

can you give any help? Thanks a lot.


Liming
Previous Topic:Getting ITypeBinding from a fully qualified class name. Is it possible?
Next Topic:Generating a javadoc comment programmatically
Goto Forum:
  


Current Time: Thu Sep 26 23:06:52 GMT 2024

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

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

Back to the top