Search in sources :

Example 11 with ErlangEditor

use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.

the class ErlangSearchResult method isShownInEditor.

@Override
public boolean isShownInEditor(final Match match, final IEditorPart editor) {
    final ErlangSearchElement ese = (ErlangSearchElement) match.getElement();
    final IFile file = ResourceUtil.getFileFromLocation(ese.getModuleName());
    if (editor instanceof ErlangEditor) {
        final AbstractErlangEditor erlangEditor = (AbstractErlangEditor) editor;
        final IErlModule module = erlangEditor.getModule();
        if (module != null) {
            if (file != null) {
                return file.equals(module.getResource());
            }
            return ese.getModuleName().equals(module.getFilePath());
        }
    }
    return false;
}
Also used : IFile(org.eclipse.core.resources.IFile) IErlModule(org.erlide.engine.model.root.IErlModule) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor)

Example 12 with ErlangEditor

use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.

the class ErlangSearchResultPage method showMatch.

@Override
protected void showMatch(final Match match, final int offset, final int length, final boolean activate) throws PartInitException {
    final Object element = match.getElement();
    if (element instanceof ErlangSearchElement) {
        final ErlangSearchElement ese = (ErlangSearchElement) element;
        final IErlModule module = ese.getModule();
        final IEditorPart editor = EditorUtility.openInEditor(module);
        if (offset != 0) {
            if (editor instanceof ErlangEditor) {
                final AbstractErlangEditor ee = (AbstractErlangEditor) editor;
                ee.selectAndReveal(offset, length);
            } else if (editor != null) {
                showWithMarker(editor, module, offset, length);
            }
        }
    }
}
Also used : IErlModule(org.erlide.engine.model.root.IErlModule) IEditorPart(org.eclipse.ui.IEditorPart) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor)

Example 13 with ErlangEditor

use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.

the class OpenItemAction method run.

@Override
public void run() {
    log.info("Open item!");
    final ISelection selection = viewer.getSelection();
    if (!(selection instanceof ITreeSelection)) {
        final IStatus executionStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Internall error occured: bad sellection type", null);
        StatusManager.getManager().handle(executionStatus, StatusManager.SHOW);
        return;
    }
    final ITreeSelection treeSelection = (ITreeSelection) selection;
    final StatsTreeObject obj = (StatsTreeObject) treeSelection.getFirstElement();
    if (obj.getClass().equals(ModuleStats.class)) {
        openInEditor(obj.getLabel() + ".erl");
    } else if (obj.getClass().equals(FunctionStats.class)) {
        final FunctionStats fs = (FunctionStats) obj;
        final String moduleName = ((StatsTreeObject) fs.getParent()).getLabel();
        final IEditorPart p = openInEditor(moduleName + ".erl");
        if (p == null || !(p instanceof ErlangEditor)) {
            return;
        }
        final ErlangEditor editor = (ErlangEditor) p;
        IErlModule module;
        try {
            module = ErlangEngine.getInstance().getModel().findModule(moduleName);
            final IErlFunction f = module.findFunction(new ErlangFunction(fs.getLabel(), fs.getArity()));
            editor.setSelection(f);
        } catch (final ErlModelException e) {
            ErlLogger.error(e);
        }
    } else {
    // disabled
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IErlFunction(org.erlide.engine.model.erlang.IErlFunction) ErlangFunction(org.erlide.engine.model.erlang.ErlangFunction) IEditorPart(org.eclipse.ui.IEditorPart) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) ErlModelException(org.erlide.engine.model.ErlModelException) ISelection(org.eclipse.jface.viewers.ISelection) IErlModule(org.erlide.engine.model.root.IErlModule) FunctionStats(org.erlide.cover.views.model.FunctionStats) StatsTreeObject(org.erlide.cover.views.model.StatsTreeObject) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor)

Example 14 with ErlangEditor

use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.

the class ErlBreakpointAdapterFactory method getAdapter.

@Override
@Nullable
public <@Nullable T> T getAdapter(final Object adaptableObject, final Class<@Nullable T> adapterType) {
    if (adaptableObject instanceof ErlangEditor) {
        final AbstractErlangEditor editorPart = (AbstractErlangEditor) adaptableObject;
        final IResource resource = editorPart.getEditorInput().getAdapter(IResource.class);
        if (resource != null) {
            final String extension = resource.getFileExtension();
            if (extension != null && "erl".equals(extension)) {
                return adapterType.cast(new ErlLineBreakpointAdapter());
            }
        }
    }
    return null;
}
Also used : IResource(org.eclipse.core.resources.IResource) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 15 with ErlangEditor

use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.

the class ShowOutlineAction method run.

@Override
public void run() {
    if (getTextEditor() instanceof ErlangEditor) {
        final ErlangEditor editor = (ErlangEditor) getTextEditor();
        final Shell parent = getTextEditor().getSite().getShell();
        final QuickOutlinePopupDialog quickOutlinePopupDialog = new QuickOutlinePopupDialog(parent, SWT.NONE, editor, editor, editor);
        quickOutlinePopupDialog.open();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) QuickOutlinePopupDialog(org.erlide.ui.editors.erl.outline.QuickOutlinePopupDialog) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor)

Aggregations

ErlangEditor (org.erlide.ui.editors.erl.ErlangEditor)16 IEditorPart (org.eclipse.ui.IEditorPart)9 IErlModule (org.erlide.engine.model.root.IErlModule)7 AbstractErlangEditor (org.erlide.ui.editors.erl.AbstractErlangEditor)6 ErlModelException (org.erlide.engine.model.ErlModelException)4 BadLocationException (org.eclipse.jface.text.BadLocationException)3 ITextSelection (org.eclipse.jface.text.ITextSelection)3 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 IFile (org.eclipse.core.resources.IFile)2 IDocument (org.eclipse.jface.text.IDocument)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IEditorReference (org.eclipse.ui.IEditorReference)2 PartInitException (org.eclipse.ui.PartInitException)2 IErlElement (org.erlide.engine.model.IErlElement)2 IErlModel (org.erlide.engine.model.root.IErlModel)2 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 File (java.io.File)1 IOException (java.io.IOException)1 IResource (org.eclipse.core.resources.IResource)1