Search in sources :

Example 1 with OtpErlangRangeException

use of com.ericsson.otp.erlang.OtpErlangRangeException in project intellij-elixir by KronicDeth.

the class Overridable method getChildren.

/**
 * Returns the list of children of the tree element.
 *
 * @return the list of children.
 */
@NotNull
@Override
public TreeElement[] getChildren() {
    QuotableKeywordList keywordArguments = keywordArguments(navigationItem);
    TreeElement[] children;
    if (keywordArguments != null) {
        List<QuotableKeywordPair> quotableKeywordPairList = keywordArguments.quotableKeywordPairList();
        List<TreeElement> treeElementList = new ArrayList<TreeElement>(quotableKeywordPairList.size());
        for (QuotableKeywordPair quotableKeywordPair : quotableKeywordPairList) {
            Quotable keywordKey = quotableKeywordPair.getKeywordKey();
            OtpErlangObject quotedKeywordKey = keywordKey.quote();
            String name;
            if (quotedKeywordKey instanceof OtpErlangAtom) {
                OtpErlangAtom keywordKeyAtom = (OtpErlangAtom) quotedKeywordKey;
                name = keywordKeyAtom.atomValue();
            } else {
                name = keywordKey.getText();
            }
            Quotable keywordValue = quotableKeywordPair.getKeywordValue();
            OtpErlangObject quotedKeywordValue = keywordValue.quote();
            Integer arity = null;
            if (quotedKeywordValue instanceof OtpErlangLong) {
                OtpErlangLong keywordValueErlangLong = (OtpErlangLong) quotedKeywordValue;
                try {
                    arity = keywordValueErlangLong.intValue();
                } catch (OtpErlangRangeException e) {
                    arity = null;
                }
            }
            boolean overridable = true;
            // noinspection ConstantConditions
            treeElementList.add(new CallReference(modular, quotableKeywordPair, Timed.Time.RUN, overridable, name, arity));
        }
        children = treeElementList.toArray(new TreeElement[treeElementList.size()]);
    } else {
        children = new TreeElement[0];
    }
    return children;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) ArrayList(java.util.ArrayList) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) TreeElement(com.intellij.ide.util.treeView.smartTree.TreeElement) Quotable(org.elixir_lang.psi.Quotable) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) QuotableKeywordList(org.elixir_lang.psi.QuotableKeywordList) QuotableKeywordPair(org.elixir_lang.psi.QuotableKeywordPair) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with OtpErlangRangeException

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

