org.eclipse.xtext.ui.XtextProjectHelper Java Examples
The following examples show how to use
org.eclipse.xtext.ui.XtextProjectHelper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MrsGrantsSecretCompartmentsProject.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public void generateProjects(final IProjectGenerator generator) { PluginProjectFactory _pluginProjectFactory = new PluginProjectFactory(); final Procedure1<PluginProjectFactory> _function = (PluginProjectFactory it) -> { it.setProjectName(this.getProjectInfo().getProjectName()); it.setLocation(this.getProjectInfo().getLocationPath()); List<String> _projectNatures = it.getProjectNatures(); Iterables.<String>addAll(_projectNatures, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID))); List<String> _builderIds = it.getBuilderIds(); Iterables.<String>addAll(_builderIds, Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList(JavaCore.BUILDER_ID, XtextProjectHelper.BUILDER_ID))); List<String> _folders = it.getFolders(); _folders.add("src"); List<String> _folders_1 = it.getFolders(); _folders_1.add("src-gen"); StringConcatenation _builder = new StringConcatenation(); _builder.append("src/"); _builder.append(this.path); _builder.append("/MrsGrantsSecretCompartments.statemachine"); this.addFile(it, _builder, TemplateContent.MrsGrantsSecretCompartments); }; PluginProjectFactory _doubleArrow = ObjectExtensions.<PluginProjectFactory>operator_doubleArrow(_pluginProjectFactory, _function); generator.generate(_doubleArrow); }
Example #2
Source File: SimpleProjectsIntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testFullBuild() throws Exception { IProject project = createProject("foo"); addNature(project.getProject(), XtextProjectHelper.NATURE_ID); createProject("bar"); build(); assertEquals(0, countResourcesInIndex()); createFile("bar/bar"+F_EXT, "objekt Foo "); build(); assertEquals(0, countResourcesInIndex()); createFile("foo/bar"+F_EXT, "objekt Foo "); build(); assertEquals(1, countResourcesInIndex()); getBuilderState().addListener(this); fullBuild(); assertEquals(1, countResourcesInIndex()); assertEquals(1,getEvents().size()); }
Example #3
Source File: AbstractN4JSContentAssistPluginUITest.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Creates a project with two files. */ @SuppressWarnings("resource") @BeforeClass public static void createTestProject() throws Exception { staticProject = ProjectTestsUtils.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); ProjectTestsUtils.waitForAutoBuild(); }
Example #4
Source File: ProfilerAbstractBuilderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testFullBuildBigProjectWithRefeernceToJar() throws Exception { IJavaProject project = workspace.createJavaProject("foo"); workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID); IFolder folder = project.getProject().getFolder("src"); IFile jarFile = project.getProject().getFile("my.jar"); jarFile.create(jarInputStream(new TextFile("my/element"+F_EXT,"object ReferenceMe")), true, workspace.monitor()); workspace.addJarToClasspath(project, jarFile); int NUM_FILES = 2000; IFile[] files = new IFile[NUM_FILES]; StopWatch timer = new StopWatch(); for (int i = 0; i < NUM_FILES; i++) { IFile file = folder.getFile("Test_" + i + "_" + F_EXT); files[i] = file; String contents = "object Foo" + i + " references ReferenceMe"; file.create(new StringInputStream(contents), true, workspace.monitor()); } logAndReset("Creating files", timer); workspace.build(); logAndReset("Auto build", timer); IMarker[] iMarkers = folder.findMarkers(EValidator.MARKER, true, IResource.DEPTH_INFINITE); for (IMarker iMarker : iMarkers) { System.out.println(iMarker.getAttribute(IMarker.MESSAGE)); } assertEquals(0,iMarkers.length); }
Example #5
Source File: XtendProjectConfigurator.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { addNature(request.getProject(), XtextProjectHelper.NATURE_ID, monitor); OutputConfiguration config = new XtendOutputConfigurationProvider() .getOutputConfigurations().iterator().next(); List<MojoExecution> executions = getMojoExecutions(request, monitor); SubMonitor progress = SubMonitor.convert(monitor, executions.size()); for (MojoExecution execution : executions) { String goal = execution.getGoal(); if (goal.equals("compile")) { readCompileConfig(config, request, execution, progress.split(1)); } else if (goal.equals("testCompile")) { readTestCompileConfig(config, request, execution, progress.split(1)); } else if (goal.equals("xtend-install-debug-info")) { readDebugInfoConfig(config, request, execution, progress.split(1)); } else if (goal.equals("xtend-test-install-debug-info")) { readTestDebugInfoConfig(config, request, execution, progress.split(1)); } } writePreferences(config, request.getProject()); }
Example #6
Source File: SameClassNamesTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public IProject createPluginProject(final String name, final String... requiredBundles) throws CoreException { final PluginProjectFactory projectFactory = this.projectFactoryProvider.get(); projectFactory.setProjectName(name); projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE); projectFactory.addFolders(Collections.<String>singletonList("src")); projectFactory.addBuilderIds( XtextProjectHelper.BUILDER_ID, JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder"); projectFactory.addProjectNatures( XtextProjectHelper.NATURE_ID, JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature"); projectFactory.addRequiredBundles(((List<String>)Conversions.doWrapArray(requiredBundles))); projectFactory.addExportedPackages(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("com.acme"))); NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor(); final IProject result = projectFactory.createProject(_nullProgressMonitor, null); final IJavaProject javaProject = JavaCore.create(result); WorkbenchTestHelper.makeCompliantFor(javaProject, JavaVersion.JAVA8); JavaProjectSetupUtil.addJreClasspathEntry(javaProject); return result; }
Example #7
Source File: ProjectOpenedOrClosedListener.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public void resourceChanged(final IResourceChangeEvent event) { if (workspace != null && workspace.isAutoBuilding()) { if (event.getType() == IResourceChangeEvent.POST_CHANGE) { try { final Set<IProject> toUpdate = findNewProjectsToBuild(event); scheduleBuildIfNecessary(toUpdate); } catch (CoreException e) { log.error(e.getMessage(), e); } } else if ((event.getType() == IResourceChangeEvent.PRE_CLOSE || event.getType() == IResourceChangeEvent.PRE_DELETE)) { if (event.getResource() instanceof IProject && (XtextProjectHelper.hasNature((IProject) event.getResource()) || event.getResource().isAccessible() && event.getResource().isHidden())) { scheduleRemoveProjectJob((IProject) event.getResource()); } } } }
Example #8
Source File: ProjectOpenedOrClosedListener.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.17 */ protected boolean visitResourceDelta(IResourceDelta delta, final Set<IProject> accumulator) { if (delta.getResource() instanceof IWorkspaceRoot) return true; if (delta.getResource() instanceof IProject) { IProject project = (IProject) delta.getResource(); if ((delta.getKind() & IResourceDelta.CHANGED) != 0 && project.isOpen()) { if ((delta.getFlags() & IResourceDelta.OPEN) != 0) { accumulator.add(project); } if ((delta.getFlags() & IResourceDelta.DESCRIPTION) != 0) { if ((delta.findMember(new Path(".project")) != null) && XtextProjectHelper.hasNature(project) && XtextProjectHelper.hasBuilder(project)) accumulator.add(project); else if (!XtextProjectHelper.hasNature(project)) { scheduleRemoveProjectJobIfNecessary(project, delta); } } } } return false; }
Example #9
Source File: SimpleProjectsIntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testCleanBuild() throws Exception { IProject project = createProject("foo"); addNature(project.getProject(), XtextProjectHelper.NATURE_ID); IFolder folder = createSubFolder(project, "subFolder"); IFile file = folder.getFile("Foo" + F_EXT); file.create(new StringInputStream("object Foo"), true, monitor()); build(); assertTrue(indexContainsElement(file.getFullPath().toString(),"Foo")); assertEquals(1, countResourcesInIndex()); getBuilderState().addListener(this); project.getProject().build(IncrementalProjectBuilder.CLEAN_BUILD, monitor()); assertEquals(1, getEvents().size()); build(); // clean build should first remove the IResourceDescriptor and then add it again assertEquals(2, getEvents().size()); assertEquals(1, getEvents().get(0).getDeltas().size()); assertNotNull(getEvents().get(0).getDeltas().get(0).getOld()); assertNull(getEvents().get(0).getDeltas().get(0).getNew()); assertEquals(1,getEvents().get(1).getDeltas().size()); assertNull(getEvents().get(1).getDeltas().get(0).getOld()); assertNotNull(getEvents().get(1).getDeltas().get(0).getNew()); }
Example #10
Source File: WorkbenchTestHelper.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public static IProject createPluginProject(String name, JavaVersion javaVersion, String... requiredBundles) throws CoreException { Injector injector = XtendActivator.getInstance().getInjector(XtendActivator.ORG_ECLIPSE_XTEND_CORE_XTEND); PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class); projectFactory.setProjectName(name); projectFactory.setProjectDefaultCharset(StandardCharsets.ISO_8859_1.name()); projectFactory.setBreeToUse(getBree(javaVersion)); projectFactory.addFolders(Collections.singletonList("src")); projectFactory.addBuilderIds(XtextProjectHelper.BUILDER_ID, JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder"); projectFactory.addProjectNatures( XtextProjectHelper.NATURE_ID, JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature"); projectFactory.addRequiredBundles(newArrayList(requiredBundles)); IProject result = projectFactory.createProject(new NullProgressMonitor(), null); IJavaProject javaProject = JavaCore.create(result); if (javaVersion == null) JavaProjectSetupUtil.makeJava8Compliant(javaProject); else makeCompliantFor(javaProject, javaVersion); JavaProjectSetupUtil.addJreClasspathEntry(javaProject); return result; }
Example #11
Source File: SimpleProjectsIntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testReexportedJarRemoved() throws Exception { IJavaProject foo = createJavaProject("foo"); IJavaProject bar = createJavaProject("bar"); IJavaProject baz = createJavaProject("baz"); addNature(foo.getProject(), XtextProjectHelper.NATURE_ID); addNature(bar.getProject(), XtextProjectHelper.NATURE_ID); addNature(baz.getProject(), XtextProjectHelper.NATURE_ID); IFile file = foo.getProject().getFile("foo.jar"); file.create(JavaProjectSetupUtil.jarInputStream(new TextFile("foo/Foo"+F_EXT, "object Foo")), true, monitor()); IClasspathEntry newLibraryEntry = JavaCore.newLibraryEntry(file.getFullPath(), null, null,true); addToClasspath(foo, newLibraryEntry); addToClasspath(bar, JavaCore.newProjectEntry(foo.getPath(), true)); addToClasspath(baz, JavaCore.newProjectEntry(bar.getPath(), false)); addSourceFolder(baz, "src"); IFile bazFile = createFile("baz/src/Baz"+F_EXT, "object Baz references Foo"); build(); assertEquals(0,countMarkers(bazFile)); deleteClasspathEntry(foo, newLibraryEntry.getPath()); build(); assertEquals(1, countMarkers(bazFile)); assertEquals(1, countResourcesInIndex()); Iterator<IReferenceDescription> references = getContainedReferences(URI.createPlatformResourceURI(bazFile.getFullPath().toString(),true)).iterator(); assertFalse(references.hasNext()); }
Example #12
Source File: SimpleProjectsIntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testTwoFilesInTwoReferencedProjectsAddNature() throws Exception { foo_project = createSimpleProjectWithXtextNature("foo"); removeNature(foo_project.getProject(), XtextProjectHelper.NATURE_ID); bar_project = createSimpleProjectWithXtextNature("bar"); foo_file = createFile("foo/foo"+F_EXT, "object Foo "); bar_file = createFile("bar/bar"+F_EXT, "object Bar references Foo"); build(); assertEquals(printMarkers(foo_file), 0, countMarkers(foo_file)); assertEquals(printMarkers(bar_file), 1, countMarkers(bar_file)); setReference(bar_project, foo_project); build(); assertEquals(printMarkers(foo_file), 0, countMarkers(foo_file)); assertEquals(printMarkers(bar_file), 1, countMarkers(bar_file)); addNature(foo_project.getProject(), XtextProjectHelper.NATURE_ID); build(); assertEquals(printMarkers(foo_file), 0, countMarkers(foo_file)); assertEquals(printMarkers(bar_file), 0, countMarkers(bar_file)); }
Example #13
Source File: IntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testCleanBuild() throws Exception { IJavaProject project = createJavaProject("foo"); addNature(project.getProject(), XtextProjectHelper.NATURE_ID); IFolder folder = project.getProject().getFolder("src"); IFile file = folder.getFile("Foo" + F_EXT); file.create(new StringInputStream("object Foo"), true, monitor()); build(); assertTrue(indexContainsElement(file.getFullPath().toString(), "Foo")); assertEquals(1, countResourcesInIndex()); getBuilderState().addListener(this); project.getProject().build(IncrementalProjectBuilder.CLEAN_BUILD, monitor()); build(); // clean build should first remove the IResourceDescriptor and then add it again assertEquals(2, getEvents().size()); assertEquals(1, getEvents().get(0).getDeltas().size()); assertNotNull(getEvents().get(0).getDeltas().get(0).getOld()); assertNull(getEvents().get(0).getDeltas().get(0).getNew()); assertEquals(1, getEvents().get(1).getDeltas().size()); assertNull(getEvents().get(1).getDeltas().get(0).getOld()); assertNotNull(getEvents().get(1).getDeltas().get(0).getNew()); }
Example #14
Source File: DisabledBuilderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
private IProject createPluginProject(String name, boolean addBuilder, String dependency) throws CoreException { PluginProjectFactory projectFactory = projectFactoryProvider.get(); projectFactory.setProjectName(name); projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE); projectFactory.addFolders(Collections.singletonList("src")); projectFactory.addBuilderIds(JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder"); if (addBuilder) { projectFactory.addBuilderIds(XtextProjectHelper.BUILDER_ID); } projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID); projectFactory.addRequiredBundles(Collections.singletonList("org.eclipse.emf.ecore")); if(dependency != null) projectFactory.addRequiredBundles(Collections.singletonList(dependency)); IProject result = projectFactory.createProject(new NullProgressMonitor(), null); return result; }
Example #15
Source File: AbstractContainerRelatedTests.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Before public void setUp() throws Exception { cleanWorkspace(); waitForBuild(); assertEquals(0, root().getProjects().length); project1 = createProject("someProject1"); project2 = createProject("someProject2"); IResourcesSetupUtil.addNature(project1, XtextProjectHelper.NATURE_ID); IResourcesSetupUtil.addNature(project2, XtextProjectHelper.NATURE_ID); uriToResourceDescription = Maps.newHashMap(); selectableDelegate = new AbstractCompoundSelectable() { @Override protected Iterable<IResourceDescription> getSelectables() { return getAllResourceDescriptions(); } }; }
Example #16
Source File: BuilderParticipantTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testClean() throws Exception { IJavaProject project = createJavaProject("foo"); addNature(project.getProject(), XtextProjectHelper.NATURE_ID); IFolder folder = project.getProject().getFolder("src"); IFile file = folder.getFile("Foo" + F_EXT); file.create(new StringInputStream("object Foo"), true, monitor()); build(); IFile generatedFile = project.getProject().getFile("./src-gen/Foo.txt"); assertTrue(generatedFile.exists()); assertTrue(generatedFile.isDerived()); assertTrue(generatedFile.findMarkers(DerivedResourceMarkers.MARKER_ID, false, IResource.DEPTH_ZERO).length == 1); assertEquals("object Foo", readFile(generatedFile).trim()); disableAutobuild(()->{ cleanBuild(); assertFalse(generatedFile.exists()); }); }
Example #17
Source File: BuilderParticipantTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testDefaultConfiguration() throws Exception { IJavaProject project = createJavaProject("foo"); addNature(project.getProject(), XtextProjectHelper.NATURE_ID); IFolder folder = project.getProject().getFolder("src"); IFile file = folder.getFile("Foo" + F_EXT); file.create(new StringInputStream("object Foo"), true, monitor()); build(); IFile generatedFile = project.getProject().getFile("./src-gen/Foo.txt"); assertTrue(generatedFile.exists()); assertTrue(generatedFile.isDerived()); assertTrue(generatedFile.findMarkers(DerivedResourceMarkers.MARKER_ID, false, IResource.DEPTH_ZERO).length == 1); assertEquals("object Foo", readFile(generatedFile).trim()); file.setContents(new StringInputStream("object Bar"), true, true, monitor()); build(); assertFalse(generatedFile.exists()); generatedFile = project.getProject().getFile("./src-gen/Bar.txt"); assertTrue(generatedFile.exists()); assertTrue(generatedFile.isDerived()); assertTrue(generatedFile.findMarkers(DerivedResourceMarkers.MARKER_ID, false, IResource.DEPTH_ZERO).length == 1); assertEquals("object Bar", readFile(generatedFile).trim()); file.delete(true, monitor()); build(); assertFalse(generatedFile.exists()); }
Example #18
Source File: JdtToBeBuiltComputer.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected boolean isBuiltByUpstream(IPackageFragmentRoot root, IProject project, IProject[] projectsInCorrectBuildOrder) { for (IProject p : projectsInCorrectBuildOrder) { if (p.equals(project)) return false; if (XtextProjectHelper.hasNature(p) && XtextProjectHelper.hasBuilder(p)) { IJavaProject javaProject = JavaCore.create(p); if (javaProject.exists()) { if (javaProject.isOnClasspath(root)) { if (log.isTraceEnabled()) log.trace("Build of project '"+project.getName()+"' skips indexing classpath entry '"+root.getPath()+"' because it already indexed by "+javaProject.getElementName()); return true; } } } } return false; }
Example #19
Source File: AddParameterWizard.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public boolean performFinish() { editingDomain.getCommandStack().execute( AddCommand.create(editingDomain, container, ProcessPackage.Literals.ABSTRACT_PROCESS__PARAMETERS, parameterWorkingCopy)); try { RepositoryManager.getInstance().getCurrentRepository().getProject() .build(IncrementalProjectBuilder.FULL_BUILD, XtextProjectHelper.BUILDER_ID, Collections.<String, String> emptyMap(), null); } catch (final CoreException e1) { BonitaStudioLog.error(e1, ParameterPlugin.PLUGIN_ID); return false; } return true; }
Example #20
Source File: IntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testDeleteFile() throws Exception { IJavaProject project = createJavaProject("foo"); addNature(project.getProject(), XtextProjectHelper.NATURE_ID); IFolder folder = project.getProject().getFolder("src"); IFile file = folder.getFile("Foo" + F_EXT); file.create(new StringInputStream("object Foo"), true, monitor()); build(); assertTrue(indexContainsElement(file.getFullPath().toString(), "Foo")); assertEquals(1, countResourcesInIndex()); getBuilderState().addListener(this); file.delete(true, monitor()); build(); assertEquals(1, getEvents().get(0).getDeltas().size()); assertNull(getEvents().get(0).getDeltas().get(0).getNew()); assertEquals(0, countResourcesInIndex()); }
Example #21
Source File: LiveShadowedAllContainerStateTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testEmptyProject() { try { final IProject project = IResourcesSetupUtil.createProject("MyProject"); IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID); final ResourceSet rs = this.liveScopeResourceSetProvider.get(project); StringConcatenation _builder = new StringConcatenation(); _builder.append("container MyProject isEmpty=true {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final String expected = _builder.toString(); Assert.assertEquals(expected, this.formatContainers(rs)); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #22
Source File: AbstractXbaseUITestCase.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public static IProject createPluginProject(String name) throws CoreException { Injector injector = XbaseActivator.getInstance().getInjector("org.eclipse.xtext.xbase.Xbase"); PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class); projectFactory.setProjectName(name); projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE); projectFactory.addFolders(Collections.singletonList("src")); projectFactory.addBuilderIds( JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder", XtextProjectHelper.BUILDER_ID); projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID); projectFactory.addRequiredBundles(Collections.singletonList("org.eclipse.xtext.xbase.lib")); IProject result = projectFactory.createProject(new NullProgressMonitor(), null); JavaProjectSetupUtil.makeJava8Compliant(JavaCore.create(result)); JavaProjectSetupUtil.setUnixLineEndings(result); return result; }
Example #23
Source File: XtextBuilder.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public ISchedulingRule getRule(int kind, Map<String, String> args) { switch (preferences.schedulingOption) { case NULL: return null; case WORKSPACE: return getProject().getWorkspace().getRoot(); case PROJECT: return getProject(); case ALL_XTEXT_PROJECTS: return new MultiRule(Arrays.stream( getProject().getWorkspace().getRoot().getProjects()) .filter(XtextProjectHelper::hasNature) .toArray(ISchedulingRule[]::new)); case ALL_XTEXT_PROJECTS_AND_JDTEXTFOLDER: return new MultiRule(Arrays.stream( getProject().getWorkspace().getRoot().getProjects()) .filter(p-> XtextProjectHelper.hasNature(p) || EXTERNAL_PROJECT_NAME.equals(p.getName()) ) .toArray(ISchedulingRule[]::new)); default: throw new IllegalArgumentException(); } }
Example #24
Source File: ContentAssistTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
public static IProject createPluginProject(String name) throws CoreException { Injector injector = XtendActivator.getInstance().getInjector("org.eclipse.xtend.core.Xtend"); PluginProjectFactory projectFactory = injector.getInstance(PluginProjectFactory.class); projectFactory.setBreeToUse(JREContainerProvider.PREFERRED_BREE); projectFactory.setProjectName(name); projectFactory.setProjectDefaultCharset(StandardCharsets.ISO_8859_1.name()); projectFactory.addFolders(Collections.singletonList("src")); projectFactory.addBuilderIds( JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder", XtextProjectHelper.BUILDER_ID); projectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID); projectFactory.addRequiredBundles(Lists.newArrayList( "org.eclipse.xtext.xbase.lib", "org.eclipse.xtend.lib")); IProject result = projectFactory.createProject(new NullProgressMonitor(), null); JavaProjectSetupUtil.makeJava8Compliant(JavaCore.create(result)); return result; }
Example #25
Source File: ProfilerAbstractBuilderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testFullBuildBigProject() throws Exception { IJavaProject project = workspace.createJavaProject("foo"); workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID); IFolder folder = project.getProject().getFolder("src"); int NUM_FILES = 200; IFile[] files = new IFile[NUM_FILES]; StopWatch timer = new StopWatch(); for (int i = 0; i < NUM_FILES; i++) { IFile file = folder.getFile("Test_" + i + "_" + F_EXT); files[i] = file; String contents = "object Foo" + i + " references Foo" + (i + 1); if (i == NUM_FILES) contents = "object Foo" + i; file.create(new StringInputStream(contents), true, workspace.monitor()); } logAndReset("Creating files", timer); workspace.build(); logAndReset("Auto build", timer); }
Example #26
Source File: TwoProjectsTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testTwoFilesInTwoReferencedProjectsAddNature() throws Exception { workspace.run((monitor) -> { removeNature(first, XtextProjectHelper.NATURE_ID); firstFile = createFile("first/first" + F_EXT, "Hello First!"); secondFile = createFile("second/second" + F_EXT, "Hello Second ( from First )!"); }); build(); assertEquals(printMarkers(firstFile), 0, countMarkers(firstFile)); assertEquals(printMarkers(secondFile), 1, countMarkers(secondFile)); addProjectReference(second, first); build(); assertEquals(printMarkers(firstFile), 0, countMarkers(firstFile)); assertEquals(printMarkers(secondFile), 1, countMarkers(secondFile)); addNature(first.getProject(), XtextProjectHelper.NATURE_ID); build(); assertEquals(printMarkers(firstFile), 0, countMarkers(firstFile)); assertEquals(printMarkers(secondFile), 0, countMarkers(secondFile)); }
Example #27
Source File: XtendLibClasspathAdderTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testAddToPlugin() throws Exception { pluginProjectFactory.setProjectName("test"); pluginProjectFactory.addFolders(Collections.singletonList("src")); pluginProjectFactory.addBuilderIds(JavaCore.BUILDER_ID, "org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder", XtextProjectHelper.BUILDER_ID); pluginProjectFactory.addProjectNatures(JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature", XtextProjectHelper.NATURE_ID); IProject project = pluginProjectFactory.createProject(null, null); IJavaProject javaProject = JavaCore.create(project); JavaProjectSetupUtil.makeJava8Compliant(javaProject); IFile file = project.getFile("src/Foo.xtend"); file.create(new StringInputStream("import org.eclipse.xtend.lib.annotations.Accessors class Foo { @Accessors int bar }"), true, null); syncUtil.waitForBuild(null); markerAssert.assertErrorMarker(file, IssueCodes.XBASE_LIB_NOT_ON_CLASSPATH); adder.addLibsToClasspath(javaProject, null); waitForAutoBuild(); markerAssert.assertNoErrorMarker(file); }
Example #28
Source File: XtextBuilder.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.19 */ protected void pollQueuedBuildData() { boolean needRebuild = false; if (pollQueuedBuildData(getProject())) { needRebuild = true; } for(IProject project: interestingProjects) { if (!XtextProjectHelper.hasNature(project)) { if (pollQueuedBuildData(project)) { needRebuild = true; } } } if(needRebuild) { needRebuild(); } }
Example #29
Source File: IntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testFullBuild() throws Exception { IJavaProject project = createJavaProject("foo"); addNature(project.getProject(), XtextProjectHelper.NATURE_ID); IProject someProject = createProject("bar"); IFile file = someProject.getFile("foo.jar"); file.create(jarInputStream(new TextFile("foo/Bar" + F_EXT, "object Foo")), true, monitor()); assertEquals(0, countResourcesInIndex()); addJarToClasspath(project, file); assertEquals(1, countResourcesInIndex()); getBuilderState().addListener(this); fullBuild(); assertEquals(1, countResourcesInIndex()); assertEquals(1, getEvents().size()); }
Example #30
Source File: SimpleProjectsIntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testEvents() throws Exception { IJavaProject xtextProject = createJavaProject("xtextProject"); addNature(xtextProject.getProject(), XtextProjectHelper.NATURE_ID); IProject projectWithJarFile = createProject("projectWithJar"); IFile jarFile = projectWithJarFile.getFile("jarFile.jar"); jarFile.create(JavaProjectSetupUtil.jarInputStream(new TextFile("inJar/Bar"+F_EXT, "object InJar")), true, monitor()); jarFile.setLocalTimeStamp(100L); addJarToClasspath(xtextProject, jarFile); projectWithJarFile.delete(true, monitor()); build(); assertEmptyIndex(); }