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;
}
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);
}
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;
}
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);
}
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);
}
Aggregations