Search in sources :

Example 21 with ErlModelException

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

the class AddRefacHandler method getBinPath.

// gets original binary path
private String getBinPath(final String callbackModule) {
    String path;
    try {
        if (ErlangEngine.getInstance().getModel().findModule(callbackModule) == null) {
            return null;
        }
        final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(ErlangEngine.getInstance().getModel().findModule(callbackModule));
        path = project.getWorkspaceProject().getLocation().append(project.getProperties().getOutputDir()).append(callbackModule + ".beam").toOSString();
        return path;
    } catch (final ErlModelException e) {
        return null;
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlModelException(org.erlide.engine.model.ErlModelException)

Example 22 with ErlModelException

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

the class UserAdhocRefactoring method load.

/**
 * Loading user's callback module
 *
 * @return
 */
public boolean load() {
    String callbackPath;
    try {
        if (ErlangEngine.getInstance().getModel().findModule(refac.getCallbackModule()) == null) {
            return false;
        }
        final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(ErlangEngine.getInstance().getModel().findModule(refac.getCallbackModule()));
        callbackPath = project.getWorkspaceProject().getLocation().append(project.getProperties().getOutputDir()).toString();
    } catch (final ErlModelException e) {
        return false;
    }
    final RpcResult res = WranglerBackendManager.getRefactoringBackend().callWithoutParser("load_callback_mod_eclipse", "ss", refac.getCallbackModule(), callbackPath);
    if (!res.isOk()) {
        return false;
    }
    return true;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlModelException(org.erlide.engine.model.ErlModelException) RpcResult(org.erlide.runtime.rpc.RpcResult)

Example 23 with ErlModelException

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

the class ErlangMainTab method createControl.

/**
 * @wbp.parser.entryPoint
 */
@Override
public void createControl(final Composite parent) {
    final Composite comp = new Composite(parent, SWT.NONE);
    setControl(comp);
    final GridLayout topLayout = new GridLayout();
    comp.setLayout(topLayout);
    createProjectsGroup(comp);
    createStartGroup(comp);
    Collection<IErlProject> projects;
    try {
        projects = ErlangEngine.getInstance().getModel().getErlangProjects();
        final List<String> ps = new ArrayList<>();
        for (final IErlProject p : projects) {
            ps.add(p.getName());
        }
    } catch (final ErlModelException e) {
        ErlLogger.warn(e);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ErlModelException(org.erlide.engine.model.ErlModelException) ArrayList(java.util.ArrayList)

Example 24 with ErlModelException

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

the class ErlangExternalsContentProvider method getChildren.

@Override
public Object[] getChildren(final Object parentElement0) {
    Object parentElement = parentElement0;
    try {
        if (parentElement instanceof IProject) {
            final IProject project = (IProject) parentElement;
            if (project.isOpen()) {
                parentElement = ErlangEngine.getInstance().getModel().findProject(project);
            }
        }
        if (parentElement instanceof IErlModule) {
            return erlangFileContentProvider.getChildren(parentElement);
        }
        if (parentElement instanceof IParent) {
            if (parentElement instanceof IOpenable) {
                final IOpenable openable = (IOpenable) parentElement;
                openable.open(null);
            }
            final IParent parent = (IParent) parentElement;
            final Collection<IErlElement> children = parent.getChildrenOfKind(ErlElementKind.EXTERNAL_ROOT, ErlElementKind.EXTERNAL_APP, ErlElementKind.EXTERNAL_FOLDER);
            return children.toArray();
        }
    } catch (final ErlModelException e) {
    }
    return ErlangExternalsContentProvider.NO_CHILDREN;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IOpenable(org.erlide.engine.model.root.IOpenable) IParent(org.erlide.engine.model.IParent) ErlModelException(org.erlide.engine.model.ErlModelException) IErlModule(org.erlide.engine.model.root.IErlModule) IProject(org.eclipse.core.resources.IProject)

Example 25 with ErlModelException

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

the class ErlangFileContentProvider method getChildren.

/**
 * Return the model elements for a *.erl IFile or NO_CHILDREN for otherwise.
 */
@Override
public Object[] getChildren(final Object parentElement0) {
    Object parentElement = parentElement0;
    try {
        if (parentElement instanceof IFile) {
            parentElement = ErlangEngine.getInstance().getModel().findModule((IFile) parentElement);
        }
        if (parentElement instanceof IOpenable) {
            final IOpenable openable = (IOpenable) parentElement;
            openable.open(null);
        }
        if (parentElement instanceof IParent) {
            final IParent parent = (IParent) parentElement;
            final Collection<IErlElement> children = parent.getChildren();
            return children.toArray();
        }
    } catch (final ErlModelException e) {
        ErlLogger.warn(e);
    }
    return ErlangFileContentProvider.NO_CHILDREN;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IOpenable(org.erlide.engine.model.root.IOpenable) IFile(org.eclipse.core.resources.IFile) IParent(org.erlide.engine.model.IParent) ErlModelException(org.erlide.engine.model.ErlModelException)

Aggregations

ErlModelException (org.erlide.engine.model.ErlModelException)45 IErlElement (org.erlide.engine.model.IErlElement)21 IErlModule (org.erlide.engine.model.root.IErlModule)21 IErlModel (org.erlide.engine.model.root.IErlModel)9 IErlProject (org.erlide.engine.model.root.IErlProject)9 ArrayList (java.util.ArrayList)8 IOpenable (org.erlide.engine.model.root.IOpenable)7 CoreException (org.eclipse.core.runtime.CoreException)6 IProject (org.eclipse.core.resources.IProject)5 IResource (org.eclipse.core.resources.IResource)5 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)4 IFile (org.eclipse.core.resources.IFile)4 IParent (org.erlide.engine.model.IParent)4 IErlFunction (org.erlide.engine.model.erlang.IErlFunction)4 IErlFunctionClause (org.erlide.engine.model.erlang.IErlFunctionClause)4 Composite (org.eclipse.swt.widgets.Composite)3 ErlangEditor (org.erlide.ui.editors.erl.ErlangEditor)3 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2