Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Applying Multiple Changes with Refactoring

Hi I've created and been working on a subclass of CRefactoring. Unfortunately
I can't seem to have multiple changes, with only one change (the prototype
declaration insertion) showing up on the preview screen and being applied. 

The others don't show up in the preview and neither are they applied.
Somehow this only seems to happen when I insert the prototype declaration
using ASTRewrite.insertBefore. I've been trying for quite awhile now to work
out why it's breaking the refactoring. Here's the code I have for
collectModifications:

	@Override
	protected void collectModifications(IProgressMonitor pm,
		ModificationCollector collector) throws CoreException,
		OperationCanceledException {
		// TODO Auto-generated method stub
		
		ASTRewrite rewrite =
collector.rewriterForTranslationUnit(definitionToStatic.getTranslationUnit());
		
		IASTSimpleDeclSpecifier changedSpecifier =
changeDeclSpecifierStatic(definitionToStatic, collector);
		rewrite.replace(definitionToStatic.getDeclSpecifier(), 
						changedSpecifier, 
						new TextEditGroup("Changed function definition to static"));
		
		if (declToRemove != null) {
			rewrite.remove(declToRemove, new TextEditGroup("Function declaration
removed"));
		}
		
		IASTSimpleDeclaration prototype = createLocalPrototype(definitionToStatic,
collector);
	
		rewrite.insertBefore(definitionToStatic.getTranslationUnit(), 
					
TranslationUnitHelper.getFirstNode(definitionToStatic.getTranslationUnit()), 
						prototype, 
						new TextEditGroup("Function prototype added"));
	}
-- 
View this message in context: http://www.nabble.com/Applying-Multiple-Changes-with-Refactoring-tp17420423p17420423.html
Sent from the Eclipse CDT - Development mailing list archive at Nabble.com.



Back to the top