use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-xtend by eclipse.
the class AbstractSingleEditorQueuedBuildTest method renameLocalVariable.
@Test
public void renameLocalVariable() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package mypackage;");
_builder.newLine();
_builder.newLine();
_builder.append("public class Bar {");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("private void bar() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("int x = 3;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("}");
_builder.newLine();
this.testHelper.createFile("/mypackage/Bar.java", _builder.toString());
final Procedure0 _function = () -> {
this.save("/mypackage/Bar.java", "x", "y");
};
this.assertThereAreNotDeltas(_function);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-xtend by eclipse.
the class ResourceStorageTest method testShouldLoadFromStorage.
@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);
}
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-xtend by eclipse.
the class Bug464136Processor method doTransform.
@Override
public void doTransform(final MutableClassDeclaration annotatedClass, @Extension final TransformationContext context) {
final Procedure0 _function = () -> {
throw new LinkageError("Just a test :-/");
};
context.validateLater(_function);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-xtend by eclipse.
the class CheckMutableClassDeclarationProcessor method doTransform.
@Override
public void doTransform(final MutableClassDeclaration annotatedClass, @Extension final TransformationContext context) {
final Procedure0 _function = () -> {
annotatedClass.setImplementedInterfaces(null);
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "superIntefaces cannot be null", _function);
final Procedure0 _function_1 = () -> {
annotatedClass.setImplementedInterfaces(Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList((TypeReference) null)));
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "superIntefaces cannot contain null", _function_1);
annotatedClass.setImplementedInterfaces(CollectionLiterals.<TypeReference>emptyList());
final Procedure1<String> _function_2 = (String identifier) -> {
annotatedClass.addTypeParameter(identifier).remove();
};
MutableAssert.assertValidJavaIdentifier("name", _function_2);
final Procedure0 _function_3 = () -> {
annotatedClass.addTypeParameter("T", ((TypeReference[]) null));
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot be null", _function_3);
final Procedure0 _function_4 = () -> {
annotatedClass.addTypeParameter("T", new TypeReference[] { null });
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot contain null", _function_4);
final MutableTypeParameterDeclaration typeParameter = annotatedClass.addTypeParameter("T");
final Procedure1<String> _function_5 = (String identifier) -> {
typeParameter.setSimpleName(identifier);
};
MutableAssert.assertValidJavaIdentifier("name", _function_5);
final Procedure0 _function_6 = () -> {
typeParameter.setUpperBounds(null);
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot be null", _function_6);
final Procedure0 _function_7 = () -> {
typeParameter.setUpperBounds(Collections.<TypeReference>unmodifiableList(CollectionLiterals.<TypeReference>newArrayList((TypeReference) null)));
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "upperBounds cannot contain null", _function_7);
typeParameter.setUpperBounds(CollectionLiterals.<TypeReference>emptyList());
final Procedure0 _function_8 = () -> {
annotatedClass.setSimpleName(null);
};
MutableAssert.<UnsupportedOperationException>assertThrowable(UnsupportedOperationException.class, "The type cannot be renamed.", _function_8);
final Procedure1<String> _function_9 = (String identifier) -> {
final Procedure1<MutableFieldDeclaration> _function_10 = (MutableFieldDeclaration it) -> {
it.setType(context.newTypeReference(String.class));
};
annotatedClass.addField(identifier, _function_10).remove();
};
MutableAssert.assertValidJavaIdentifier("name", _function_9);
final Procedure0 _function_10 = () -> {
annotatedClass.addField("foo", null);
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "initializer cannot be null", _function_10);
final Procedure1<String> _function_11 = (String identifier) -> {
final Procedure1<MutableMethodDeclaration> _function_12 = (MutableMethodDeclaration it) -> {
};
annotatedClass.addMethod(identifier, _function_12).remove();
};
MutableAssert.assertValidJavaIdentifier("name", _function_11);
final Procedure0 _function_12 = () -> {
annotatedClass.addMethod("foo", null);
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "initializer cannot be null", _function_12);
final Procedure0 _function_13 = () -> {
annotatedClass.addConstructor(null);
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "initializer cannot be null", _function_13);
final Procedure1<MutableMethodDeclaration> _function_14 = (MutableMethodDeclaration it) -> {
};
final MutableMethodDeclaration method = annotatedClass.addMethod("foo", _function_14);
annotatedClass.findDeclaredMethod(null);
annotatedClass.findDeclaredMethod("foo");
final Procedure0 _function_15 = () -> {
annotatedClass.findDeclaredMethod("foo", ((TypeReference[]) null));
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "parameterTypes cannot be null", _function_15);
final Procedure0 _function_16 = () -> {
annotatedClass.findDeclaredMethod("foo", new TypeReference[] { null });
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "parameterTypes cannot contain null", _function_16);
annotatedClass.findDeclaredMethod("foo", ((TypeReference[]) Conversions.unwrapArray(CollectionLiterals.<TypeReference>emptyList(), TypeReference.class)));
method.remove();
final Procedure0 _function_17 = () -> {
annotatedClass.findDeclaredConstructor(((TypeReference[]) null));
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "parameterTypes cannot be null", _function_17);
final Procedure0 _function_18 = () -> {
annotatedClass.findDeclaredConstructor(new TypeReference[] { null });
};
MutableAssert.<IllegalArgumentException>assertThrowable(IllegalArgumentException.class, "parameterTypes cannot contain null", _function_18);
annotatedClass.findDeclaredConstructor(((TypeReference[]) Conversions.unwrapArray(CollectionLiterals.<TypeReference>emptyList(), TypeReference.class)));
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure0 in project xtext-xtend by eclipse.
the class XtendEditorChangingClasspathTest method assertAddLibsToClasspath.
public void assertAddLibsToClasspath(final IJavaProject project) {
final Procedure0 _function = () -> {
this._xtendLibClasspathAdder.addLibsToClasspath(project, null);
};
Assert.assertNotNull(this.waitForCoarseGrainedEvent(_function));
}
Aggregations