/** * Creates a project with two files. */ @SuppressWarnings("resource") @BeforeClass public static void createTestProject() throws Exception { staticProject = ProjectUtils.createJSProject(PROJECT_NAME); IFolder path = staticProject.getFolder("src").getFolder("path"); path.create(true, true, null); IFile libFile = path.getFile("Libs.n4js"); libFile.create(new StringInputStream( "export public class MyFirstClass {} export public class MySecondClass {} class MyHiddenClass {}", libFile.getCharset()), true, monitor()); IFile moreLibFile = path.getFile("MoreLibs.n4js"); moreLibFile.create(new StringInputStream( "export public class MoreLibFirstClass {} export public class MoreLibSecondClass {}", moreLibFile.getCharset()), true, monitor()); IFile testFile = path.getFile("Test.n4js"); testFile.create(new StringInputStream("", testFile.getCharset()), true, monitor()); addNature(staticProject, XtextProjectHelper.NATURE_ID); ProjectUtils.waitForAutoBuild(); }
/** * Toggles the EASy nature of <code>project</code>. * * @param project the project to toggle the EASy nature for * @throws IOException in case of initialization problems * @throws InvalidProjectnameException if a projectname is not valid */ public static final void toggleNature(IProject project) throws IOException, InvalidProjectnameException { try { boolean hasNature = NatureUtils.hasNature(project, EASyNature.NATURE_ID); if (!hasNature) { ResourcesMgmt.INSTANCE.addEASyNatures(project, XtextProjectHelper.NATURE_ID, EASyNature.NATURE_ID); } else { String projectID = ResourcesMgmt.INSTANCE.getIDfromResource(project); ProductLineProject deletedPLP = (ProductLineProject) SPLsManager.INSTANCE.getPLP(projectID); if (null != deletedPLP) { deletedPLP.close(); } NatureUtils.removeNature(project, EASyNature.NATURE_ID, null); project.refreshLocal(IProject.DEPTH_INFINITE, null); } } catch (CoreException e) { throw new IOException(e.getMessage()); } }
/** Applies the Xtext nature to the project and creates (if necessary) and returns the source folder. */ public static IFolder configureProjectWithXtext(IProject project, String sourceFolder) throws CoreException { addNature(project.getProject(), XtextProjectHelper.NATURE_ID); IFolder folder = project.getProject().getFolder(sourceFolder); if (!folder.exists()) { folder.create(true, true, null); } return folder; }
/***/ protected URI createTempProject(String projectName) throws CoreException { IProjectDescription description = workspace.getWorkspace().newProjectDescription(projectName); // deliberately avoid the build command description.setNatureIds(new String[] { XtextProjectHelper.NATURE_ID }); IProject newProject = workspace.getProject(projectName); newProject.create(null); newProject.open(null); newProject.setDescription(description, null); return URI.createPlatformResourceURI(projectName, true); }
@Override protected boolean checkExists() { if (XtextProjectHelper.hasNature(project)) { return project.getFile(N4MF_MANIFEST).exists(); } return false; }
public void addNature(IProject project) { try { IProjectDescription description = project.getDescription(); String[] natures = description.getNatureIds(); String[] newNatures = new String[natures.length + 1]; System.arraycopy(natures, 0, newNatures, 0, natures.length); newNatures[natures.length] = XtextProjectHelper.NATURE_ID; description.setNatureIds(newNatures); project.setDescription(description, null); } catch (CoreException e) { e.printStackTrace(); } }
protected String[] getProjectNatures() { return new String[] { JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", //$NON-NLS-1$ XtextProjectHelper.NATURE_ID }; }
protected String[] getBuilders() { return new String[]{ JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", //$NON-NLS-1$ "org.eclipse.pde.SchemaBuilder", //$NON-NLS-1$ XtextProjectHelper.BUILDER_ID }; }
@Override public RefactoringParticipant[] loadParticipants(RefactoringStatus status, SharableParticipants sharedParticipants) throws CoreException { RenameParticipant[] renameParticipants = ParticipantManager.loadRenameParticipants(status, this, renameElementContext, new RenameArguments(newName, true), new String[] { XtextProjectHelper.NATURE_ID }, sharedParticipants); return renameParticipants; }
protected void checkXtextNature() { IFileEditorInput editorInput = (IFileEditorInput) getEditorInput(); IProject project = editorInput.getFile().getProject(); if (project != null && !XtextProjectHelper.hasNature(project) && project.isAccessible() && !project.isHidden()) { addNature(project); } }
private IJavaProject createJavaProjectWithRootSrc(String string) throws CoreException { IJavaProject project = createJavaProject(string); addNature(project.getProject(), XtextProjectHelper.NATURE_ID); addSourceFolder(project, "src"); return project; }
protected boolean isAccessibleXtextProject(IProject p) { return p != null && XtextProjectHelper.hasNature(p) && XtextProjectHelper.hasNature(p); }
protected boolean isAccessibleXtextProject(IProject p) { return p != null && XtextProjectHelper.hasNature(p) && XtextProjectHelper.hasBuilder(p); }
private String[] natureIds() { return new String[] { JavaCore.NATURE_ID, GaugeProjectNature.NATURE_ID, XtextProjectHelper.NATURE_ID }; }
protected String[] getProjectNatures() { return new String[] { XtextProjectHelper.NATURE_ID // we want the Xtext nature by default }; }
/** * This creates the Java project that will be used for the tests. * @throws CoreException */ protected void createTestJavaProject() throws CoreException { IJavaProject javaProject = createJavaProject(TEST_PROJECT); addNature(javaProject.getProject(), XtextProjectHelper.NATURE_ID); }
private void addXtextNatureTo(IProject project) throws CoreException { String[] natureIds = (String[]) Arrays.asList(XtextProjectHelper.NATURE_ID).toArray(); IProjectDescription description = project.getDescription(); description.setNatureIds(natureIds); project.setDescription(description, null); }