Search in sources :

Example 36 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString 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 37 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString 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 38 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString 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)

Example 39 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.

the class SimpleCodeInspectionHandler method extractModule.

private IErlModule extractModule(final OtpErlangObject m) throws ErlModelException {
    String name = "";
    if (m instanceof OtpErlangString) {
        final OtpErlangString element = (OtpErlangString) m;
        name = element.stringValue();
    } else if (m instanceof OtpErlangAtom) {
        final OtpErlangAtom atom = (OtpErlangAtom) m;
        name = atom.atomValue();
    }
    final String[] modNameParts = name.split("/");
    final IErlModule mod = ErlangEngine.getInstance().getModel().findModule(modNameParts[modNameParts.length - 1]);
    return mod;
}
Also used : IErlModule(org.erlide.engine.model.root.IErlModule) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 40 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.

the class AbstractRefactoringRpcMessage method parseFileList.

protected ArrayList<ChangedFile> parseFileList(final OtpErlangList fileList) {
    final ArrayList<ChangedFile> ret = new ArrayList<>();
    OtpErlangTuple e;
    OtpErlangString oldPath;
    OtpErlangString newPath;
    for (int i = 0; i < fileList.arity(); ++i) {
        e = (OtpErlangTuple) fileList.elementAt(i);
        oldPath = (OtpErlangString) e.elementAt(0);
        newPath = (OtpErlangString) e.elementAt(1);
        final String newContent = OtpErlang.asString(e.elementAt(2));
        ret.add(new ChangedFile(oldPath.stringValue(), newPath.stringValue(), newContent));
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) ChangedFile(org.erlide.wrangler.refactoring.backend.ChangedFile) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Aggregations

OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)56 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)36 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)31 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)22 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)15 ArrayList (java.util.ArrayList)9 RpcResult (org.erlide.runtime.rpc.RpcResult)8 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)7 RpcException (org.erlide.runtime.rpc.RpcException)7 Test (org.junit.Test)7 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)6 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)5 IPath (org.eclipse.core.runtime.IPath)5 ErlModelException (org.erlide.engine.model.ErlModelException)5 IErlElement (org.erlide.engine.model.IErlElement)5 WranglerRpcParsingException (org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)5 IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)5 CoreException (org.eclipse.core.runtime.CoreException)4 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)4 Map (java.util.Map)3