Search in sources :

Example 41 with IErlModule

use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.

the class SimpleCodeInspectionHandler method createErlModuleList.

private ArrayList<IErlElement> createErlModuleList(final OtpErlangList modList) {
    final ArrayList<IErlElement> modules = new ArrayList<>();
    for (int i = 0; i < modList.arity(); ++i) {
        IErlModule m;
        try {
            m = extractModule(modList.elementAt(i));
            modules.add(m);
        } catch (final ErlModelException e) {
        }
    }
    return modules;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) ErlModelException(org.erlide.engine.model.ErlModelException) ArrayList(java.util.ArrayList) IErlModule(org.erlide.engine.model.root.IErlModule)

Example 42 with IErlModule

use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.

the class DebuggerTraceView method gotoModuleLine.

// @Override
// public void createPartControl(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();
// final String msg = o == null ? "" : o.toString(); //$NON-NLS-1$
// getViewSite().getActionBars().getStatusLineManager()
// .setMessage(msg);
// 
// }
// });
// 
// viewer.getTree().addMouseListener(new MouseListener() {
// 
// 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) {
// }
// 
// }
// }
// 
// public void mouseDown(final MouseEvent e) {
// }
// 
// public void mouseUp(final MouseEvent e) {
// }
// 
// });
// // PlatformUI.getWorkbench().getWorkingSetManager()
// // .addPropertyChangeListener(getWorkingSetListener());
// 
// // registerContextMenu();
// // initDragAndDrop();
// 
// }
protected void gotoModuleLine(final String moduleName, final int line) {
    final IWorkbenchWindow window = ErlideUIPlugin.getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    final IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return;
    }
    IEditorPart part = null;
    final IErlElementLocator model = ErlangEngine.getInstance().getModel();
    IErlModule module;
    try {
        module = model.findModule(moduleName);
    } catch (final ErlModelException e) {
        ErlLogger.error(e);
        return;
    }
    IEditorInput input = null;
    input = EditorUtility.getEditorInput(module);
    if (input != null) {
        final String editorId = EditorUtility.getEditorID(input, module);
        if (editorId != null) {
            try {
                part = page.openEditor(input, editorId);
            } catch (final PartInitException e) {
                ErlideUIPlugin.errorDialog(window.getShell(), "Go to File", "Exception occurred", // 
                e);
            }
        }
    }
    if (part instanceof ErlangEditor) {
        part.setFocus();
        final ErlangEditor ee = (ErlangEditor) part;
        final IDocument d = ee.getDocument();
        int lineStart;
        int lineLength;
        try {
            lineStart = d.getLineOffset(line - 1);
            lineLength = d.getLineLength(line - 1);
            EditorUtility.revealInEditor(ee, lineStart, lineLength - 1);
        } catch (final BadLocationException e) {
            ErlLogger.error(e);
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) IEditorPart(org.eclipse.ui.IEditorPart) ErlModelException(org.erlide.engine.model.ErlModelException) IErlModule(org.erlide.engine.model.root.IErlModule) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor)

Example 43 with IErlModule

use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.

the class InterpretHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final InterpretedModulesView view = (InterpretedModulesView) HandlerUtil.getActivePart(event);
    final String commandId = event.getCommand().getId();
    if (commandId.equals(InterpretHandler.INTERPRET_COMMAND_ID)) {
        final List<IErlModule> modules = DebugTab.getModulesFromAddModulesDialog(view.getSite().getShell());
        for (final IErlModule module : modules) {
            view.interpretOrDeinterpret(module, true);
        }
    } else if (commandId.equals(InterpretHandler.DEINTERPRET_COMMAND_ID)) {
        final ISelection selection = HandlerUtil.getCurrentSelection(event);
        if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
            final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
            for (final Object o : structuredSelection.toArray()) {
                final IErlModule module = (IErlModule) o;
                view.interpretOrDeinterpret(module, false);
            }
        }
    } else {
        throw new ExecutionException("bad command id");
    }
    return null;
}
Also used : IErlModule(org.erlide.engine.model.root.IErlModule) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 44 with IErlModule

use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.

the class EditorConfiguration method getReconciler.

@Override
public IReconciler getReconciler(final ISourceViewer sourceViewer) {
    final ErlReconcilingStrategy strategy = new ErlReconcilingStrategy(editor);
    final IErlModule module = editor != null ? editor.getModule() : null;
    final String path = module != null ? module.getFilePath() : null;
    reconciler = new ErlReconciler(strategy, true, true, path, module, getEditor());
    reconciler.setProgressMonitor(new NullProgressMonitor());
    reconciler.setIsAllowedToModifyDocument(false);
    reconciler.setDelay(500);
    return reconciler;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ErlReconcilingStrategy(org.erlide.ui.editors.internal.reconciling.ErlReconcilingStrategy) IErlModule(org.erlide.engine.model.root.IErlModule) ErlReconciler(org.erlide.ui.editors.internal.reconciling.ErlReconciler)

Example 45 with IErlModule

use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.

the class BreakpointUtils method getElement.

public static IErlElement getElement(final ILineBreakpoint breakpoint) {
    final IErlElementLocator model = ErlangEngine.getInstance().getModel();
    final IErlElement element = model.findElement(breakpoint.getMarker().getResource());
    if (element instanceof IErlModule) {
        final IErlModule m = (IErlModule) element;
        try {
            m.open(null);
            final int lineNumber = breakpoint.getLineNumber();
            return m.getElementAtLine(lineNumber - 1);
        } catch (final Exception e) {
            ErlLogger.warn(e);
        }
    }
    return null;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlModule(org.erlide.engine.model.root.IErlModule) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint)

Aggregations

IErlModule (org.erlide.engine.model.root.IErlModule)191 Test (org.junit.Test)66 IErlProject (org.erlide.engine.model.root.IErlProject)57 IErlElement (org.erlide.engine.model.IErlElement)35 IFile (org.eclipse.core.resources.IFile)26 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)26 ErlModelException (org.erlide.engine.model.ErlModelException)22 IPath (org.eclipse.core.runtime.IPath)21 ErlProject (org.erlide.engine.internal.model.root.ErlProject)21 File (java.io.File)20 IErlModel (org.erlide.engine.model.root.IErlModel)18 Path (org.eclipse.core.runtime.Path)17 IProject (org.eclipse.core.resources.IProject)16 IResource (org.eclipse.core.resources.IResource)14 ArrayList (java.util.ArrayList)13 CoreException (org.eclipse.core.runtime.CoreException)10 IEditorPart (org.eclipse.ui.IEditorPart)10 IParent (org.erlide.engine.model.IParent)10 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)9 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)9