Java Code Examples for org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil#waitForBuild()

The following examples show how to use org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil#waitForBuild() . 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: ListBasePluginTest.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@SuppressWarnings("javadoc")
@Test
public void testListBase() throws Exception {
	IProject project = ProjectTestsUtils.importProject(new File("probands"), new N4JSProjectName("ListBase"));
	IResourcesSetupUtil.waitForBuild();
	IFile underscore_js = project.getFile("src/underscore/underscore.n4js");
	assertTrue(underscore_js.exists());
	assertMarkers(underscore_js + " should have no errors", underscore_js, 0);

	IFile listbase_js = project.getFile("src/n4/lang/ListBase.n4js");

	assertTrue(listbase_js.exists());

	final Collection<IMarker> allMarkers = newHashSet(listbase_js.findMarkers(MarkerTypes.ANY_VALIDATION, true,
			IResource.DEPTH_INFINITE));
	assertTrue(format(EXPECTED_NUMBER_OF_ISSUE_TEMPLATE, allMarkers.size()),
			NUMBER_OF_EXPECTED_ISSUES == allMarkers.size());

	long unexpectedMarkerCount = allMarkers.stream()
			.filter(EXPECTED_VALIDATION_PREDICATE.negate())
			.count();

	assertTrue("Unexpected validation issues were found. " + toString(allMarkers), unexpectedMarkerCount == 0);
}
 
