IFile file = getFile(info.getAtgEditor());
TextFileChange textFileChange = new TextFileChange( file.getName(), file );
rootChange.add(textFileChange);
//a file change contains a tree of edits, first add the root of them
final MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
textFileChange.setEdit(fileChangeRootEdit);
AtgAstVisitor renameCharacterVisitor = new AtgAstVisitor() {
@Override
public boolean visit(AbstractAtgAstNode node) {
if (node instanceof ProductionNode && // production node
(globalReformat() || localSelection(node) || localCursorPos(node)))
{
ProductionNode productionNode = (ProductionNode) node;
IEditorInput editorInput = info.getAtgEditor().getEditorInput();
IDocumentProvider documentProvider = info.getAtgEditor().getDocumentProvider();
IDocument document = documentProvider.getDocument(editorInput);
String production = null;
try {
production = document.get(
productionNode.getRegion().getOffset(),
productionNode.getRegion().getLength());
try {
ATGProductionReformatter atgProductionReformatter = new ATGProductionReformatter(document, productionNode, info);
production = atgProductionReformatter.reformat();
ReplaceEdit edit = new ReplaceEdit(
productionNode.getRegion().getOffset(),
productionNode.getRegion().getLength(),
production);
fileChangeRootEdit.addChild(edit);
} catch (Exception e) {
e.printStackTrace();
}
} catch (BadLocationException e) {
e.printStackTrace();