the class RefactoringHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    try {
        GlobalParameters.setSelection(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection());
    } catch (final WranglerException e1) {
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", e1.getMessage());
        return null;
    }
    if (!checkForDirtyEditors()) {
        return null;
    }
    DefaultWranglerRefactoringWizard wizard;
    WranglerRefactoring refactoring = null;
    final String actionId = event.getCommand().getId();
    final ArrayList<WranglerPage> pages = new ArrayList<>();
    // apply ad hoc refactoring
    if ("org.erlide.wrangler.refactoring.adhoc".equals(actionId)) {
        final InputDialog dialog = getModuleInput("Apply ad hoc refactoring", "Please type the gen_refac module name!");
        dialog.open();
        if (dialog.getReturnCode() == Window.CANCEL) {
            return null;
        }
        final String callbackModule = dialog.getValue();
        pages.add(new UserRefacInputPage("Apply ad hoc refactoring", "Please type input arguments for this refactoring", "Arguments should not be empty!", new NonEmptyStringValidator()));
        refactoring = new ApplyAdhocElemRefactoring();
        ((ApplyAdhocElemRefactoring) refactoring).setCallbackModuleName(callbackModule);
        if (!((ApplyAdhocElemRefactoring) refactoring).fetchParPrompts()) {
            MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Elementary refactoring error", "Can not load callback module");
            return null;
        }
    // apply user-defined refactoring
    } else if ("org.erlide.wrangler.refactoring.gen_refac".equals(actionId)) {
        final String callbackModule = event.getParameter("org.erlide.wrangler.refactoring.gen_refac.callback");
        final String name = event.getParameter("org.erlide.wrangler.refactoring.gen_refac.name");
        pages.add(new UserRefacInputPage(name, "Please type input arguments for this refactoring", "Arguments should not be empty!", new NonEmptyStringValidator()));
        refactoring = new ApplyUserElementaryRefactoring(name, callbackModule);
        if (!((ApplyUserElementaryRefactoring) refactoring).fetchParPrompts()) {
            MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Refactoring error", "Can not find callback module");
            return null;
        }
    // run rename variable refactoring
    } else if ("org.erlide.wrangler.refactoring.renamevariable".equals(actionId)) {
        refactoring = new RenameVariableRefactoring();
        final SimpleInputPage page = new SimpleInputPage("Rename variable", "Please type the new variable name!", "New variable name:", "New name must be a valid Erlang variable name!", new VariableNameValidator());
        page.setInput(refactoring.getDefaultValue());
        pages.add(page);
    // introduce new variable refactoring
    } else if ("org.erlide.wrangler.refactoring.introducenewvariable".equals(actionId)) {
        pages.add(new SimpleInputPage("Introduce new variable", "Please type the new variable name!", "New variable name:", "New name must be a valid Erlang variable name!", new VariableNameValidator()));
        refactoring = new IntroduceNewVariableRefactoring();
    // run rename function refactoring
    } else if ("org.erlide.wrangler.refactoring.renamefunction".equals(actionId)) {
        refactoring = new RenameFunctionRefactoring();
        final CostumworkFlowInputPage page = new CostumworkFlowInputPage("Rename function", "Please type the new function name!", "New function name:", "New name must be a valid Erlang atom!", new AtomValidator());
        page.setInput(refactoring.getDefaultValue());
        pages.add(page);
    // run extract function refactoring
    } else if ("org.erlide.wrangler.refactoring.extractfunction".equals(actionId)) {
        pages.add(new CostumworkFlowInputPage("Extract function", "Please type a function name!", "Function name:", "Function name must be a valid Erlang atom!", new AtomValidator()));
        refactoring = new ExtractFunctionRefactoring();
    // run rename module refactoring
    } else if ("org.erlide.wrangler.refactoring.renamemodule".equals(actionId)) {
        final boolean answer = MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Warning!", "The requested operation cannot be undone. Would you like to continue?");
        if (!answer) {
            return null;
        }
        refactoring = new RenameModuleRefactoring();
        final CostumworkFlowInputPage page = new CostumworkFlowInputPage("Rename module", "Please type the new module name!", "New module name:", "New module name must be a valid Erlang atom!", new AtomValidator());
        page.setInput(refactoring.getDefaultValue());
        pages.add(page);
    // run move function refactoring
    } else if ("org.erlide.wrangler.refactoring.movefunction".equals(actionId)) {
        final IProject project = ErlangEngine.getInstance().getModelUtilService().getProject(GlobalParameters.getWranglerSelection().getErlElement()).getWorkspaceProject();
        final ArrayList<String> moduleList = WranglerUtils.getModuleNames(project);
        final String moduleName = GlobalParameters.getWranglerSelection().getErlElement().getResource().getName();
        moduleList.remove(WranglerUtils.removeExtension(moduleName));
        pages.add(new ComboInputPage("Move function", "Please select the destination module", "Destination module:", moduleList));
        refactoring = new MoveFunctionRefactoring();
    // run fold expression against a local function
    } else if ("org.erlide.wrangler.refactoring.foldlocalexpression".equals(actionId)) {
        refactoring = new FoldLocalExpressionRefactoring();
        pages.add(new SelectionInputPage("Fold expression", "Please select expression which should be fold!", "Select expressions which should be folded!", (CostumWorkflowRefactoringWithPositionsSelection) refactoring));
    // run fold expression against a remote function
    } else {
        final Shell activeShell = PlatformUI.getWorkbench().getDisplay().getActiveShell();
        if ("org.erlide.wrangler.refactoring.foldremoteexpression".equals(actionId)) {
            // must store the selection, because, the user through the
            // dialog
            // may change it
            final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
            final RemoteFunctionClauseDialog dialog = new RemoteFunctionClauseDialog(activeShell, "Fold expression");
            dialog.open();
            dialog.resetSelection();
            if (dialog.isFinished()) {
                final IErlFunctionClause functionClause = dialog.getFunctionClause();
                refactoring = new FoldRemoteExpressionRefactoring(functionClause, sel);
                pages.add(new SelectionInputPage("Fold expression", "Please select expression which should be fold!", "Select expressions which should be folded!", (CostumWorkflowRefactoringWithPositionsSelection) refactoring));
            } else {
                return null;
            }
        // run introduce macro refactoring
        } else if ("org.erlide.wrangler.refactoring.introducemacro".equals(actionId)) {
            refactoring = new IntroduceMacroRefactoring();
            pages.add(new SimpleInputPage("Introduce macro definition", "Please type the new macro name!", "New macro name:", "Macro name cannot be empty!", new NonEmptyStringValidator()));
        // run rename process refactoring
        } else if ("org.erlide.wrangler.refactoring.renameprocess".equals(actionId)) {
            refactoring = new RenameProcessRefactoring();
            pages.add(new SimpleInputPage("Rename process", "Please type the new process name!", "New process name:", "New process name must be an Erlang atom!", new AtomValidator()));
        // run function to process refactoring
        } else if ("org.erlide.wrangler.refactoring.functiontoprocess".equals(actionId)) {
            refactoring = new FunctionToProcessRefactoring();
            pages.add(new SimpleInputPage("Convert function to process", "Please type the new process name!", "New process name:", "New process name must be an Erlang atom!", new AtomValidator()));
        // run tuple function parameters refactoring
        } else if ("org.erlide.wrangler.refactoring.tuplefunctonparameters".equals(actionId)) {
            refactoring = new TupleFunctionParametersRefactoring();
        // run generalise function refactoring
        } else if ("org.erlide.wrangler.refactoring.generalise".equals(actionId)) {
            /*
                 * pages.add(new CostumworkFlowInputPage("Generalise function",
                 * "Please type the new parameter name!", "New parameter name:",
                 * "New parameter name must be a valid Erlang variable name!", new
                 * VariableNameValidator()));
                 */
            try {
                refactoring = runGenFunRefactoring(pages, activeShell);
            } catch (final OtpErlangRangeException e) {
                ErlLogger.error(e);
                return null;
            }
            if (refactoring == null) {
                return null;
            }
        // fold against macro definition
        } else if ("org.erlide.wrangler.refactoring.foldagainstmacro".equals(actionId)) {
            refactoring = new FoldAgainstMacro();
            pages.add(new SelectionInputPage("Fold against macro definition", "Please select expression which should be fold!", "Select expressions which should be folded!", (CostumWorkflowRefactoringWithPositionsSelection) refactoring));
        // normalize record expression
        } else if ("org.erlide.wrangler.refactoring.normalizerecordexpression".equals(actionId)) {
            final boolean showDefaultFields = MessageDialog.openQuestion(activeShell, "Showing defaults", "Show record fields with default values?");
            refactoring = new NormalizeRecordExpression(showDefaultFields);
        } else if ("org.erlide.wrangler.refactoring.introducelet".equals(actionId)) {
            pages.add(new CostumworkFlowInputPage("Introduce ?LET", "Please type the pattern variable name!", "Pattern variable name:", "New name must be a valid Erlang atom!", new VariableNameValidator()));
            refactoring = new IntroduceLetRefactoring();
        } else if ("org.erlide.wrangler.refactoring.mergelet".equals(actionId)) {
            refactoring = new MergeLetRefactoring();
            pages.add(new SelectionInputPage("Merge ?LET expressions", "Please select expressions which whould be merged!", "Select expressions which should be merged", (CostumWorkflowRefactoringWithPositionsSelection) refactoring));
        } else if ("org.erlide.wrangler.refactoring.mergeforall".equals(actionId)) {
            refactoring = new MergeForAllRefactoring();
            pages.add(new SelectionInputPage("Merge ?FORALL expressions", "Please select expressions which should be merged!", "Select expressions which should be merged", (CostumWorkflowRefactoringWithPositionsSelection) refactoring));
        } else if ("org.erlide.wrangler.refactoring.eqc_statemtorecord".equals(actionId)) {
            refactoring = new EqcStatemStateDataToRecordRefactoring();
            pages.add(new RecordDataInputPage("eqc_statem State Data To Record"));
        } else if ("org.erlide.wrangler.refactoring.eqc_fsmtorecord".equals(actionId)) {
            refactoring = new EqcFsmStateDataToRecordRefactoring();
            pages.add(new RecordDataInputPage("eqc_fsm State Data To Record"));
        } else if ("org.erlide.wrangler.refactoring.gen_fsmtorecord".equals(actionId)) {
            refactoring = new GenFsmStateDataToRecordRefactoring();
            pages.add(new RecordDataInputPage("gen_fsm State Data To Record"));
        } else if ("org.erlide.wrangler.refactoring.unfoldfunctionapplication".equals(actionId)) {
            refactoring = new UnfoldFunctionApplicationRefactoring();
        } else if ("org.erlide.wrangler.refactoring.partitionexports".equals(actionId)) {
            refactoring = new PartitionExportsRefactoring();
            final SimpleInputPage page = new SimpleInputPage("Partition exports", "Please input the the distance treshould between 0.1 and 1.0", "Distance treshold", "The value must be between 0.1 and 1.0", new NormalDoulbeValidator());
            page.setInput("0.8");
            pages.add(page);
        } else {
            return null;
        }
    }
    refactoring.doBeforeRefactoring();
    // run the given refactoring's wizard
    wizard = new DefaultWranglerRefactoringWizard(refactoring, RefactoringWizard.DIALOG_BASED_USER_INTERFACE, pages);
    final Shell shell = new Shell();
    final RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
    try {
        final int ret = op.run(shell, refactoring.getName());
        if (RefactoringStatus.OK == ret) {
            refactoring.doAfterRefactoring();
        }
    } catch (final Exception e) {
        ErlLogger.error(e);
    }
    checkWarningMessages();
    return null;
}
Also used : EqcFsmStateDataToRecordRefactoring(org.erlide.wrangler.refactoring.core.internal.EqcFsmStateDataToRecordRefactoring) UnfoldFunctionApplicationRefactoring(org.erlide.wrangler.refactoring.core.internal.UnfoldFunctionApplicationRefactoring) IntroduceMacroRefactoring(org.erlide.wrangler.refactoring.core.internal.IntroduceMacroRefactoring) SimpleInputPage(org.erlide.wrangler.refactoring.ui.wizardpages.SimpleInputPage) ArrayList(java.util.ArrayList) RenameVariableRefactoring(org.erlide.wrangler.refactoring.core.internal.RenameVariableRefactoring) UserRefacInputPage(org.erlide.wrangler.refactoring.ui.wizardpages.UserRefacInputPage) FoldLocalExpressionRefactoring(org.erlide.wrangler.refactoring.core.internal.FoldLocalExpressionRefactoring) FoldAgainstMacro(org.erlide.wrangler.refactoring.core.internal.FoldAgainstMacro) IntroduceNewVariableRefactoring(org.erlide.wrangler.refactoring.core.internal.IntroduceNewVariableRefactoring) WranglerPage(org.erlide.wrangler.refactoring.ui.wizardpages.WranglerPage) AtomValidator(org.erlide.wrangler.refactoring.ui.validator.AtomValidator) CostumWorkflowRefactoringWithPositionsSelection(org.erlide.wrangler.refactoring.core.CostumWorkflowRefactoringWithPositionsSelection) MergeLetRefactoring(org.erlide.wrangler.refactoring.core.internal.MergeLetRefactoring) MoveFunctionRefactoring(org.erlide.wrangler.refactoring.core.internal.MoveFunctionRefactoring) IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) NonEmptyStringValidator(org.erlide.wrangler.refactoring.ui.validator.NonEmptyStringValidator) RefactoringWizardOpenOperation(org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation) RenameModuleRefactoring(org.erlide.wrangler.refactoring.core.internal.RenameModuleRefactoring) ApplyAdhocElemRefactoring(org.erlide.wrangler.refactoring.core.internal.ApplyAdhocElemRefactoring) ComboInputPage(org.erlide.wrangler.refactoring.ui.wizardpages.ComboInputPage) MergeForAllRefactoring(org.erlide.wrangler.refactoring.core.internal.MergeForAllRefactoring) ExtractFunctionRefactoring(org.erlide.wrangler.refactoring.core.internal.ExtractFunctionRefactoring) IntroduceLetRefactoring(org.erlide.wrangler.refactoring.core.internal.IntroduceLetRefactoring) SelectionInputPage(org.erlide.wrangler.refactoring.ui.wizardpages.SelectionInputPage) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) WranglerException(org.erlide.wrangler.refactoring.exception.WranglerException) IErlFunctionClause(org.erlide.engine.model.erlang.IErlFunctionClause) Shell(org.eclipse.swt.widgets.Shell) RecordDataInputPage(org.erlide.wrangler.refactoring.ui.wizardpages.RecordDataInputPage) RenameProcessRefactoring(org.erlide.wrangler.refactoring.core.internal.RenameProcessRefactoring) VariableNameValidator(org.erlide.wrangler.refactoring.ui.validator.VariableNameValidator) FoldRemoteExpressionRefactoring(org.erlide.wrangler.refactoring.core.internal.FoldRemoteExpressionRefactoring) TupleFunctionParametersRefactoring(org.erlide.wrangler.refactoring.core.internal.TupleFunctionParametersRefactoring) InputDialog(org.eclipse.jface.dialogs.InputDialog) NormalDoulbeValidator(org.erlide.wrangler.refactoring.ui.validator.NormalDoulbeValidator) NormalizeRecordExpression(org.erlide.wrangler.refactoring.core.internal.NormalizeRecordExpression) CostumworkFlowInputPage(org.erlide.wrangler.refactoring.ui.wizardpages.CostumworkFlowInputPage) WranglerRefactoring(org.erlide.wrangler.refactoring.core.WranglerRefactoring) ApplyUserElementaryRefactoring(org.erlide.wrangler.refactoring.core.internal.ApplyUserElementaryRefactoring) PartitionExportsRefactoring(org.erlide.wrangler.refactoring.core.internal.PartitionExportsRefactoring) IProject(org.eclipse.core.resources.IProject) ExecutionException(org.eclipse.core.commands.ExecutionException) WranglerException(org.erlide.wrangler.refactoring.exception.WranglerException) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) EqcStatemStateDataToRecordRefactoring(org.erlide.wrangler.refactoring.core.internal.EqcStatemStateDataToRecordRefactoring) RenameFunctionRefactoring(org.erlide.wrangler.refactoring.core.internal.RenameFunctionRefactoring) FunctionToProcessRefactoring(org.erlide.wrangler.refactoring.core.internal.FunctionToProcessRefactoring) DefaultWranglerRefactoringWizard(org.erlide.wrangler.refactoring.ui.wizard.DefaultWranglerRefactoringWizard) GenFsmStateDataToRecordRefactoring(org.erlide.wrangler.refactoring.core.internal.GenFsmStateDataToRecordRefactoring)

