Search in sources :

Example 11 with AbstractErlangEditor

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

the class CompileAction method run.

@Override
public void run() {
    final AbstractErlangEditor editor = (AbstractErlangEditor) getSite().getPage().getActiveEditor();
    final IErlModule module = editor.getModule();
    if (module == null) {
        return;
    }
    final IResource resource = module.getResource();
    final IProject project = resource.getProject();
    if (project == null) {
        return;
    }
    final IErlProject eproject = ErlangEngine.getInstance().getModelUtilService().getProject(module);
    if (eproject == null) {
        return;
    }
    final IOtpRpc b = BackendCore.getBuildBackend(eproject);
    final BuildResource bres = new BuildResource(resource);
    final CompilerOptions prefs = new CompilerOptions(project);
    prefs.load();
    final OtpErlangList compilerOptions = prefs.export();
    final IErlProject erlProject = ErlangEngine.getInstance().getModel().getErlangProject(project);
    if ("erl".equals(resource.getFileExtension())) {
        helper.compileErl(project, bres, erlProject.getProperties().getOutputDir().toString(), b, compilerOptions);
    }
    if ("yrl".equals(resource.getFileExtension())) {
        helper.compileYrl(project, bres, b, compilerOptions);
    }
    final ErlEditorActionBarContributor status = (ErlEditorActionBarContributor) editor.getEditorSite().getActionBarContributor();
    status.displayMessage(String.format("File '%s' was compiled.", resource.getName()));
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) IErlModule(org.erlide.engine.model.root.IErlModule) CompilerOptions(org.erlide.core.builder.CompilerOptions) ErlEditorActionBarContributor(org.erlide.ui.editors.erl.ErlEditorActionBarContributor) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject) BuildResource(org.erlide.core.builder.BuildResource) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) IOtpRpc(org.erlide.runtime.rpc.IOtpRpc)

Example 12 with AbstractErlangEditor

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

the class GotoAnnotationAction method run.

@Override
public void run() {
    final AbstractErlangEditor e = (AbstractErlangEditor) getTextEditor();
    e.gotoAnnotation(fForward);
}
Also used : AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor)

Example 13 with AbstractErlangEditor

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

the class OpenAction method run.

@Override
public void run(final ITextSelection selection) {
    try {
        final IEditorPart activeEditor = getSite().getPage().getActiveEditor();
        final int offset = selection.getOffset();
        ITextEditor textEditor = null;
        OpenResult openResult = null;
        IErlElement element = null;
        IErlProject project = null;
        IErlModule module = null;
        final IErlModel model = ErlangEngine.getInstance().getModel();
        if (activeEditor instanceof AbstractErlangEditor) {
            final AbstractErlangEditor editor = (AbstractErlangEditor) activeEditor;
            textEditor = editor;
            editor.reconcileNow();
            final String scannerName = editor.getScannerName();
            module = editor.getModule();
            project = editor.getProject();
            openResult = ErlangEngine.getInstance().getOpenService().open(scannerName, offset, ErlangEngine.getInstance().getModelUtilService().getImportsAsList(module), project.getProperties().getExternalModules(), model.getPathVars());
            ErlLogger.debug("open " + openResult);
            element = editor.getElementAt(offset, true);
        } else if (activeEditor instanceof ITextEditor) {
            textEditor = (ITextEditor) activeEditor;
            final String text = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()).get();
            openResult = ErlangEngine.getInstance().getOpenService().openText(text, offset);
            final IFile file = textEditor.getEditorInput().getAdapter(IFile.class);
            if (file != null) {
                final IProject p = file.getProject();
                if (p != null) {
                    project = model.findProject(p);
                }
            }
        }
        if (openResult != null) {
            helper.openOpenResult(textEditor, module, offset, project, openResult, element);
        }
    } catch (final Exception e) {
        ErlLogger.error(e);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IFile(org.eclipse.core.resources.IFile) IErlModel(org.erlide.engine.model.root.IErlModel) IEditorPart(org.eclipse.ui.IEditorPart) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) IErlElement(org.erlide.engine.model.IErlElement) OpenResult(org.erlide.engine.services.search.OpenResult) IErlModule(org.erlide.engine.model.root.IErlModule)

Aggregations

AbstractErlangEditor (org.erlide.ui.editors.erl.AbstractErlangEditor)13 IErlModule (org.erlide.engine.model.root.IErlModule)8 IErlProject (org.erlide.engine.model.root.IErlProject)4 ErlangEditor (org.erlide.ui.editors.erl.ErlangEditor)4 IEditorPart (org.eclipse.ui.IEditorPart)3 IErlElement (org.erlide.engine.model.IErlElement)3 OpenResult (org.erlide.engine.services.search.OpenResult)3 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IResource (org.eclipse.core.resources.IResource)2 CoreException (org.eclipse.core.runtime.CoreException)2 ITextSelection (org.eclipse.jface.text.ITextSelection)2 IOtpRpc (org.erlide.runtime.rpc.IOtpRpc)2 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 ITypedRegion (org.eclipse.jface.text.ITypedRegion)1 TextSelection (org.eclipse.jface.text.TextSelection)1 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)1