Example 2
Source File: ResourceStorageTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testShouldLoadFromStorage() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package mypack");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class MyClass {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public def void foo() {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IFile file = this.helper.createFile("mypack/MyClass.xtend", _builder.toString());
    IResourcesSetupUtil.waitForBuild();
    final URI uri = this.uriMapper.getUri(file);
    final ResourceSet resourceSet = this.resourceSetProvider.get(file.getProject());
    SourceLevelURIsAdapter.setSourceLevelUris(resourceSet, Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
    Resource _createResource = resourceSet.createResource(uri);
    final StorageAwareResource resource = ((StorageAwareResource) _createResource);
    final Procedure0 _function = () -> {
      Assert.assertTrue(resource.getResourceStorageFacade().shouldLoadFromStorage(resource));
    };
    this.doWorkInJob(_function);
    NullProgressMonitor _nullProgressMonitor = new NullProgressMonitor();
    file.delete(true, _nullProgressMonitor);
    IResourcesSetupUtil.waitForBuild();
    final Procedure0 _function_1 = () -> {
      Assert.assertFalse(resource.getResourceStorageFacade().shouldLoadFromStorage(resource));
    };
    this.doWorkInJob(_function_1);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 3
Source File: AbstractQuickfixTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected XtextEditor openInEditor(IFile dslFile) {
	IResourcesSetupUtil.waitForBuild();
	try {
		return openEditor(dslFile);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
Example 4
Source File: XtendUnsugaredHoverTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testExtensionParameter() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("class B {");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("def foo(CharSequence chars) {}");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("def bar(extension B a) {");
  _builder.newLine();
  _builder.append("    ");
  _builder.append("\"\".foo() ");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final XtendFile xtendFile = this.testHelper.xtendFile(XtendUnsugaredHoverTest.FILEPATH, _builder.toString());
  IResourcesSetupUtil.waitForBuild();
  XtendMember _get = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers().get(1);
  final XtendFunction function = ((XtendFunction) _get);
  XExpression _expression = function.getExpression();
  final XBlockExpression block = ((XBlockExpression) _expression);
  final XExpression call = block.getExpressions().get(0);
  Assert.assertEquals("a.foo(\"\")", this.serializer.computeUnsugaredExpression(call));
}
 
Example 5
Source File: XbaseEditorOpenClassFileTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testOpenEditor_NameConflict02() {
  try {
    boolean _supportsEditorOverride = this.supportsEditorOverride();
    boolean _not = (!_supportsEditorOverride);
    if (_not) {
      return;
    }
    final IJavaProject jp = JavaCore.create(this.project);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("// Xtend");
    _builder.newLine();
    _builder.append("package myPackage");
    _builder.newLine();
    _builder.append("class Foo {}");
    _builder.newLine();
    Pair<String, String> _mappedTo = Pair.<String, String>of("myPackage/Foo.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("// Java");
    _builder_1.newLine();
    _builder_1.append("package otherPackage;");
    _builder_1.newLine();
    _builder_1.append("public class Foo {}");
    _builder_1.newLine();
    Pair<String, String> _mappedTo_1 = Pair.<String, String>of("otherPackage/Foo.java", _builder_1.toString());
    this.addJarToProject(this.project, 
      this.createJar(_mappedTo, _mappedTo_1));
    IResourcesSetupUtil.waitForBuild();
    final IType type = jp.findType("myPackage.Foo");
    Assert.assertNotNull(type);
    final String result = this.getEditorContents(type);
    this.assertContains("package myPackage;", result);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 6
Source File: XtendUnsugaredHoverTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUnsuagaredVersionForXtendFunction_3() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package testpackage");
  _builder.newLine();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("extension Extension");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def baz(Integer it){");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("val a = 42");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("bar(it, 42 + a)\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final XtendFile xtendFile = this.testHelper.xtendFile(XtendUnsugaredHoverTest.FILEPATH, _builder.toString());
  IResourcesSetupUtil.waitForBuild();
  XtendMember _get = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers().get(1);
  final XtendFunction function = ((XtendFunction) _get);
  XExpression _expression = function.getExpression();
  final XBlockExpression block = ((XBlockExpression) _expression);
  final XExpression call = block.getExpressions().get(1);
  Assert.assertEquals("this._extension.bar(it, 42 + a)", this.serializer.computeUnsugaredExpression(call));
}
 
Example 7
Source File: AbstractHyperlinkingTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected XtextEditor openInEditor(IFile dslFile) {
	// Wait for the cross-reference resolution
	IResourcesSetupUtil.waitForBuild();
	try {
		return openEditor(dslFile);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
Example 8
Source File: XtendEditorChangingClasspathTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testAddXtendLib() {
  try {
    final IJavaProject project = JavaProjectSetupUtil.createJavaProject("testProject");
    final IFile file = IResourcesSetupUtil.createFile("testProject/src/Foo.xtend", "class Foo {}");
    IResourcesSetupUtil.waitForBuild();
    this.workbenchTestHelper.openEditor(file);
    this.assertAddLibsToClasspath(project);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 9
Source File: OpenTargetWithMultipleSourcesTestCase.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Before
@Override
public void setUp() throws Exception {
  super.setUp();
  this.testProject = WorkbenchTestHelper.createPluginProject("testProject");
  Path _path = new Path("testProject/src/mypackage/A.xtend");
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package mypackage; ");
  _builder.newLine();
  _builder.append("class A {");
  _builder.newLine();
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def dispatch foo(Object it) {}");
  _builder.newLine();
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def dispatch foo(Void it) {}");
  _builder.newLine();
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  IResourcesSetupUtil.createFile(_path, _builder.toString());
  Path _path_1 = new Path("testProject/src/mypackage/B.xtend");
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("package mypackage; ");
  _builder_1.newLine();
  _builder_1.append("class B extends A {");
  _builder_1.newLine();
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("def dispatch foo(String it) {}");
  _builder_1.newLine();
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  IResourcesSetupUtil.createFile(_path_1, _builder_1.toString());
  IResourcesSetupUtil.waitForBuild();
}
 
Example 10
Source File: XtendUnsugaredHoverTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUnsuagaredVersionForXtendFunction_2() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package testpackage");
  _builder.newLine();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("extension Extension");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def baz(Integer it){");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("bar(it, 42)\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final XtendFile xtendFile = this.testHelper.xtendFile(XtendUnsugaredHoverTest.FILEPATH, _builder.toString());
  IResourcesSetupUtil.waitForBuild();
  XtendMember _get = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers().get(1);
  final XtendFunction function = ((XtendFunction) _get);
  XExpression _expression = function.getExpression();
  final XBlockExpression block = ((XBlockExpression) _expression);
  final XExpression call = block.getExpressions().get(0);
  Assert.assertEquals("this._extension.bar(it, 42)", this.serializer.computeUnsugaredExpression(call));
}
 
Example 11
Source File: MarkOccurrencesTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	IJavaProject project = JavaProjectSetupUtil.createJavaProject("MarkOccurrencesTest");
	IResourcesSetupUtil.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
	IResourcesSetupUtil.waitForBuild();
	setMarkOccurrences(false);
}
 
Example 12
Source File: RenameStrategyTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testOverrideIndicatorAnnotationAfterFileRename() throws Exception {
	testHelper.createFile("test/SuperClass","package test\nclass SuperClass { def foo() {}}");
	final IFile subClassFile = testHelper.createFile("test/SubClass","package test\nclass SubClass extends SuperClass { override foo () {}}");
	IResourcesSetupUtil.waitForBuild();
	XtextEditor openEditor = testHelper.openEditor(subClassFile);
	final OverrideIndicatorAnnotation[] annotationBeforeFileRename = new OverrideIndicatorAnnotation[]{null};
	final OverrideIndicatorAnnotation[] annotationAfterFileRename = new OverrideIndicatorAnnotation[]{null};
	final ISourceViewer sourceViewer = openEditor.getInternalSourceViewer();
	sleepWhile(Predicates.isNull(), new Provider<Object>() {

		@Override
		public OverrideIndicatorAnnotation get() {
			annotationBeforeFileRename[0] = Iterators.getOnlyElement(Iterators.filter(sourceViewer.getAnnotationModel().getAnnotationIterator(), OverrideIndicatorAnnotation.class), null);
			return annotationBeforeFileRename[0];
		}
	},TimeUnit.SECONDS.toMillis(10));
	assertNotNull(annotationBeforeFileRename[0]);
	new WorkspaceModifyOperation() {
		@Override
		protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException,
				InterruptedException {
			subClassFile.move(subClassFile.getFullPath().removeLastSegments(1).append("Test.xtend"), true, monitor);
		}
	}.run(new NullProgressMonitor());
	IResourcesSetupUtil.waitForBuild();
	sleepWhile(Predicates.isNull(), new Provider<Object>() {

		@Override
		public OverrideIndicatorAnnotation get() {
			OverrideIndicatorAnnotation ann = Iterators.getOnlyElement(Iterators.filter(sourceViewer.getAnnotationModel().getAnnotationIterator(), OverrideIndicatorAnnotation.class), null);
			if (ann != annotationBeforeFileRename[0])
				annotationAfterFileRename[0] = ann;
			return annotationAfterFileRename[0];
		}
	},TimeUnit.SECONDS.toMillis(10));
	assertNotNull(annotationAfterFileRename[0]);
	assertNotSame(annotationBeforeFileRename[0], annotationAfterFileRename[0]);
}
 
Example 13
Source File: JavaVersionSettingTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testCompileWithJava6() {
  try {
    this.workbenchTestHelper.tearDown();
    WorkbenchTestHelper.createPluginProject(WorkbenchTestHelper.TESTPROJECT_NAME, JavaVersion.JAVA6);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package mypackage");
    _builder.newLine();
    _builder.append("class B implements A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("override a() {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.append("interface A {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void a()");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IFile xtendFile = this.workbenchTestHelper.createFile("mypackage/OverrideTest.xtend", _builder.toString());
    IResourcesSetupUtil.waitForBuild();
    this.assertNoErrors(xtendFile);
    final String content = this.getJavaFileContent("xtend-gen/mypackage/B.java", xtendFile.getProject());
    Assert.assertTrue("@Override annotation was not generated.", content.contains("@Override"));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 14
Source File: XtendUnsugaredHoverTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testUnsuagaredVersionForXtendFunction_9() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package testpackage");
  _builder.newLine();
  _builder.append("import java.util.ArrayList");
  _builder.newLine();
  _builder.append("class Foo {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("extension Extension");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def baz(String it){");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("substring(0)");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final XtendFile xtendFile = this.testHelper.xtendFile(XtendUnsugaredHoverTest.FILEPATH, _builder.toString());
  IResourcesSetupUtil.waitForBuild();
  XtendMember _get = IterableExtensions.<XtendClass>head(Iterables.<XtendClass>filter(xtendFile.getXtendTypes(), XtendClass.class)).getMembers().get(1);
  final XtendFunction function = ((XtendFunction) _get);
  XExpression _expression = function.getExpression();
  final XBlockExpression block = ((XBlockExpression) _expression);
  final XExpression call = block.getExpressions().get(0);
  Assert.assertEquals("it.substring(0)", this.serializer.computeUnsugaredExpression(call));
}
 
Example 15
Source File: ReproduceInvalidIndexPluginTest.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private void importProjects(boolean incremental) throws CoreException {
	final File testdataLocation = new File(getResourceUri(PROBANDS, PROBANDS_SUBFOLDER));
	// not executing anything, so a dummy n4js-runtime is sufficient:
	ProjectTestsUtils.importProject(testdataLocation, N4JSGlobals.N4JS_RUNTIME);
	for (String projectName : projectsToImport) {
		ProjectTestsUtils.importProject(testdataLocation, new N4JSProjectName(projectName));
	}
	if (incremental) {
		// This should really be called incrementalBuild
		IResourcesSetupUtil.waitForBuild();
	} else {
		IResourcesSetupUtil.fullBuild();
	}
}
 
Example 16
Source File: RebuildAffectedResourcesTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testAddMethod() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class Type3 {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IFile type3 = this.workbenchTestHelper.createFile("Type3.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("class Type1 {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def Type3 foo() { return new Type3()}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    this.workbenchTestHelper.createFile("Type1.xtend", _builder_1.toString());
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("class Type2 {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("def void doStuff() {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("new Type1().foo().bar()");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    final IFile type2 = this.workbenchTestHelper.createFile("Type2.xtend", _builder_2.toString());
    IResourcesSetupUtil.waitForBuild();
    this.assertHasErrors(type2, "bar");
    StringConcatenation _builder_3 = new StringConcatenation();
    _builder_3.append("class Type3 {");
    _builder_3.newLine();
    _builder_3.append("\t");
    _builder_3.append("def void bar() {}");
    _builder_3.newLine();
    _builder_3.append("}");
    _builder_3.newLine();
    StringInputStream _stringInputStream = new StringInputStream(_builder_3.toString());
    type3.setContents(_stringInputStream, true, true, null);
    IResourcesSetupUtil.waitForBuild();
    this.assertNoErrorsInWorkspace();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 17
Source File: WorkspaceScenariosTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
protected IProject createProjectWithJarDependency(final Function1<? super String, ? extends Boolean> jarFilter) {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package mypack");
    _builder.newLine();
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.annotations.Data");
    _builder.newLine();
    _builder.newLine();
    _builder.append("@Data class MyData {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("String someProp");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("int anotherProp");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    Pair<String, String> _mappedTo = Pair.<String, String>of("mypack/MyData.xtend", _builder.toString());
    final byte[] jarData = this.createJar(
      Collections.<Pair<? extends String, ? extends String>>unmodifiableList(CollectionLiterals.<Pair<? extends String, ? extends String>>newArrayList(_mappedTo)), jarFilter);
    final IProject project = WorkbenchTestHelper.createPluginProject("my.project", "org.eclipse.xtext.xbase.lib");
    this.addJarToProject(project, jarData);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package pack");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("import mypack.MyData");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("class MyClass {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def String myMethod() {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("val myData = new MyData(\'foo\', 42)");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("return myData.getSomeProp() + myData.getAnotherProp()");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    IResourcesSetupUtil.createFile("my.project/src/pack/MyClass.xtend", _builder_1.toString());
    IResourcesSetupUtil.waitForBuild();
    return project;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 18
Source File: PerformanceTestProjectSetup.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
protected static void refreshExternalArchives(IJavaProject p) throws JavaModelException {
	IResourcesSetupUtil.waitForBuild(); // ensure that the auto-build job doesn't interfere with external jar refreshing
	getJavaModel().refreshExternalArchives(new IJavaElement[] {p}, null);
}
 
Example 19
Source File: XbaseEditorOpenClassFileTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testOpenEditor4NestedType_NoNameConflict() {
  try {
    boolean _supportsEditorOverride = this.supportsEditorOverride();
    boolean _not = (!_supportsEditorOverride);
    if (_not) {
      return;
    }
    final IJavaProject jp = JavaCore.create(this.project);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("// Xtend");
    _builder.newLine();
    _builder.append("package myPackage");
    _builder.newLine();
    _builder.append("class Foo {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("static class MyInnerClass {}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    Pair<String, String> _mappedTo = Pair.<String, String>of("myPackage/Foo.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("// Java");
    _builder_1.newLine();
    _builder_1.append("package otherPackage;");
    _builder_1.newLine();
    _builder_1.append("public class Bar {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("static class MyInnerClass2 {}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    Pair<String, String> _mappedTo_1 = Pair.<String, String>of("otherPackage/Bar.java", _builder_1.toString());
    this.addJarToProject(this.project, 
      this.createJar(_mappedTo, _mappedTo_1));
    IResourcesSetupUtil.waitForBuild();
    final IType type = jp.findType("myPackage.Foo.MyInnerClass");
    Assert.assertNotNull(type);
    final String result = this.getEditorContents(type);
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("// Xtend");
    _builder_2.newLine();
    _builder_2.append("package myPackage");
    _builder_2.newLine();
    _builder_2.append("class Foo {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("static class MyInnerClass {}");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    this.assertContains(_builder_2.toString(), result);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 20
Source File: XtendUnsugaredHoverTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Before
public void createExtensionClass() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package testpackage");
  _builder.newLine();
  _builder.append("import java.util.List");
  _builder.newLine();
  _builder.append("class Extension {");
  _builder.newLine();
  _builder.newLine();
  _builder.append("\t");
  _builder.append("public String fieldInExtension");
  _builder.newLine();
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def bar(Integer p1, Integer p2)");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def barCharSequence(Integer p1, CharSequence c)");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def bar(List<String list, Integer a)");
  _builder.newLine();
  _builder.append("\t");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("def static String setZonk(String s, String s2) {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("s + s2");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  _builder.newLine();
  this.testHelper.createFile(("testpackage/Extension" + XtendUnsugaredHoverTest.FILEEXTENSION), _builder.toString());
  StringConcatenation _builder_1 = new StringConcatenation();
  _builder_1.append("package testpackage;");
  _builder_1.newLine();
  _builder_1.append("public class ExtensionJava {");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("public void bar(Integer p1, Integer p2){");
  _builder_1.newLine();
  _builder_1.append("\t\t");
  _builder_1.newLine();
  _builder_1.append("\t");
  _builder_1.append("}");
  _builder_1.newLine();
  _builder_1.append("}");
  _builder_1.newLine();
  _builder_1.newLine();
  this.testHelper.createFile("testpackage/ExtensionJava.java", _builder_1.toString());
  IResourcesSetupUtil.waitForBuild();
}