Search in sources :

Example 1 with ExpressionPosRpcMessage

use of org.erlide.wrangler.refactoring.backend.internal.ExpressionPosRpcMessage 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();
}
Also used : IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection) ExpressionPosRpcMessage(org.erlide.wrangler.refactoring.backend.internal.ExpressionPosRpcMessage)

Example 2 with ExpressionPosRpcMessage

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

the class FoldRemoteExpressionRefactoring method checkInitialConditions.

@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
    if (functionClause == null) {
        return RefactoringStatus.createFatalErrorStatus("No function clause was given!");
    }
    ExpressionPosRpcMessage m = new ExpressionPosRpcMessage();
    final String path = selection.getFilePath();
    final String moduleName = ErlangEngine.getInstance().getModelUtilService().getModule(functionClause).getModuleName();
    final String functionName = functionClause.getFunctionName();
    final int arity = functionClause.getArity();
    int clauseIndex = 1;
    if (!(functionClause instanceof IErlFunction)) {
        clauseIndex = Integer.valueOf(functionClause.getName().substring(1));
    }
    m = (ExpressionPosRpcMessage) WranglerBackendManager.getRefactoringBackend().callWithParser(m, "fold_expr_by_name_eclipse", "sssiixi", path, moduleName, functionName, arity, clauseIndex, selection.getSearchPath(), GlobalParameters.getTabWidth());
    if (m.isSuccessful()) {
        syntaxTree = m.getSyntaxTree();
        // TODO: store positions, selectedpositions
        positions = m.getPositionDefinitions(selection.getDocument());
        selectedPositions = new ArrayList<>();
    } else {
        return RefactoringStatus.createFatalErrorStatus(m.getMessageString());
    }
    return new RefactoringStatus();
}
Also used : IErlFunction(org.erlide.engine.model.erlang.IErlFunction) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) ExpressionPosRpcMessage(org.erlide.wrangler.refactoring.backend.internal.ExpressionPosRpcMessage)

Example 3 with ExpressionPosRpcMessage

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

the class FoldAgainstMacro method checkInitialConditions.

@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_against_macro_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();
}
Also used : IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection) ExpressionPosRpcMessage(org.erlide.wrangler.refactoring.backend.internal.ExpressionPosRpcMessage)

Example 4 with ExpressionPosRpcMessage

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

the class MergeForAllRefactoring method checkInitialConditions.

@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, "merge_forall_eclipse", "sxi", sel.getFilePath(), sel.getSearchPath(), GlobalParameters.getTabWidth());
    if (m.isSuccessful()) {
        positions = m.getPositionDefinitions(sel.getDocument());
        selectedPositions = new ArrayList<>();
    } else {
        return RefactoringStatus.createFatalErrorStatus(m.getMessageString());
    }
    return new RefactoringStatus();
}
Also used : IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection) ExpressionPosRpcMessage(org.erlide.wrangler.refactoring.backend.internal.ExpressionPosRpcMessage)

Example 5 with ExpressionPosRpcMessage

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

the class MergeLetRefactoring method checkInitialConditions.

@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, "merge_let_eclipse", "sxi", sel.getFilePath(), sel.getSearchPath(), GlobalParameters.getTabWidth());
    if (m.isSuccessful()) {
        positions = m.getPositionDefinitions(sel.getDocument());
        selectedPositions = new ArrayList<>();
    } else {
        return RefactoringStatus.createFatalErrorStatus(m.getMessageString());
    }
    return new RefactoringStatus();
}
Also used : IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) IErlSelection(org.erlide.wrangler.refactoring.selection.IErlSelection) ExpressionPosRpcMessage(org.erlide.wrangler.refactoring.backend.internal.ExpressionPosRpcMessage)

Aggregations

RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)5 ExpressionPosRpcMessage (org.erlide.wrangler.refactoring.backend.internal.ExpressionPosRpcMessage)5 IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)4 IErlSelection (org.erlide.wrangler.refactoring.selection.IErlSelection)4 IErlFunction (org.erlide.engine.model.erlang.IErlFunction)1