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 createModule( final String moduleName, final String moduleContents, final IFolder folder) throws CoreException { final IFile file = createFile(moduleName, moduleContents, folder); final IErlModel model = ErlangEngine.getInstance().getModel(); IErlModule module = model.findModule(file); if (module == null) { final String path = file.getLocation().toPortableString(); module = model.getModuleFromFile( model, file.getName(), path, Charset.defaultCharset().name(), path); } return module; }
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); }
public static IErlModule createModuleFromText(final String initialText) { final IErlModel model = ErlangEngine.getInstance().getModel(); final IErlModule module = model.getModuleFromText(model, "test1", initialText, "test1"); modulesAndIncludes.add(module); return module; }