Example 3 with OtpErlangRangeException

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

the class DebuggerTraceView method createViewer.

@Override
protected Viewer createViewer(final Composite parent) {
    viewer = new TreeViewer(new Tree(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION));
    // setViewer(viewer);
    // super.createPartControl(parent);
    // parent.setLayout(new FillLayout());
    viewer.getTree().setLinesVisible(true);
    viewer.setUseHashlookup(true);
    createColumns();
    viewer.setContentProvider(getContentProvider());
    viewer.setLabelProvider(new ColumnLabelProvider());
    getSite().setSelectionProvider(viewer);
    viewer.setInput(this);
    DebugPlugin.getDefault().addDebugEventListener(this);
    // viewer.getTree().addTreeListener(new TreeAdapter() {
    // @Override
    // public void treeCollapsed(final TreeEvent e) {
    // removeExpandedCategory((MarkerCategory) e.item.getData());
    // }
    // 
    // @Override
    // public void treeExpanded(final TreeEvent e) {
    // addExpandedCategory((MarkerCategory) e.item.getData());
    // }
    // });
    // // Set help on the view itself
    // viewer.getControl().addHelpListener(new HelpListener() {
    // public void helpRequested(HelpEvent e) {
    // Object provider = getAdapter(IContextProvider.class);
    // if (provider == null) {
    // return;
    // }
    // 
    // IContext context = ((IContextProvider) provider)
    // .getContext(viewer.getControl());
    // PlatformUI.getWorkbench().getHelpSystem().displayHelp(context);
    // }
    // 
    // });
    viewer.getTree().addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final Object o = getSelectedInTree();
            // $NON-NLS-1$
            final String msg = o == null ? "" : o.toString();
            getViewSite().getActionBars().getStatusLineManager().setMessage(msg);
        }
    });
    viewer.getTree().addMouseListener(new MouseListener() {

        @Override
        public void mouseDoubleClick(final MouseEvent e) {
            final Object o = getSelectedInTree();
            if (o instanceof OtpErlangTuple) {
                final OtpErlangTuple t = (OtpErlangTuple) o;
                final OtpErlangTuple t2 = (OtpErlangTuple) t.elementAt(1);
                final OtpErlangTuple ieval = (OtpErlangTuple) t2.elementAt(0);
                final OtpErlangAtom mod = (OtpErlangAtom) ieval.elementAt(3);
                final String module = mod.atomValue();
                final OtpErlangLong lin = (OtpErlangLong) ieval.elementAt(2);
                try {
                    final int line = lin.intValue();
                    gotoModuleLine(module, line);
                } catch (final OtpErlangRangeException e1) {
                }
            }
        }

        @Override
        public void mouseDown(final MouseEvent e) {
        }

        @Override
        public void mouseUp(final MouseEvent e) {
        }
    });
    // .addPropertyChangeListener(getWorkingSetListener());
    return viewer;
