Search in sources :

Example 6 with ErlangProjectProperties

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

the class RebarProjectConfigurationTest method configCanBeParsed.

@Override
@Test
public void configCanBeParsed() throws CoreException {
    project.setConfigType(ProjectConfigType.REBAR);
    project.storeAllProperties();
    setFileContent(ProjectConfigType.REBAR.getConfigName(), "");
    final IProjectConfigurator persister = ProjectConfiguratorFactory.getDefault().getConfig(project.getConfigType(), project);
    final ProjectConfigurationSerializer configurator = ((FileProjectConfigurator) persister).getSerializer();
    final ErlangProjectProperties expected = new ErlangProjectProperties();
    expected.setOutputDir(new Path("ebin"));
    final ErlangProjectProperties actual = configurator.decodeConfig("");
    assertThat(actual).isEqualTo(expected);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ProjectConfigurationSerializer(org.erlide.engine.model.root.ProjectConfigurationSerializer) IProjectConfigurator(org.erlide.engine.model.root.IProjectConfigurator) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) FileProjectConfigurator(org.erlide.engine.model.root.FileProjectConfigurator) Test(org.junit.Test)

Example 7 with ErlangProjectProperties

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

the class InternalProjectConfigurationTest method outputPathShouldFollowPropertyChange.

@Test
public void outputPathShouldFollowPropertyChange() throws BackingStoreException {
    final String expected = "hello/world";
    final IProject wproject = project.getWorkspaceProject();
    final IEclipsePreferences node = new ProjectScope(wproject).getNode("org.erlide.core");
    node.put(ProjectPreferencesConstants.OUTPUT_DIR, expected);
    node.flush();
    final ErlangProjectProperties pp = project.getProperties();
    final String actual = pp.getOutputDir().toPortableString();
    assertThat(actual).isEqualTo(expected);
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 8 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 9 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 10 with ErlangProjectProperties

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

the class RebarProjectConfigurationTest method propertiesShouldFollowConfigFileChange.

@Test
public void propertiesShouldFollowConfigFileChange() throws CoreException {
    project.setConfigType(ProjectConfigType.REBAR);
    final String cfgFile = ProjectConfigType.REBAR.getConfigName();
    final String config = getFileContent(cfgFile);
    final String config1 = config + "{erl_opts, [{i, \"myinclude\"}, " + "{src_dirs, [\"src\", \"src2\"]}]}.";
    setFileContent(cfgFile, config1);
    final ErlangProjectProperties p2 = project.getProperties();
    final Collection<IPath> actualSources = p2.getSourceDirs();
    assertThat(actualSources).hasSize(2);
    assertThat(actualSources).contains(new Path("src2"));
    final Collection<IPath> actualIncludes = p2.getIncludeDirs();
    assertThat(actualIncludes).hasSize(1);
    assertThat(actualIncludes).contains(new Path("myinclude"));
}
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) Test(org.junit.Test)

Aggregations

ErlangProjectProperties (org.erlide.engine.model.root.ErlangProjectProperties)12 IPath (org.eclipse.core.runtime.IPath)8 Test (org.junit.Test)7 Path (org.eclipse.core.runtime.Path)6 IProject (org.eclipse.core.resources.IProject)3 IErlProject (org.erlide.engine.model.root.IErlProject)3 ArrayList (java.util.ArrayList)2 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)2 CoreException (org.eclipse.core.runtime.CoreException)2 IProjectConfigurator (org.erlide.engine.model.root.IProjectConfigurator)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 BackendException (org.erlide.backend.api.BackendException)1 DialyzerBuilder (org.erlide.dialyzer.internal.builder.DialyzerBuilder)1 ErlProject (org.erlide.engine.internal.model.root.ErlProject)1 ErlModelException (org.erlide.engine.model.ErlModelException)1