Search in sources :

Example 1 with IPathVariableManager

use of org.eclipse.core.resources.IPathVariableManager in project erlide_eclipse by erlang.

the class BuilderHelper method getIncludeDirs.

public Collection<IPath> getIncludeDirs(final IProject project) {
    final Collection<IPath> includeDirs = new ArrayList<>();
    final IErlProject erlProject = ErlangEngine.getInstance().getModel().getErlangProject(project);
    if (erlProject == null) {
        return includeDirs;
    }
    final Collection<IPath> projectIncludeDirs = erlProject.getProperties().getIncludeDirs();
    final IPathVariableManager pvm = ResourcesPlugin.getWorkspace().getPathVariableManager();
    for (final IPath inc : projectIncludeDirs) {
        final IPath incPath = URIUtil.toPath(pvm.resolveURI(URIUtil.toURI(inc)));
        if (incPath.isAbsolute()) {
            includeDirs.add(incPath);
        } else {
            final IFolder folder = project.getFolder(incPath);
            if (folder != null && folder.exists()) {
                final IPath location = folder.getLocation();
                if (location != null) {
                    includeDirs.add(location);
                } else {
                    ErlLogger.warn("No location for %s", folder);
                }
            } else {
                if (!BuilderHelper.reportedMissingFolders.contains(folder)) {
                    ErlLogger.warn("Inexistent location for %s", folder);
                }
                BuilderHelper.reportedMissingFolders.add(folder);
            }
        }
    }
    return includeDirs;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IPath(org.eclipse.core.runtime.IPath) IPathVariableManager(org.eclipse.core.resources.IPathVariableManager) ArrayList(java.util.ArrayList) IFolder(org.eclipse.core.resources.IFolder)

Example 2 with IPathVariableManager

use of org.eclipse.core.resources.IPathVariableManager in project erlide_eclipse by erlang.

the class ErlModel method closing.

@Override
protected void closing(final Object info) throws ErlModelException {
    final IPathVariableManager pvm = ResourcesPlugin.getWorkspace().getPathVariableManager();
    pvm.removeChangeListener(fPathVariableChangeListener);
}
Also used : IPathVariableManager(org.eclipse.core.resources.IPathVariableManager)

Example 3 with IPathVariableManager

use of org.eclipse.core.resources.IPathVariableManager in project erlide_eclipse by erlang.

the class ErlModel method getPathVars.

@Override
public OtpErlangList getPathVars() {
    // if (fCachedPathVars == null) {
    final IPathVariableManager pvm = ResourcesPlugin.getWorkspace().getPathVariableManager();
    final String[] names = pvm.getPathVariableNames();
    final OtpErlangObject[] objects = new OtpErlangObject[names.length];
    for (int i = 0; i < names.length; i++) {
        final String name = names[i];
        final String value = URIUtil.toPath(pvm.getURIValue(name)).toPortableString();
        objects[i] = new OtpErlangTuple(new OtpErlangObject[] { new OtpErlangString(name), new OtpErlangString(value) });
    }
    fCachedPathVars = new OtpErlangList(objects);
    // }
    return fCachedPathVars;
}
Also used : IPathVariableManager(org.eclipse.core.resources.IPathVariableManager) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 4 with IPathVariableManager

use of org.eclipse.core.resources.IPathVariableManager in project erlide_eclipse by erlang.

the class ErlModel method setupWorkspaceListeners.

public final void setupWorkspaceListeners() {
    final IWorkspace workspace = ResourcesPlugin.getWorkspace();
    final IPathVariableManager pvm = workspace.getPathVariableManager();
    pvm.addChangeListener(fPathVariableChangeListener);
    final IResourceChangeListener listener = new ResourceChangeListener();
    workspace.addResourceChangeListener(listener);
}
Also used : IPathVariableManager(org.eclipse.core.resources.IPathVariableManager) IWorkspace(org.eclipse.core.resources.IWorkspace) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener)

Example 5 with IPathVariableManager

use of org.eclipse.core.resources.IPathVariableManager in project erlide_eclipse by erlang.

the class IErlModelTest method getPathVars.

// IErlElement innermostThat(final IErlElement el,
// final IErlangFirstThat firstThat);
// OtpErlangList getPathVars();
@Test
public void getPathVars() throws Exception {
    final OtpErlangList pathVars = model.getPathVars();
    final IPathVariableManager pvm = ResourcesPlugin.getWorkspace().getPathVariableManager();
    final String[] pathVariableNames = pvm.getPathVariableNames();
    final int n = pathVariableNames.length;
    assertEquals(n, pathVars.arity());
    final URI path = ErlideTestUtils.getTmpURIPath("");
    pvm.setURIValue(IErlModelTest.PV, path);
    final OtpErlangList pathVars2 = model.getPathVars();
    assertEquals(n + 1, pathVars2.arity());
    final OtpErlangTuple t = (OtpErlangTuple) pathVars2.elementAt(0);
    final String name = Util.stringValue(t.elementAt(0));
    final String value = pvm.getURIValue(name).getPath();
    final String value2 = Util.stringValue(t.elementAt(1));
    assertEquals(value, value2);
}
Also used : IPathVariableManager(org.eclipse.core.resources.IPathVariableManager) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) URI(java.net.URI) Test(org.junit.Test)

Aggregations

IPathVariableManager (org.eclipse.core.resources.IPathVariableManager)17 URI (java.net.URI)10 IWorkspace (org.eclipse.core.resources.IWorkspace)9 CoreException (org.eclipse.core.runtime.CoreException)5 URISyntaxException (java.net.URISyntaxException)4 IPath (org.eclipse.core.runtime.IPath)4 IOException (java.io.IOException)3 Path (org.eclipse.core.runtime.Path)3 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)2 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)2 ArrayList (java.util.ArrayList)2 IFile (org.eclipse.core.resources.IFile)2 IFolder (org.eclipse.core.resources.IFolder)2 CheckConfiguration (com.avaloq.tools.ddk.checkcfg.checkcfg.CheckConfiguration)1 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProject (org.eclipse.core.resources.IProject)1