Java Code Examples for org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil#makeJava8Compliant()
The following examples show how to use
org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil#makeJava8Compliant() .
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: 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 2
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 3
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 4
Source File: XtendLibClasspathAdderTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testAddToJavaProject() throws Exception { javaProjectFactory.setProjectName("test"); javaProjectFactory.addFolders(Collections.singletonList("src")); javaProjectFactory.addBuilderIds(JavaCore.BUILDER_ID, XtextProjectHelper.BUILDER_ID); javaProjectFactory.addProjectNatures(JavaCore.NATURE_ID, XtextProjectHelper.NATURE_ID); IProject project = javaProjectFactory.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(); syncUtil.waitForBuild(null); markerAssert.assertNoErrorMarker(file); }
Example 5
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 6
Source File: XtendLibClasspathAdderTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testAddToBrokenPlugin() 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); project.findMember("META-INF").delete(true, null); 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(); syncUtil.waitForBuild(null); markerAssert.assertNoErrorMarker(file); }
Example 7
Source File: Bug456868Test.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
/** * https://bugs.eclipse.org/bugs/show_bug.cgi?id=452821 */ @Test public void testProjectWithWhitespaceInNameWorks() { try { this.project = JavaProjectSetupUtil.createJavaProject("my project"); JavaProjectSetupUtil.makeJava8Compliant(this.project); NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor(); this.libAdder.addLibsToClasspath(this.project, _nullProgressMonitor); this.natureAdder.toggleNature(this.project.getProject()); StringConcatenation _builder = new StringConcatenation(); _builder.append("class MyClass {"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("}"); _builder.newLine(); IResourcesSetupUtil.createFile("my project/src/MyClass.xtend", _builder.toString()); IResourcesSetupUtil.waitForBuild(); IResourcesSetupUtil.assertNoErrorsInWorkspace(); final IResource generatedJava = IResourcesSetupUtil.file("my project/xtend-gen/MyClass.java"); Assert.assertTrue(generatedJava.exists()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }