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

The following examples show how to use org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil#createFile() . 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: TextChangeCombinerTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testMixedChanges() throws Exception {
	IFile file1 = IResourcesSetupUtil.createFile(PROJECT + "/file1.txt", MODEL);
	ITextEditor editor1 = openInEditor(file1);
	CompositeChange compositeChange = new CompositeChange("test");
	compositeChange.add(createEditorDocumentChange(editor1, 1, 1, "foo"));
	compositeChange.add(createTextFileChange(file0, 1, 1, "foo"));
	CompositeChange compositeChange1 = new CompositeChange("test");
	compositeChange.add(compositeChange1);
	compositeChange1.add(createEditorDocumentChange(editor1, 3, 1, "baz"));
	compositeChange1.add(createTextFileChange(file0, 1, 1, "foo"));
	compositeChange1.add(createTextFileChange(file0, 3, 1, "baz"));
	Change combined = combiner.combineChanges(compositeChange);
	Change undo = combined.perform(new NullProgressMonitor());
	IDocument document1 = getDocument(editor1);
	assertEquals(MODEL.replace("123", "foo2baz"), document1.get());
	assertEquals(MODEL.replace("123", "foo2baz"), getContents(file0));
	undo.perform(new NullProgressMonitor());
	assertEquals(MODEL, document1.get());
	assertEquals(MODEL, getContents(file0));
}
 
Example 2
Source File: AbstractProblemHoverTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	modelAsText = "stuff mystuff\nstuff yourstuff refs _mystuff// Comment";
	file = IResourcesSetupUtil.createFile("test/test.testlanguage", modelAsText);
	editor = openEditor(file);
	document = editor.getDocument();
	hover = TestsActivator.getInstance().getInjector(getEditorId()).getInstance(MockHover.class);
	hover.setSourceViewer(editor.getInternalSourceViewer());
	List<Issue> issues = document.readOnly(new IUnitOfWork<List<Issue>, XtextResource>() {
		@Override
		public List<Issue> exec(XtextResource state) throws Exception {
			return state.getResourceServiceProvider().getResourceValidator().validate(state, CheckMode.ALL, null);
		}	
	});
	MarkerCreator markerCreator =  TestsActivator.getInstance().getInjector(getEditorId()).getInstance(MarkerCreator.class);
	for (Issue issue : issues) {
		markerCreator.createMarker(issue, file, MarkerTypes.forCheckType(issue.getType()));
	}
}
 
Example 3
Source File: XtendJavaElementDelegateJunitLaunchTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
private IFile dslFile(final CharSequence text) {
  try {
    IFile _xblockexpression = null;
    {
      final IFile file = IResourcesSetupUtil.createFile(this.getProjectName(), "src/foo/FooTest", this._fileExtensionProvider.getPrimaryFileExtension(), this.getContent(text));
      final IProject project = file.getProject();
      boolean _hasNature = project.hasNature(XtextProjectHelper.NATURE_ID);
      boolean _not = (!_hasNature);
      if (_not) {
        IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
      }
      IResourcesSetupUtil.fullBuild();
      _xblockexpression = file;
    }
    return _xblockexpression;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 4
Source File: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testPersistedWithResource() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    String _primaryFileExtension = this._fileExtensionProvider.getPrimaryFileExtension();
    final String fileName = ("MyProject/myfile." + _primaryFileExtension);
    IResourcesSetupUtil.createFile(fileName, "stuff foo");
    IResourcesSetupUtil.waitForBuild();
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    Assert.assertNotNull(rs.getResource(URI.createPlatformResourceURI(fileName, true), true));
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=false {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile.testlanguage exported=[foo]");
    _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 5
Source File: ProblemHoverTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	modelAsText = "stuff mystuff\nstuff yourstuff refs _mystuff stuff hisstuff refs _yourstuff// Comment";
	IFile file = IResourcesSetupUtil.createFile("test/test.testlanguage", modelAsText);
	editor = openEditor(file);
	document = editor.getDocument();
	hover = TestsActivator.getInstance().getInjector(getEditorId()).getInstance(ProblemAnnotationHover.class);
	hover.setSourceViewer(editor.getInternalSourceViewer());
	List<Issue> issues = document.readOnly(new IUnitOfWork<List<Issue>, XtextResource>() {
		@Override
		public List<Issue> exec(XtextResource state) throws Exception {
			return state.getResourceServiceProvider().getResourceValidator().validate(state, CheckMode.ALL, null);
		}	
	});
	MarkerCreator markerCreator =  TestsActivator.getInstance().getInjector(getEditorId()).getInstance(MarkerCreator.class);
	for (Issue issue : issues) {
		markerCreator.createMarker(issue, file, MarkerTypes.forCheckType(issue.getType()));
	}
}
 
Example 6
Source File: Bug456868Test.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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);
  }
}
 
Example 7
Source File: AbstractOutlineWorkbenchTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void setUp() throws Exception {
	super.setUp();
	preferenceStore = new ScopedPreferenceStore(new InstanceScope(), getEditorId());
	comparer = new IOutlineNodeComparer.Default();
	modelAsText = "one { two {} three {} } four {}";
	file = IResourcesSetupUtil.createFile("test/test.outlinetestlanguage", modelAsText);
	editor = openEditor(file);
	document = editor.getDocument();
	outlineView = editor.getEditorSite().getPage().showView("org.eclipse.ui.views.ContentOutline");
	executeAsyncDisplayJobs();
	Object adapter = editor.getAdapter(IContentOutlinePage.class);
	assertTrue(adapter instanceof SyncableOutlinePage);
	outlinePage = (SyncableOutlinePage) adapter;
	outlinePage.resetSyncer();
	try {
		outlinePage.waitForUpdate(EXPECTED_TIMEOUT);
	} catch (TimeoutException e) {
		System.out.println("Expected timeout exceeded: "+EXPECTED_TIMEOUT);// timeout is OK here
	}
	treeViewer = outlinePage.getTreeViewer();
	assertSelected(treeViewer);
	assertExpanded(treeViewer);
	assertTrue(treeViewer.getInput() instanceof IOutlineNode);
	IOutlineNode rootNode = (IOutlineNode) treeViewer.getInput();
	List<IOutlineNode> children = rootNode.getChildren();
	assertEquals(1, children.size());
	modelNode = children.get(0);
	assertEquals(2, modelNode.getChildren().size());
	oneNode = modelNode.getChildren().get(0);
	assertEquals(2, oneNode.getChildren().size());
	twoNode = oneNode.getChildren().get(0);
	threeNode = oneNode.getChildren().get(1);
	fourNode = modelNode.getChildren().get(1);
}
 
Example 8
Source File: XtextElementLinksTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	modelAsText = "stuff mystuff\nstuff yourstuff";
	IFile file = IResourcesSetupUtil.createFile("test/test.testlanguage", modelAsText);
	editor = openEditor(file);
	document = editor.getDocument();
	elementLinks = TestsActivator.getInstance().getInjector(getEditorId()).getInstance (XtextElementLinks.class);
	f = document.readOnly(new IUnitOfWork<File, XtextResource>() {
		@Override
		public File exec(XtextResource state) throws Exception {
			return (File) state.getContents().get(0);
		}	
	});	
}
 