// registerContextMenu();
// initDragAndDrop();
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) MouseListener(org.eclipse.swt.events.MouseListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Example 4 with OtpErlangRangeException

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

the class DebugTraceEvent method getStackFrames.

public List<IStackFrame> getStackFrames(final IDebugTarget target, final IThread process) {
    // XXX JC copy paste
    final OtpErlangTuple tuple = getTuple();
    final OtpErlangList erlStackFrames = (OtpErlangList) tuple.elementAt(2);
    final OtpErlangTuple t2 = (OtpErlangTuple) tuple.elementAt(1);
    final OtpErlangTuple ieval = (OtpErlangTuple) t2.elementAt(0);
    OtpErlangAtom m = (OtpErlangAtom) ieval.elementAt(3);
    OtpErlangList bindings = (OtpErlangList) t2.elementAt(t2.arity() - 1);
    OtpErlangLong l = (OtpErlangLong) ieval.elementAt(1);
    final List<IStackFrame> stackFrames = new ArrayList<>(erlStackFrames.arity() + 1);
    for (final OtpErlangObject o : erlStackFrames) {
        final OtpErlangTuple t = (OtpErlangTuple) o;
        final OtpErlangTuple ml = (OtpErlangTuple) t.elementAt(1);
        final OtpErlangObject ml0 = ml.elementAt(0);
        int stackFrameNo;
        final OtpErlangLong n = (OtpErlangLong) t.elementAt(3);
        try {
            stackFrameNo = n.intValue();
        } catch (final OtpErlangRangeException e) {
            stackFrameNo = -1;
        }
        final String module = m.atomValue();
        int line;
        try {
            line = l.intValue();
        } catch (final OtpErlangRangeException e) {
            line = -1;
        }
        final IStackFrame sf = new ErlangStackFrame(module, (ErlangProcess) process, target, line, null, bindings, stackFrameNo);
        stackFrames.add(sf);
        bindings = (OtpErlangList) t.elementAt(2);
        m = (OtpErlangAtom) ml0;
        l = (OtpErlangLong) ml.elementAt(1);
    }
    return stackFrames;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) IStackFrame(org.eclipse.debug.core.model.IStackFrame) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ArrayList(java.util.ArrayList) ErlangStackFrame(org.erlide.backend.debug.model.ErlangStackFrame) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom)

