Search in sources :

Example 1 with RefactoringRpcMessage

use of org.erlide.wrangler.refactoring.backend.internal.RefactoringRpcMessage in project erlide_eclipse by erlang.

the class IntroduceLetRefactoring method getWorkflowController.

@Override
public RefactoringWorkflowController getWorkflowController(final Shell shell) {
    return new RefactoringWorkflowController(shell) {

        @Override
        public void doRefactoring() {
            final IErlSelection sel = GlobalParameters.getWranglerSelection();
            RefactoringRpcMessage message = (RefactoringRpcMessage) run(sel);
            if (message.isSuccessful()) {
                changedFiles = message.getRefactoringChangeset();
                status = new RefactoringStatus();
            } else if (message.getRefactoringState() == RefactoringState.QUESTION) {
                if (ask("Question", message.getMessageString())) {
                    final OtpErlangTuple res = message.getResultObject();
                    expr = ((OtpErlangTuple) res.elementAt(2)).elementAt(0);
                    parentExpr = ((OtpErlangTuple) res.elementAt(2)).elementAt(1);
                    message = (RefactoringRpcMessage) runAlternative(sel);
                    if (message.isSuccessful()) {
                        status = new RefactoringStatus();
                        changedFiles = message.getRefactoringChangeset();
                    } else {
                        status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
                    }
                } else {
                    status = RefactoringStatus.createFatalErrorStatus("Refactoring failed: the expression selected is not a QuickCheck generator.");
                }
            } else if (message.getRefactoringState() == RefactoringState.ERROR) {
                status = RefactoringStatus.createFatalErrorStatus(message.getMessageString());
            }
        }
    };
}
Also used : RefactoringWorkflowController(org.erlide.wrangler.refactoring.core.RefactoringWorkflowController) IRefactoringRpcMessage(org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage) RefactoringRpcMessage(org.erlide.wrangler.refactoring.backend.internal.RefactoringRpcMessage) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Aggregations

OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)1 IRefactoringRpcMessage (org.erlide.wrangler.refactoring.backend.IRefactoringRpcMessage)1 RefactoringRpcMessage (org.erlide.wrangler.refactoring.backend.internal.RefactoringRpcMessage)1 RefactoringWorkflowController (org.erlide.wrangler.refactoring.core.RefactoringWorkflowController)1 IErlSelection (org.erlide.wrangler.refactoring.selection.IErlSelection)1