public static IErlProject createProject(final IPath path, 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, path.toPortableString()); final IProject project = erlProject.getWorkspaceProject(); final IErlangProjectProperties prefs = new OldErlangProjectProperties(project); final List<IPath> srcDirs = new ArrayList<IPath>(); srcDirs.add(new Path("src")); prefs.setSourceDirs(srcDirs); buildPaths(root, project, srcDirs); final List<IPath> includeDirs = new ArrayList<IPath>(); includeDirs.add(new Path("include")); buildPaths(root, project, includeDirs); prefs.setIncludeDirs(includeDirs); final List<IPath> ebinDirs = new ArrayList<IPath>(); ebinDirs.add(new Path("ebin")); buildPaths(root, project, ebinDirs); prefs.setOutputDir(ebinDirs.get(0)); projects.add(erlProject); return erlProject; }
@Before public void initialClean() throws CoreException { final IErlProject p2 = ErlideTestUtils.getExistingProject("builders"); prj = p2.getResource().getProject(); final IResource ebin = prj.findMember("ebin"); if (ebin != null) { ebin.delete(true, null); } else { prj.getFolder("ebin").create(true, true, null); } }
public static void initProjects() throws CoreException { projects = Lists.newArrayList(); final IErlModel model = ErlangEngine.getInstance().getModel(); model.open(null); final List<IErlElement> children = model.getChildren(); for (final IErlElement child : children) { if (child instanceof IErlProject) { final IErlProject project = (IErlProject) child; if (project.getName().startsWith("testproject")) { deleteProject(project); } } } }
public static IErlModule createInclude( final IErlProject project, final String moduleName, final String moduleContents) throws CoreException { final IFolder folder = project.getWorkspaceProject().getFolder("include"); final IErlModule module = createModule(moduleName, moduleContents, folder); modulesAndIncludes.add(module); return module; }
@Test public void sourcePathsShouldFollowPropertyChange() { final String expected = "hello/world;a/b"; final IProject project = erlProject.getWorkspaceProject(); final IEclipsePreferences node = new ProjectScope(project).getNode("org.erlide.core"); node.put(ProjectPreferencesConstants.SOURCE_DIRS, expected); final IErlangProjectProperties pp = new ErlangProjectProperties(project); final String actual = pp.getSourceDirs().toString(); assertThat(actual, is(convertListString(expected))); }
@Test public void outputPathShouldFollowPropertyChange() { final String expected = "hello/world"; final IProject project = erlProject.getWorkspaceProject(); final IEclipsePreferences node = new ProjectScope(project).getNode("org.erlide.core"); node.put(ProjectPreferencesConstants.OUTPUT_DIR, expected); final IErlangProjectProperties pp = new ErlangProjectProperties(project); final String actual = pp.getOutputDir().toPortableString(); assertEquals(expected, actual); }
public static void deleteProject(final IErlProject erlProject) throws CoreException { final IProject project = erlProject.getWorkspaceProject(); final IPath location = project.getLocation(); project.delete(true, null); if (location != null) { new File(location.toPortableString()).delete(); } if (modulesAndIncludes != null) { final List<IErlModule> list = Lists.newArrayList(modulesAndIncludes); for (final IErlModule module : list) { if (ErlangEngine.getInstance().getModelUtilService().getProject(module) == erlProject) { deleteModule(module); } } } erlProject.dispose(); if (projects != null) { projects.remove(ErlangEngine.getInstance().getModel().findProject(project)); } final IErlModel model = ErlangEngine.getInstance().getModel(); model.resourceChanged(null); model.open(null); }
@AfterClass public static void finish() throws CoreException { final IErlProject p2 = ErlideTestUtils.getExistingProject("p2"); final IProject prj = p2.getResource().getProject(); ErlangNature.setErlangProjectBuilder(prj, BuilderTool.INTERNAL); }
public static void refreshProjects() { for (final IErlProject project : projects) { project.resourceChanged(new ResourceDeltaStub()); } }
public static void invokeBuilderOn(final IErlProject erlProject) throws CoreException { final IProject project = erlProject.getWorkspaceProject(); project.build(IncrementalProjectBuilder.FULL_BUILD, null); }