Hi at all!
I'm trying to replace astNodes from different compilationUnits. By doing that, I cannot resolve the types from a replaced astNode.
An Example:
Button b1; //NodeToBeReplaced --> org.eclipse.swt.widgets.Button
should be replaced by:
Button b = new Button(null, 1); //replaceNode --> org.eclipse.swt.widgets.Button
For that, I use the astParser construct to get the astNodes I seek for. For these nodes I'm able to resolve the types (to get org.eclipse.swt.widgets.Button)
Now if I'm trying to replace the node (within a block), the types will not be resolved.
My replacing works like that:
Block parent = (Block) NodeToBeReplaced.getParent();
ASTNode astNodeCopied = ASTNode.copySubtree(NodeToBeReplaced.getAst(), replaceNode);
parent.statements().set(0, astNodeCopied);
The astNode astNodeCopied is not able to resolve the type.
((VariableDeclarationStatement) astNodeCopied).getType().resolveType();
leads to null.
Do you have a hint, how to realize this issue?
Best regards,
Andreas
[Updated on: Fri, 13 May 2011 10:49]
Report message to a moderator