Comments preventing AST node deletion [message #258395] |
Thu, 29 January 2009 20:12  |
Eclipse User |
|
|
|
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.
|
|
|
|
Powered by
FUDForum. Page generated in 10.69414 seconds