Search in sources :

Example 16 with RpcResult

use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.

the class WranglerRefactoringBackend method callWithParser.

/**
 * Send an RPC, and allow to define a costum parser
 *
 * @param parser
 *            parser object
 * @param functionName
 *            function name in wrangler_refacs.erl
 * @param signature
 *            parameters signature
 * @param parameters
 *            parameters array
 * @return parsed RPC message
 */
public IRpcMessage callWithParser(final IRpcMessage parser, final String functionName, final String signature, final Object... parameters) {
    final RpcResult res = callWithoutParser(functionName, signature, parameters);
    parser.parse(res);
    return parser;
}
Also used : RpcResult(org.erlide.runtime.rpc.RpcResult)

Example 17 with RpcResult

use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.

the class WranglerRefactoringBackend method call.

/**
 * Send an RPC and parses it with the default parser
 *
 * @param functionName
 *            function name in wrangler.erl
 * @param signature
 *            parameters signature
 * @param parameters
 *            parameters in an array
 * @return parsed RPC message
 * @noreference This method is not intended to be referenced by clients.
 */
public AbstractRefactoringRpcMessage call(final String functionName, final String signature, final Object... parameters) {
    final RpcResult res = callWithoutParser(functionName, signature, parameters);
    final AbstractRefactoringRpcMessage message = new RefactoringRpcMessage();
    message.parse(res);
    return message;
}
Also used : RpcResult(org.erlide.runtime.rpc.RpcResult)

Example 18 with RpcResult

use of org.erlide.runtime.rpc.RpcResult 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 19 with RpcResult

use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.

the class UserAdhocRefactoring method load.

/**
 * Loading user's callback module
 *
 * @return
 */
public boolean load() {
    String callbackPath;
    try {
        if (ErlangEngine.getInstance().getModel().findModule(refac.getCallbackModule()) == null) {
            return false;
        }
        final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(ErlangEngine.getInstance().getModel().findModule(refac.getCallbackModule()));
        callbackPath = project.getWorkspaceProject().getLocation().append(project.getProperties().getOutputDir()).toString();
    } catch (final ErlModelException e) {
        return false;
    }
    final RpcResult res = WranglerBackendManager.getRefactoringBackend().callWithoutParser("load_callback_mod_eclipse", "ss", refac.getCallbackModule(), callbackPath);
    if (!res.isOk()) {
        return false;
    }
    return true;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlModelException(org.erlide.engine.model.ErlModelException) RpcResult(org.erlide.runtime.rpc.RpcResult)

Example 20 with RpcResult

use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.

the class SimpleCodeInspectionHandler method handleLargeModulesCall.

private void handleLargeModulesCall(final IErlSelection wranglerSelection, final Shell shell) {
    CodeInspectionViewsManager.hideView(CodeInspectionViewsManager.CODE_INSPECTION_VIEW, SimpleCodeInspectionHandler.LARGE_MODULES_VIEW_ID);
    final InputDialog dialog = new InputDialog(shell, "Lines of a large module", "Lines of a large module:", "", new IntegerInputValidator());
    final int ret = dialog.open();
    if (ret == Window.CANCEL) {
        return;
    }
    final int lines = Integer.parseInt(dialog.getValue());
    final RpcResult res = WranglerBackendManager.getRefactoringBackend().callInspection("large_modules_eclipse", "ixi", lines, wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
    ArrayList<IErlElement> modules = new ArrayList<>();
    try {
        final OtpErlangObject obj = res.getValue();
        final OtpErlangTuple restuple = (OtpErlangTuple) obj;
        final OtpErlangAtom resindicator = (OtpErlangAtom) restuple.elementAt(0);
        if ("ok".equals(resindicator.atomValue())) {
            final OtpErlangList modList = (OtpErlangList) restuple.elementAt(1);
            modules = createErlModuleList(modList);
        } else {
            final OtpErlangString s = (OtpErlangString) restuple.elementAt(1);
            MessageDialog.openError(shell, "Error", s.stringValue());
            return;
        }
    } catch (final Exception e) {
        ErlLogger.error(e);
    }
    if (!modules.isEmpty()) {
        CodeInspectionViewsManager.showErlElements("Large modules", modules, SimpleCodeInspectionHandler.LARGE_MODULES_VIEW_ID);
    } else {
        MessageDialog.openInformation(shell, "No result", "There is no large module with the specified parameter!");
    }
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) RpcResult(org.erlide.runtime.rpc.RpcResult) ArrayList(java.util.ArrayList) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) ErlModelException(org.erlide.engine.model.ErlModelException) ExecutionException(org.eclipse.core.commands.ExecutionException) WranglerException(org.erlide.wrangler.refactoring.exception.WranglerException) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) IErlElement(org.erlide.engine.model.IErlElement) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Aggregations

RpcResult (org.erlide.runtime.rpc.RpcResult)26 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)10 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)8 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)7 ExecutionException (org.eclipse.core.commands.ExecutionException)7 ErlModelException (org.erlide.engine.model.ErlModelException)7 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)7 IErlElement (org.erlide.engine.model.IErlElement)6 IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)6 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)5 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)4 WranglerRefactoringBackend (org.erlide.wrangler.refactoring.backend.internal.WranglerRefactoringBackend)4 WranglerRpcParsingException (org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)4 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)3 ArrayList (java.util.ArrayList)2 InputDialogWithCheckbox (org.erlide.wrangler.refactoring.codeinspection.ui.InputDialogWithCheckbox)2 OtpErlangFloat (com.ericsson.otp.erlang.OtpErlangFloat)1 OtpErlangInt (com.ericsson.otp.erlang.OtpErlangInt)1 Enumeration (java.util.Enumeration)1 LinkedList (java.util.LinkedList)1