use of org.erlide.wrangler.refactoring.selection.IErlSelection in project erlide_eclipse by erlang.
the class MergeForAllRefactoring method checkFinalConditions.
@Override
public RefactoringStatus checkFinalConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
final IErlSelection sel = GlobalParameters.getWranglerSelection();
final IRefactoringRpcMessage message = run(sel);
if (message.isSuccessful()) {
changedFiles = message.getRefactoringChangeset();
return new RefactoringStatus();
}
return RefactoringStatus.createFatalErrorStatus(message.getMessageString());
}
use of org.erlide.wrangler.refactoring.selection.IErlSelection in project erlide_eclipse by erlang.
the class MoveFunctionRefactoring method checkFinalConditions.
@Override
public RefactoringStatus checkFinalConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
final IErlSelection sel = GlobalParameters.getWranglerSelection();
IRefactoringRpcMessage message = run(sel);
if (message.isSuccessful()) {
changedFiles = message.getRefactoringChangeset();
return new RefactoringStatus();
} else if (message.getRefactoringState() == RefactoringState.QUESTION) {
message = run2(sel);
if (message.isSuccessful()) {
changedFiles = message.getRefactoringChangeset();
return new RefactoringStatus();
}
return RefactoringStatus.createFatalErrorStatus(message.getMessageString());
} else {
return RefactoringStatus.createFatalErrorStatus(message.getMessageString());
}
}
use of org.erlide.wrangler.refactoring.selection.IErlSelection in project erlide_eclipse by erlang.
the class ProcessRelatedRefactoring method checkFinalConditions.
@Override
public RefactoringStatus checkFinalConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
final IErlSelection sel = GlobalParameters.getWranglerSelection();
final ProcessRpcMessage msg = checkUndecidables((IErlMemberSelection) sel);
if (msg.isSuccessful()) {
changedFiles = msg.getRefactoringChangeset();
return new RefactoringStatus();
} else if (msg.hasUndecidables()) {
undecidables = msg.getMessageString();
final IRefactoringRpcMessage message = run(sel);
changedFiles = message.getRefactoringChangeset();
return RefactoringStatus.createWarningStatus(getUndecidableWarningMessage());
} else {
return RefactoringStatus.createFatalErrorStatus(msg.getMessageString());
}
}
use of org.erlide.wrangler.refactoring.selection.IErlSelection in project erlide_eclipse by erlang.
the class ExtractFunctionRefactoring method getWorkflowController.
@Override
public RefactoringWorkflowController getWorkflowController(final Shell shell) {
return new RefactoringWorkflowController(shell) {
@Override
public void doRefactoring() {
final IErlSelection sel = GlobalParameters.getWranglerSelection();
IRefactoringRpcMessage message = run(sel);
if (message.isSuccessful()) {
changedFiles = message.getRefactoringChangeset();
status = new RefactoringStatus();
} else if (message.getRefactoringState() == RefactoringState.WARNING) {
final boolean answer = !ask("Warning", message.getMessageString());
if (answer) {
message = runAlternative(sel);
if (message.getRefactoringState() == RefactoringState.OK) {
status = new RefactoringStatus();
} else {
status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
}
} else {
stop();
}
} else {
status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
}
}
};
}
use of org.erlide.wrangler.refactoring.selection.IErlSelection in project erlide_eclipse by erlang.
the class FoldLocalExpressionRefactoring method checkInitialConditions.
/**
* Preprocessing the file(s), and finding the candidates to fold.
*/
@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
final IErlSelection selection = GlobalParameters.getWranglerSelection();
if (!(selection instanceof IErlMemberSelection && (selection.getKind() == SelectionKind.FUNCTION || selection.getKind() == SelectionKind.FUNCTION_CLAUSE))) {
return RefactoringStatus.createFatalErrorStatus("Please select an expression!");
}
final IErlMemberSelection sel = (IErlMemberSelection) selection;
ExpressionPosRpcMessage m = new ExpressionPosRpcMessage();
m = (ExpressionPosRpcMessage) WranglerBackendManager.getRefactoringBackend().callWithParser(m, "fold_expr_by_loc_eclipse", "siixi", sel.getFilePath(), sel.getMemberRange().getStartLine(), sel.getMemberRange().getStartCol(), sel.getSearchPath(), GlobalParameters.getTabWidth());
if (m.isSuccessful()) {
syntaxTree = m.getSyntaxTree();
positions = m.getPositionDefinitions(sel.getDocument());
selectedPositions = new ArrayList<>();
} else {
return RefactoringStatus.createFatalErrorStatus(m.getMessageString());
}
return new RefactoringStatus();
}
Aggregations