Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] AST: replace ICPPASTBaseSpecifier


I'm desperately trying to replace base specifiers using an ASTRewrite
within a refactoring to insert the 'virtual' keyword which seems not to
work. I guess the simplest approach would be:

final TextEditGroup editGroup = new TextEditGroup("bla");
final ICPPASTBaseSpecifier baseSpec = //get specifier to replace ...
final IASTTranslationUnit ast = baseSpec.getTranslationUnit();
final ASTRewrite rewrite = collector.rewriterForTranslationUnit(ast);

final ICPPASTBaseSpecifier copy = baseSpec.copy();
rewrite.replace(baseSpec, copy, editGroup);

This produces no text change. Also copying the parent of the base
specifier (which then is an ICPPASTCompositeTypeSpecifier), replacing
the base specifier within the array returned by getBaseSpecifiers() and
then replacing the whole class with its modified copy using the
ASTRewrite does not yield any changes. The same applies for changing the
visibility of base specifiers. Only thing that worked for me was
replacing the specifier's name.

Any suggestions on what I'm missing out here?


Back to the top