Example 9
Source File: AnnotationWithQuickFixesHoverTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	modelAsText = "stuff mystuff stuff yourstuff refs _mystuff stuff hisstuff refs _yourstuff";
	IFile file = IResourcesSetupUtil.createFile("test/test.testlanguage", modelAsText);
	editor = openEditor(file);
	document = editor.getDocument();
	hover = TestsActivator.getInstance().getInjector(getEditorId()).getInstance(AnnotationWithQuickFixesHover.class);
	hover.setSourceViewer(editor.getInternalSourceViewer());
	List<Issue> issues = document.readOnly(new IUnitOfWork<List<Issue>, XtextResource>() {
		@Override
		public List<Issue> exec(XtextResource state) throws Exception {
			return state.getResourceServiceProvider().getResourceValidator().validate(state, CheckMode.ALL, null);
		}
	});
	assertEquals(2, issues.size());
	MarkerCreator markerCreator = TestsActivator.getInstance().getInjector(getEditorId())
			.getInstance(MarkerCreator.class);
	for (Issue issue : issues) {
		markerCreator.createMarker(issue, file, MarkerTypes.forCheckType(issue.getType()));
	}

	if (Display.getCurrent().getActiveShell() != editor.getShell()) {
		System.out.println("Editor shell is not active. Active shell is: " + Display.getCurrent().getActiveShell());
		getWorkbenchWindow().getShell().forceActive();
		editor.getInternalSourceViewer().getTextWidget().forceFocus();
	}

}
 
Example 10
Source File: DispatchingEObjectTextHoverTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	modelAsText = "stuff mystuff stuff yourstuff refs mystuff // Comment";
	IFile file = IResourcesSetupUtil.createFile("test/test.testlanguage", modelAsText);
	editor = openEditor(file);
	document = editor.getDocument();
	hover = TestsActivator.getInstance().getInjector(getEditorId()).getInstance(MockHover.class);
}
 
Example 11
Source File: UniqueClassNameValidatorUITest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Ignore("Since the name acme.A is considered to be derived, it is filtered from the Java delta")
@Test
public void testXtendAndJavaSameProjectXtendFirst() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package acme");
    _builder.newLine();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IFile firstFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/B.xtend", _builder.toString());
    this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package acme;");
    _builder_1.newLine();
    _builder_1.append("class A2 {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final IFile javaFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/A.java", _builder_1.toString());
    this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    StringInputStream _stringInputStream = new StringInputStream("package acme; class A{}");
    javaFile.setContents(_stringInputStream, false, false, null);
    this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, JavaCore.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    final IMarker[] markers = firstFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    Assert.assertEquals(IResourcesSetupUtil.printMarker(markers), 1, markers.length);
    Assert.assertEquals("The type A is already defined in A.java.", IterableExtensions.<IMarker>head(((Iterable<IMarker>)Conversions.doWrapArray(markers))).getAttribute(IMarker.MESSAGE));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 12
Source File: AbstractEditorDoubleClickTextSelectionTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected IFile createFile(String content) {
	try {
		return IResourcesSetupUtil.createFile(getProjectName(), getFileName(), getFileExtension(), content);
	} catch (InvocationTargetException | CoreException | InterruptedException e) {
		throw new RuntimeException(e);
	}
}
 
Example 13
Source File: Bug379500Test.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	// We open a second Editor. Due to bug 379500 a singelton of
	// org.eclipse.xtext.ui.editor.outline.actions.IOutlineContribution.Composite
	// was used, so all outline actions only worked for the last recent opened editor.
	String modelAsText2 = "one { x {} y {} } z {}";
	IFile file2 = IResourcesSetupUtil.createFile("test/Bug379500Test.outlinetestlanguage", modelAsText2);
	openEditor(file2);
}
 
Example 14
Source File: AbstractEditorTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected IFile dslFile(String projectName, String fileName, String fileExtension, CharSequence content) {
	try {
		IFile file = IResourcesSetupUtil.createFile(projectName, fileName, fileExtension, content.toString());
		IProject project = file.getProject();
		if (!project.hasNature(XtextProjectHelper.NATURE_ID)) {
			IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
		}
		return file;
	} catch (InvocationTargetException | CoreException | InterruptedException e) {
		throw new RuntimeException(e);
	}
}
 
