Search in sources :

Example 11 with IErlMemberSelection

use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection in project erlide_eclipse by erlang.

the class RenameVariableRefactoring method getDefaultValue.

@Override
public String getDefaultValue() {
    final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
    if (sel == null) {
        return "";
    }
    final RpcResult res = WranglerBackendManager.getRefactoringBackend().callWithoutParser("get_var_name_eclipse", "siixi", sel.getFilePath(), sel.getSelectionRange().getStartLine(), sel.getSelectionRange().getStartCol(), sel.getSearchPath(), GlobalParameters.getTabWidth());
    if (res.getValue().getClass().equals(OtpErlangString.class)) {
        return ((OtpErlangString) res.getValue()).stringValue();
    }
    return "";
}
Also used : IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) RpcResult(org.erlide.runtime.rpc.RpcResult) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 12 with IErlMemberSelection

use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection in project erlide_eclipse by erlang.

the class UserElementaryRefactoring method run.

@Override
public IRefactoringRpcMessage run(final IErlSelection selection) {
    final IErlMemberSelection sel = (IErlMemberSelection) selection;
    final OtpErlangList pos = new OtpErlangList(new OtpErlangInt[] { new OtpErlangInt(sel.getSelectionRange().getStartLine()), new OtpErlangInt(sel.getSelectionRange().getStartCol()) });
    final OtpErlangList selectionBeg = new OtpErlangList(new OtpErlangInt[] { new OtpErlangInt(sel.getSelectionRange().getStartLine()), new OtpErlangInt(sel.getSelectionRange().getStartCol()) });
    final OtpErlangList selectionEnd = new OtpErlangList(new OtpErlangInt[] { new OtpErlangInt(sel.getSelectionRange().getEndLine()), new OtpErlangInt(sel.getSelectionRange().getEndCol()) });
    final OtpErlangList selectionPos = new OtpErlangList(new OtpErlangObject[] { selectionBeg, selectionEnd });
    final OtpErlangList args = new OtpErlangList(new OtpErlangObject[] { new OtpErlangString(sel.getFilePath()), pos, selectionPos, prepareUserInput(), sel.getSearchPath(), new OtpErlangInt(GlobalParameters.getTabWidth()) });
    return WranglerBackendManager.getRefactoringBackend().call("run_refac_eclipse", "sx", getCallbackModule(), args);
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) OtpErlangInt(com.ericsson.otp.erlang.OtpErlangInt) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 13 with IErlMemberSelection

use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection in project erlide_eclipse by erlang.

the class ExpressionSearchAction method callRefactoring.

@Override
protected IResultParser callRefactoring() throws WranglerRpcParsingException {
    final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
    final WranglerRefactoringBackend backend = WranglerBackendManager.getRefactoringBackend();
    final RpcResult result = backend.callWithoutParser(WranglerRefactoringBackend.UNLIMITED_TIMEOUT, "expr_search_eclipse", "sxxi", sel.getFilePath(), sel.getSelectionRange().getStartPos(), sel.getSelectionRange().getEndPos(), GlobalParameters.getTabWidth());
    if (result.isOk()) {
        return new ExpressionSearchParser(result.getValue());
    }
    throw new WranglerRpcParsingException("RPC error");
}
Also used : WranglerRefactoringBackend(org.erlide.wrangler.refactoring.backend.internal.WranglerRefactoringBackend) IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) RpcResult(org.erlide.runtime.rpc.RpcResult) WranglerRpcParsingException(org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)

Example 14 with IErlMemberSelection

use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection 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 15 with IErlMemberSelection

use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection in project erlide_eclipse by erlang.

the class GeneraliseFunctionRefactoring method createPositionList.

/**
 * Returns IErlRange, OtpErlangTuple pairs, which are represents the same
 * position in a module
 *
 * @param thePositions
 * @return
 */
protected HashMap<IErlRange, OtpErlangTuple> createPositionList(final OtpErlangList thePositions) {
    try {
        final HashMap<IErlRange, OtpErlangTuple> ret = new HashMap<>();
        final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
        for (final OtpErlangObject o : thePositions) {
            // {{sl, sc}, {el,ec}}
            final OtpErlangTuple pos = (OtpErlangTuple) o;
            ret.put(new ErlRange(new Range(pos), sel.getDocument()), pos);
        }
        return ret;
    } catch (final OtpErlangException e) {
        ErlLogger.error(e);
        return null;
    }
}
Also used : IErlRange(org.erlide.wrangler.refactoring.util.IErlRange) HashMap(java.util.HashMap) IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangException(com.ericsson.otp.erlang.OtpErlangException) ErlRange(org.erlide.wrangler.refactoring.util.ErlRange) IErlRange(org.erlide.wrangler.refactoring.util.IErlRange) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) Range(org.erlide.wrangler.refactoring.util.Range) ErlRange(org.erlide.wrangler.refactoring.util.ErlRange) IErlRange(org.erlide.wrangler.refactoring.util.IErlRange)

Aggregations

IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)19 RefactoringStatus (org.eclipse.ltk.core.refactoring.RefactoringStatus)6 RpcResult (org.erlide.runtime.rpc.RpcResult)6 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)5 IErlSelection (org.erlide.wrangler.refactoring.selection.IErlSelection)5 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)4 ExpressionPosRpcMessage (org.erlide.wrangler.refactoring.backend.internal.ExpressionPosRpcMessage)4 WranglerRefactoringBackend (org.erlide.wrangler.refactoring.backend.internal.WranglerRefactoringBackend)4 WranglerRpcParsingException (org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)4 IErlRange (org.erlide.wrangler.refactoring.util.IErlRange)4 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)2 CostumWorkflowRefactoringWithPositionsSelection (org.erlide.wrangler.refactoring.core.CostumWorkflowRefactoringWithPositionsSelection)2 WranglerRefactoring (org.erlide.wrangler.refactoring.core.WranglerRefactoring)2 SelectionInputPage (org.erlide.wrangler.refactoring.ui.wizardpages.SelectionInputPage)2 OtpErlangException (com.ericsson.otp.erlang.OtpErlangException)1 OtpErlangFloat (com.ericsson.otp.erlang.OtpErlangFloat)1 OtpErlangInt (com.ericsson.otp.erlang.OtpErlangInt)1 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 ArrayList (java.util.ArrayList)1