Search in sources :

Example 21 with ErlangProjectProperties

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

the class ErlProject method addExternals.

private void addExternals(final List<IErlElement> children) {
    final ErlangProjectProperties myProperties = getProperties();
    final String externalIncludes = myProperties.getExternalIncludes();
    final String externalModules = myProperties.getExternalModules();
    final Collection<IPath> includeDirs = myProperties.getIncludeDirs();
    final List<String> projectIncludes = Lists.newArrayList();
    for (final IPath path : new PathResolver().resolvePaths(includeDirs)) {
        if (path.isAbsolute() && !fProject.getLocation().isPrefixOf(path)) {
            final Collection<String> includes = ErlangEngine.getInstance().getOpenService().getIncludesInDir(path.toPortableString());
            if (includes != null) {
                for (final String include : includes) {
                    projectIncludes.add(path.append(include).toPortableString());
                }
            }
        }
    }
    if (!externalIncludes.isEmpty() || !externalModules.isEmpty() || !projectIncludes.isEmpty()) {
        final IErlExternalRoot external = new ErlExternalReferenceEntryList(this, "Externals", externalIncludes, projectIncludes, externalModules);
        children.add(external);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) IErlExternalRoot(org.erlide.engine.model.root.IErlExternalRoot) PathResolver(org.erlide.engine.model.root.PathResolver)

Example 22 with ErlangProjectProperties

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

the class ErlideTestUtils method createErlProject.

public static IErlProject createErlProject(final String name) throws CoreException {
    final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    final IProject project2 = root.getProject(name);
    try {
        project2.delete(true, null);
    } catch (final CoreException x) {
    // ignore
    }
    final IErlProject erlProject = ErlangEngine.getInstance().getModel().newProject(name);
    erlProject.getBuilderProperties().setBuilderTool(BuilderTool.INTERNAL);
    final IProject project = erlProject.getWorkspaceProject();
    final ErlangProjectProperties prefs = erlProject.getProperties();
    final List<IPath> srcDirs = new ArrayList<>();
    ErlideTestUtils.createFolder(project2, "src");
    srcDirs.add(new Path("src"));
    prefs.setSourceDirs(srcDirs);
    ErlideTestUtils.buildPaths(root, project, srcDirs);
    final List<IPath> includeDirs = new ArrayList<>();
    ErlideTestUtils.createFolder(project2, "include");
    includeDirs.add(new Path("include"));
    ErlideTestUtils.buildPaths(root, project, includeDirs);
    prefs.setIncludeDirs(includeDirs);
    ErlideTestUtils.createFolder(project2, "ebin");
    final IPath ebinDir = new Path("ebin");
    ErlideTestUtils.buildPaths(root, project, Lists.newArrayList(ebinDir));
    prefs.setOutputDir(ebinDir);
    ErlideTestUtils.projects.add(erlProject);
    return erlProject;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) IPath(org.eclipse.core.runtime.IPath) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject)

Example 23 with ErlangProjectProperties

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

the class EmakeConfiguratorTest method sourceDirectoriesShouldBeConfigured.

@Test
public void sourceDirectoriesShouldBeConfigured() {
    final StringConcatenation _builder = new StringConcatenation();
    _builder.append("{\'src1/*\',[debug_info]}.");
    _builder.newLine();
    _builder.append("{\'src2/*\',[debug_info]}.");
    _builder.newLine();
    final String input = _builder.toString();
    final ErlangProjectProperties actual = configurator.decodeConfig(input);
    final Path _path = new Path("src1");
    final Path _path_1 = new Path("src2");
    Truth.<IPath, Iterable<IPath>>assertThat(actual.getSourceDirs()).containsAtLeastElementsIn(Collections.<Object>unmodifiableList(CollectionLiterals.<Object>newArrayList(_path, _path_1)));
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 24 with ErlangProjectProperties

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

the class EmakeConfiguratorTest method includeDirectoriesShouldBeConfigured.

@Test
public void includeDirectoriesShouldBeConfigured() {
    final StringConcatenation _builder = new StringConcatenation();
    _builder.append("{\'src1/*\',[debug_info,{i,\"myinclude\"}]}.");
    _builder.newLine();
    final String input = _builder.toString();
    final ErlangProjectProperties actual = configurator.decodeConfig(input);
    final IterableSubject _assertThat = Truth.<IPath, Iterable<IPath>>assertThat(actual.getIncludeDirs());
    final Path _path = new Path("myinclude");
    _assertThat.contains(_path);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IterableSubject(com.google.common.truth.IterableSubject) IPath(org.eclipse.core.runtime.IPath) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 25 with ErlangProjectProperties

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

the class RebarConfiguratorTest method handleMultipleOptions.

@Test
public void handleMultipleOptions() {
    final StringConcatenation _builder = new StringConcatenation();
    _builder.append("{erl_opts, [{i, \"inc1\"}]}.");
    _builder.newLine();
    _builder.append("{erl_opts, [{src_dirs, [\"src1\", \"src2\"]}]}.");
    _builder.newLine();
    _builder.append("{erl_opts, [{i, \"inc2\"}]}.");
    _builder.newLine();
    _builder.append("{erl_opts, [{src_dirs, [\"src3\", \"src4\"]}]}.");
    _builder.newLine();
    final String input = _builder.toString();
    final ErlangProjectProperties actual = configurator.decodeConfig(input);
    final Path _path = new Path("inc1");
    final Path _path_1 = new Path("inc2");
    Truth.<IPath, Iterable<IPath>>assertThat(actual.getIncludeDirs()).containsAtLeastElementsIn(Collections.<Object>unmodifiableList(CollectionLiterals.<Object>newArrayList(_path, _path_1)));
    final Path _path_2 = new Path("src3");
    final Path _path_3 = new Path("src4");
    Truth.<IPath, Iterable<IPath>>assertThat(actual.getSourceDirs()).containsAtLeastElementsIn(Collections.<Object>unmodifiableList(CollectionLiterals.<Object>newArrayList(_path_2, _path_3)));
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Aggregations

ErlangProjectProperties (org.erlide.engine.model.root.ErlangProjectProperties)29 IPath (org.eclipse.core.runtime.IPath)21 Test (org.junit.Test)19 Path (org.eclipse.core.runtime.Path)18 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)10 IterableSubject (com.google.common.truth.IterableSubject)4 IErlProject (org.erlide.engine.model.root.IErlProject)4 IProjectConfigurator (org.erlide.engine.model.root.IProjectConfigurator)4 IProject (org.eclipse.core.resources.IProject)3 Subject (com.google.common.truth.Subject)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)2 CoreException (org.eclipse.core.runtime.CoreException)2 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1 IResource (org.eclipse.core.resources.IResource)1 ProjectScope (org.eclipse.core.resources.ProjectScope)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1