Example 15
Source File: UniqueClassNameValidatorUITest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testTwoXtendFilesSameProject() {
  try {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package acme");
    _builder.newLine();
    _builder.append("class A {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IFile firstFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/A.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package acme");
    _builder_1.newLine();
    _builder_1.append("class A {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    final IFile secondFile = IResourcesSetupUtil.createFile("first.p384008/src/acme/B.xtend", _builder_1.toString());
    final IWorkspaceRunnable _function = (IProgressMonitor it) -> {
      this.first.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, XtextBuilder.BUILDER_ID, UniqueClassNameValidatorUITest.emptyStringMap(), null);
    };
    this.runInWorkspace(_function);
    final IMarker[] firstFileMarkers = firstFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
    Assert.assertEquals(IResourcesSetupUtil.printMarker(firstFileMarkers), 1, firstFileMarkers.length);
    Assert.assertEquals("The type A is already defined in B.xtend.", IterableExtensions.<IMarker>head(((Iterable<IMarker>)Conversions.doWrapArray(firstFileMarkers))).getAttribute(IMarker.MESSAGE));
    final Iterable<IMarker> secondFileMarkers = this.onlyErrors(((Iterable<IMarker>)Conversions.doWrapArray(secondFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE))));
    Assert.assertEquals(IResourcesSetupUtil.printMarker(((IMarker[])Conversions.unwrapArray(secondFileMarkers, IMarker.class))), 1, ((Object[])Conversions.unwrapArray(secondFileMarkers, Object.class)).length);
    Assert.assertEquals("The type A is already defined in A.xtend.", IterableExtensions.<IMarker>head(secondFileMarkers).getAttribute(IMarker.MESSAGE));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 16
Source File: AbstractOutlineTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected IOutlineNode getOutlineTree(CharSequence modelAsText)
		throws Exception {
	file = IResourcesSetupUtil.createFile(TEST_PROJECT + "/test."
			+ fileExtension, modelAsText.toString());
	editor = openEditor(file);
	document = editor.getDocument();
	return treeProvider.createRoot(document);
}
 
Example 17
Source File: RebuildDependentResourcesTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public static IFile createFile(String projectRelative, String content) throws CoreException, InvocationTargetException,
	InterruptedException {
	return IResourcesSetupUtil.createFile(new Path("RebuildDependentResourcesTest/" + projectRelative), content);
}
 
Example 18
Source File: WorkbenchTestHelper.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public IFile createFileImpl(String fullFileName, String content) throws Exception {
	IFile file = IResourcesSetupUtil.createFile(fullFileName, content);
	getFiles().add(file);
	return file;
}
 
Example 19
Source File: ResolvingCrossReferenceDuringIndexingTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testResolvingJvmParameterizedTypeReference() {
  try {
    final IProject annoProject = WorkbenchTestHelper.createPluginProject("annotation.project", "com.google.inject", 
      "org.eclipse.xtend.lib", "org.eclipse.xtext.xbase.lib", "org.eclipse.xtend.core");
    WorkbenchTestHelper.addExportedPackages(annoProject, "myannotation");
    Path _path = new Path("/annotation.project/src/myannotation/MyAnnotation.xtend");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package myannotation");
    _builder.newLine();
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.macro.AbstractClassProcessor");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.macro.Active");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.macro.RegisterGlobalsContext");
    _builder.newLine();
    _builder.append("import org.eclipse.xtend.lib.macro.declaration.ClassDeclaration");
    _builder.newLine();
    _builder.append("import org.eclipse.xtext.common.types.impl.JvmParameterizedTypeReferenceImpl");
    _builder.newLine();
    _builder.append("import org.eclipse.xtext.xbase.lib.util.ReflectExtensions");
    _builder.newLine();
    _builder.newLine();
    _builder.append("@Active(MyAnnotationProcessor)");
    _builder.newLine();
    _builder.append("annotation MyAnnotation {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class MyAnnotationProcessor extends AbstractClassProcessor {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("extension ReflectExtensions _reflectExtensions = new ReflectExtensions()");
    _builder.newLine();
    _builder.newLine();
    _builder.append("\t");
    _builder.append("override doRegisterGlobals(ClassDeclaration annotatedClass, extension RegisterGlobalsContext context) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("val xtendClass = annotatedClass.invoke(\'getDelegate\')");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (!(xtendClass.invoke(\'getExtends\').invoke(\'basicGetType\').invoke(\'eIsProxy\') as Boolean)) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("throw new IllegalStateException(\"Before: Type should be a proxy.\")");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("annotatedClass.extendedClass");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("if (!(xtendClass.invoke(\'getExtends\').invoke(\'basicGetType\').invoke(\'eIsProxy\') as Boolean)) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("throw new IllegalStateException(\"After: Type should be a proxy.\")");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    IResourcesSetupUtil.createFile(_path, _builder.toString());
    IResourcesSetupUtil.waitForBuild();
    this.assertNoErrorsInWorkspace();
    WorkbenchTestHelper.createPluginProject("client.project", "com.google.inject", "org.eclipse.xtend.lib", 
      "org.eclipse.xtext.xbase.lib", "annotation.project");
    Path _path_1 = new Path("/client.project/src/mypackage/MyClient.xtend");
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package mypackage");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("import myannotation.MyAnnotation");
    _builder_1.newLine();
    _builder_1.append("import java.util.ArrayList");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("@MyAnnotation");
    _builder_1.newLine();
    _builder_1.append("class MyClient extends ArrayList<Object> {");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    IResourcesSetupUtil.createFile(_path_1, _builder_1.toString());
    IResourcesSetupUtil.waitForBuild();
    this.assertNoErrorsInWorkspace();
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 20
Source File: WorkspaceScenariosTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testIncrementalChangeOnBidirectionalDep() {
  try {
    WorkbenchTestHelper.createPluginProject("my.project", "org.eclipse.xtext.xbase.lib", "org.eclipse.xtend.lib");
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package mypack");
    _builder.newLine();
    _builder.newLine();
    _builder.append("class ClassA {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("def void myMethod(ClassB b) {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("b.myMethod");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final IFile fileA = IResourcesSetupUtil.createFile("my.project/src/mypack/ClassA.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("package mypack");
    _builder_1.newLine();
    _builder_1.newLine();
    _builder_1.append("class ClassB {");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("def void anotherMethod(ClassA a) {");
    _builder_1.newLine();
    _builder_1.append("\t\t");
    _builder_1.append("a.anotherMethod");
    _builder_1.newLine();
    _builder_1.append("\t");
    _builder_1.append("}");
    _builder_1.newLine();
    _builder_1.append("}");
    _builder_1.newLine();
    IResourcesSetupUtil.createFile("my.project/src/mypack/ClassB.xtend", _builder_1.toString());
    IResourcesSetupUtil.waitForBuild();
    IResourcesSetupUtil.assertNoErrorsInWorkspace();
    final IFile javaB = fileA.getProject().getFile("xtend-gen/mypack/ClassB.java");
    Assert.assertTrue(WorkbenchTestHelper.getContentsAsString(javaB).contains("anotherMethod(a);"));
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("package mypack");
    _builder_2.newLine();
    _builder_2.newLine();
    _builder_2.append("class ClassA {");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("def void myMethod(ClassB b) {");
    _builder_2.newLine();
    _builder_2.append("\t\t");
    _builder_2.append("b.myMethod");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("}");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.newLine();
    _builder_2.append("\t");
    _builder_2.append("def void anotherMethod() {}");
    _builder_2.newLine();
    _builder_2.append("}");
    _builder_2.newLine();
    StringInputStream _stringInputStream = new StringInputStream(_builder_2.toString());
    fileA.setContents(_stringInputStream, true, true, null);
    IResourcesSetupUtil.waitForBuild();
    IResourcesSetupUtil.assertNoErrorsInWorkspace();
    Assert.assertTrue(WorkbenchTestHelper.getContentsAsString(javaB).contains("a.anotherMethod();"));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}