Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Comments preventing AST node deletion
Comments preventing AST node deletion [message #258395] Thu, 29 January 2009 20:12 Go to next message
Eclipse UserFriend
Hi Everyone,

This would be my first foray into jdt coding, so there might be an
obvious solution to this that I am missing.

I have an ASTVisitor that tries to look for a certain method declaration
and deletes it, the code is pretty straightforward:

@Override
public boolean visit(MethodDeclaration node) {

if (node.getName().getFullyQualifiedName().equals("getConfigLocations ")) {
node.delete();
}
return true;

}

This works perfectly if the method is structured as follows:

@Override
protected String[] getConfigLocations() {
return new String[] { "spring/testContext.xml" };
}


However, if the method contains a comment, a very weird thing happens,
the method gets deleted up to only the comment section, so for this method:

@Override
protected String[] getConfigLocations() {
//Test Comment
return new String[] { "spring/testContext.xml" };
}

The following gets left behind in the resulting source:

//Test Comment
return new String[] { "spring/testContext.xml" };
}

Am I missing something here?

I am on eclipse Ganymede latest version and I am using the following
rewriting code at the end:

TextEdit edit = astRoot.rewrite(document,
type.getCompilationUnit().getJavaProject().getOptions(true)) ;
edit.apply(document);

Any help would be greatly appreciated.

Thanks.
Re: Comments preventing AST node deletion [message #258401 is a reply to message #258395] Fri, 30 January 2009 18:08 Go to previous message
Eclipse UserFriend
Muhammad Yahia a écrit :
> However, if the method contains a comment, a very weird thing happens,
> the method gets deleted up to only the comment section, so for this method:
Please open a bug report against JDT/Core with steps to reproduce.
This looks like a bug and deserves more investigations.
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT

Thanks.
--
Olivier
Previous Topic:Autocorrecting to Greek
Next Topic:inclusion and exclusion pattern resolutions
Goto Forum:
  


Current Time: Mon Apr 28 12:53:09 EDT 2025

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

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

Back to the top