use of org.eclipse.xtext.xbase.ui.document.DocumentRewriter.Section in project xtext-xtend by eclipse.
the class ExtractMethodRefactoring method checkFinalConditions.
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
StatusWrapper status = statusProvider.get();
try {
status.merge(validateMethodName(methodName));
status.merge(validateParameters());
ITextRegion expressionsRegion = getExpressionsRegion();
ITextRegion predecessorRegion = locationInFileProvider.getFullTextRegion(originalMethod);
if (pm.isCanceled()) {
throw new OperationCanceledException();
}
Section expressionSection = rewriter.newSection(expressionsRegion.getOffset(), expressionsRegion.getLength());
Section declarationSection = rewriter.newSection(predecessorRegion.getOffset() + predecessorRegion.getLength(), 0);
createMethodCallEdit(expressionSection, expressionsRegion);
if (pm.isCanceled()) {
throw new OperationCanceledException();
}
createMethodDeclarationEdit(declarationSection, expressionSection.getBaseIndentLevel(), expressionsRegion);
if (pm.isCanceled()) {
throw new OperationCanceledException();
}
textEdit = replaceConverter.convertToTextEdit(rewriter.getChanges());
} catch (OperationCanceledException e) {
throw e;
} catch (Exception exc) {
handleException(exc, status);
}
return status.getRefactoringStatus();
}
Aggregations