Example 5 with OtpErlangRangeException

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

the class DialyzerMarkerUtils method addDialyzerWarningMarkersFromResultList.

public static void addDialyzerWarningMarkersFromResultList(final IOtpRpc backend, final OtpErlangList result) {
    if (result == null || result.arity() == 0) {
        return;
    }
    final List<String> warnings = ErlideDialyze.formatWarnings(backend, result);
    for (int i = 0; i < warnings.size(); i++) {
        final OtpErlangTuple t = (OtpErlangTuple) result.elementAt(i);
        final OtpErlangTuple fileLine = (OtpErlangTuple) t.elementAt(1);
        final String filename = Util.stringValue(fileLine.elementAt(0));
        final OtpErlangLong lineL = (OtpErlangLong) fileLine.elementAt(1);
        if (!filename.isEmpty()) {
            int line = 1;
            try {
                line = lineL.intValue();
            } catch (final OtpErlangRangeException e) {
                ErlLogger.error(e);
            }
            if (line <= 0) {
                line = 1;
            }
            String msg = warnings.get(i);
            final int j = msg.indexOf(": ");
            if (j != -1) {
                msg = msg.substring(j + 1);
            }
            final IErlElementLocator model = ErlangEngine.getInstance().getModel();
            DialyzerMarkerUtils.addDialyzerWarningMarker(model, filename, line, msg);
        }
    }
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple)

Aggregations

OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)23 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)18 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)18 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)16 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)8 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)7 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)4 ArrayList (java.util.ArrayList)3 RpcException (org.erlide.runtime.rpc.RpcException)3 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)3 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)1 OtpErlangException (com.ericsson.otp.erlang.OtpErlangException)1 OtpErlangInt (com.ericsson.otp.erlang.OtpErlangInt)1 OtpErlangPid (com.ericsson.otp.erlang.OtpErlangPid)1 TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)1 Date (java.util.Date)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IMarker (org.eclipse.core.resources.IMarker)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1