Search in sources :

Example 6 with ErlangEditor

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

the class WranglerUtils method notifyErlide.

/**
 * Notifies Erlide about the changed files.
 *
 * @param changedFiles
 *            changed files
 */
public static void notifyErlide(final List<ChangedFile> changedFiles) {
    final IErlModel model = ErlangEngine.getInstance().getModel();
    for (final ChangedFile f : changedFiles) {
        IFile file;
        try {
            file = WranglerUtils.getFileFromPath(f.getNewPath());
            final IErlElement element = model.findElement(file);
            final IErlModule m = (IErlModule) element;
            m.resourceChanged(null);
            final IEditorPart editor = GlobalParameters.getEditor();
            if (editor instanceof ErlangEditor) {
                ((ErlangEditor) editor).resetAndCacheScannerAndParser();
            }
            model.notifyChange(m);
        } catch (final Exception e) {
            ErlLogger.error(e);
        }
    }
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IFile(org.eclipse.core.resources.IFile) IErlModel(org.erlide.engine.model.root.IErlModel) IErlModule(org.erlide.engine.model.root.IErlModule) IEditorPart(org.eclipse.ui.IEditorPart) ChangedFile(org.erlide.wrangler.refactoring.backend.ChangedFile) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) BadLocationException(org.eclipse.jface.text.BadLocationException) IOException(java.io.IOException) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor)

Example 7 with ErlangEditor

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

the class ExpandCollapseAllHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
    if (!(activeEditor instanceof ErlangEditor)) {
        return null;
    }
    final ErlangEditor editor = (ErlangEditor) activeEditor;
    final boolean collapse = "collapse".equals(event.getParameter("org.erlide.ui.commands.expandCollapseParameter"));
    final boolean comments = "comments".equals(event.getParameter("org.erlide.ui.commands.foldWhatParameter"));
    editor.expandCollapseFunctionsOrComments(collapse, comments);
    return null;
}
Also used : IEditorPart(org.eclipse.ui.IEditorPart) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor)

Example 8 with ErlangEditor

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

the class DefaultErlangFoldingStructureProvider method install.

@Override
public void install(final ITextEditor editor, final ProjectionViewer viewer) {
    if (editor instanceof ErlangEditor) {
        fFirstTimeInitialCollapse = true;
        fEditor = editor;
        fViewer = viewer;
        fViewer.addProjectionListener(this);
        final IErlModel mdl = ErlangEngine.getInstance().getModel();
        mdl.addModelChangeListener(this);
    }
}
Also used : IErlModel(org.erlide.engine.model.root.IErlModel) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor)

Example 9 with ErlangEditor

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

the class EditorUtility method getAllErlangEditors.

public static Collection<IEditorPart> getAllErlangEditors() {
    final List<IEditorPart> result = Lists.newArrayList();
    final IWorkbench workbench = ErlideUIPlugin.getDefault().getWorkbench();
    for (final IWorkbenchWindow i : workbench.getWorkbenchWindows()) {
        for (final IWorkbenchPage j : i.getPages()) {
            for (final IEditorReference editorReference : j.getEditorReferences()) {
                final IEditorPart editorPart = editorReference.getEditor(false);
                if (editorPart instanceof ErlangEditor) {
                    result.add(editorPart);
                }
            }
        }
    }
    return result;
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor)

Example 10 with ErlangEditor

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

the class ConvertMultiStringQuickFix method appliesAt.

@Override
public boolean appliesAt(final IQuickAssistInvocationContext invocationContext) {
    final ISourceViewer viewer = invocationContext.getSourceViewer();
    final IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (!(editorPart instanceof ErlangEditor)) {
        return false;
    }
    final ErlangEditor editor = (ErlangEditor) editorPart;
    if (editor.getViewer() != viewer) {
        return false;
    }
    final IErlModule module = editor.getModule();
    final int offset = invocationContext.getOffset();
    final ErlToken token = module.getScanner().getTokenAt(offset);
    if (token == null || token.getKind() != ErlToken.KIND_STRING) {
        return false;
    }
    final IDocument doc = viewer.getDocument();
    String text;
    try {
        text = doc.get(token.getOffset(), token.getLength());
        if (text.contains("\n")) {
            return true;
        }
    } catch (final BadLocationException e) {
    }
    return false;
}
Also used : IErlModule(org.erlide.engine.model.root.IErlModule) IEditorPart(org.eclipse.ui.IEditorPart) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) ErlToken(org.erlide.engine.services.parsing.ErlToken) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException) 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