Search in sources :

Example 6 with RpcResult

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

the class SimilarDetectionAction method callRefactoring.

@Override
protected IResultParser callRefactoring() throws WranglerRpcParsingException, CoreException, IOException, WranglerWarningException {
    final WranglerRefactoringBackend backend = WranglerBackendManager.getRefactoringBackend();
    final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
    RpcResult result;
    final String functionName = "sim_code_detection_eclipse";
    if (onlyInFile) {
        final OtpErlangString fp = new OtpErlangString(sel.getFilePath());
        final OtpErlangString[] fpa = new OtpErlangString[1];
        fpa[0] = fp;
        final OtpErlangList fpl = new OtpErlangList(fpa);
        result = backend.callWithoutParser(WranglerRefactoringBackend.UNLIMITED_TIMEOUT, functionName, "xiiiidxi", fpl, minLen, minToks, minFreq, maxNewVars, simScore, sel.getSearchPath(), GlobalParameters.getTabWidth());
    } else {
        result = backend.callWithoutParser(WranglerRefactoringBackend.UNLIMITED_TIMEOUT, functionName, "xiiiidxi", sel.getSearchPath(), minLen, minToks, minFreq, maxNewVars, simScore, sel.getSearchPath(), GlobalParameters.getTabWidth());
    }
    if (!result.isOk()) {
        throw new WranglerRpcParsingException("Rpc error");
    }
    return new DuplicateDetectionParser(result.getValue());
}
Also used : WranglerRefactoringBackend(org.erlide.wrangler.refactoring.backend.internal.WranglerRefactoringBackend) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) RpcResult(org.erlide.runtime.rpc.RpcResult) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) WranglerRpcParsingException(org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)

Example 7 with RpcResult

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

the class SimilarSearchAction method callRefactoring.

@Override
protected IResultParser callRefactoring() throws WranglerRpcParsingException, CoreException, IOException, WranglerWarningException {
    final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
    final WranglerRefactoringBackend backend = WranglerBackendManager.getRefactoringBackend();
    RpcResult result = null;
    String functionName;
    if (onlyInFile) {
        functionName = "simi_expr_search_in_buffer_eclipse";
    } else {
        functionName = "simi_expr_search_in_dirs_eclipse";
    }
    result = backend.callWithoutParser(WranglerRefactoringBackend.UNLIMITED_TIMEOUT, functionName, "sxxxxi", sel.getFilePath(), sel.getSelectionRange().getStartPos(), sel.getSelectionRange().getEndPos(), new OtpErlangFloat(simScore), sel.getSearchPath(), GlobalParameters.getTabWidth());
    if (result.isOk()) {
        return new SimilarExpressionSearchParser(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) OtpErlangFloat(com.ericsson.otp.erlang.OtpErlangFloat) WranglerRpcParsingException(org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)

Example 8 with RpcResult

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

the class UserRefactoringsManager method scanForUserRefactorings.

/**
 * Looks for user defined refactorings (in order to generate menu items for
 * them)
 */
@SuppressWarnings("rawtypes")
private void scanForUserRefactorings() {
    elementaryRefacs = new LinkedList<>();
    compositeRefacs = new LinkedList<>();
    myElementaryRefacs = new LinkedList<>();
    myCompositeRefacs = new LinkedList<>();
    final Bundle coreBundle = Platform.getBundle(Activator.CORE_ID);
    final Enumeration modules = coreBundle.findEntries("wrangler/ebin", "*.beam", false);
    // modules that origin from repository
    final List<OtpErlangObject> erlModules = new LinkedList<>();
    while (modules != null && modules.hasMoreElements()) {
        final String next = modules.nextElement().toString();
        final String module = next.substring(next.lastIndexOf('/') + 1, next.lastIndexOf('.'));
        erlModules.add(new OtpErlangString(module));
    }
    RpcResult res = WranglerBackendManager.getRefactoringBackend().callWithoutParser("get_user_refactorings", "x", new OtpErlangList(erlModules.toArray(new OtpErlangObject[0])));
    if (res.isOk() && res.getValue() instanceof OtpErlangList) {
        final OtpErlangList genRefac = (OtpErlangList) ((OtpErlangTuple) ((OtpErlangList) res.getValue()).elementAt(0)).elementAt(1);
        final OtpErlangList genCompositeRefac = (OtpErlangList) ((OtpErlangTuple) ((OtpErlangList) res.getValue()).elementAt(1)).elementAt(1);
        for (final OtpErlangObject obj : genRefac) {
            elementaryRefacs.add(new UserRefactoringInfo(obj.toString()));
        }
        for (final OtpErlangObject obj : genCompositeRefac) {
            compositeRefacs.add(new UserRefactoringInfo(obj.toString()));
        }
    }
    ErlLogger.info("Refac modules found " + res.toString());
    // user's own refactoring
    final Enumeration userModules = coreBundle.findEntries("wrangler/ebin/my_gen_refac", "*.beam", false);
    while (userModules != null && userModules.hasMoreElements()) {
        final String next = userModules.nextElement().toString();
        myElementaryRefacs.add(new UserRefactoringInfo(next.substring(next.lastIndexOf('/') + 1, next.lastIndexOf('.'))));
    }
    // user's own composite refactorings
    final Enumeration userCompositeModules = coreBundle.findEntries("wrangler/ebin/my_gen_composite_refac", "*.beam", false);
    while (userCompositeModules != null && userCompositeModules.hasMoreElements()) {
        final String next = userCompositeModules.nextElement().toString();
        myCompositeRefacs.add(new UserRefactoringInfo(next.substring(next.lastIndexOf('/') + 1, next.lastIndexOf('.'))));
    }
    // load refactorings
    res = WranglerBackendManager.getRefactoringBackend().callWithoutParser("load_user_refactorings", "s", getEbinPath());
    ErlLogger.debug(res.toString());
}
Also used : Enumeration(java.util.Enumeration) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) Bundle(org.osgi.framework.Bundle) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) RpcResult(org.erlide.runtime.rpc.RpcResult) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) LinkedList(java.util.LinkedList) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 9 with RpcResult

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

the class WranglerSyntaxBackend method varToPos.

protected SyntaxInfo varToPos(final OtpErlangTuple syntaxTree, final int line, final int col) {
    final OtpErlangInt[] position = new OtpErlangInt[2];
    position[0] = new OtpErlangInt(line);
    position[1] = new OtpErlangInt(col);
    final RpcResult res = backend.call_noexception(WranglerSyntaxBackend.INTERFACE_MODULE, WranglerSyntaxBackend.VAR_FUNCTION, "xx", syntaxTree, new OtpErlangTuple(position));
    return parseVarInfo(res.getValue());
}
Also used : OtpErlangInt(com.ericsson.otp.erlang.OtpErlangInt) RpcResult(org.erlide.runtime.rpc.RpcResult) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 10 with RpcResult

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

the class Activator method initWrangler.

/**
 * Loads the necessary *.ebin files to the Erlang node for the plug-in.
 *
 * @throws CoreException
 *             detailed exception about the loading process errors
 */
private void initWrangler() throws CoreException {
    final IOtpRpc mb = getBackend();
    RpcResult res = mb.call_noexception("wrangler_refacs", "init_eclipse", "", new Object[0]);
    ErlLogger.debug("Wrangler app started:\n" + res);
    res = mb.call_noexception("wrangler_error_logger", "init", "x", new OtpErlangList());
    ErlLogger.debug("Error logger started:" + res);
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) RpcResult(org.erlide.runtime.rpc.RpcResult) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc)

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