use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class MethodBuilderTest method testXtendTypeParameter.
@Test
public void testXtendTypeParameter() {
AbstractMethodBuilder _createMethodBuilder = this._codeBuilderFactory.createMethodBuilder(this.getXtendClass());
final Procedure1<AbstractMethodBuilder> _function = (AbstractMethodBuilder it) -> {
it.setContext(this.getXtendClass());
it.setMethodName("foo");
JvmTypeParameter _createJvmTypeParameter = this._typesFactory.createJvmTypeParameter();
final Procedure1<JvmTypeParameter> _function_1 = (JvmTypeParameter it_1) -> {
it_1.setName("T");
};
JvmTypeParameter _doubleArrow = ObjectExtensions.<JvmTypeParameter>operator_doubleArrow(_createJvmTypeParameter, _function_1);
JvmTypeParameter _createJvmTypeParameter_1 = this._typesFactory.createJvmTypeParameter();
final Procedure1<JvmTypeParameter> _function_2 = (JvmTypeParameter it_1) -> {
it_1.setName("U");
};
JvmTypeParameter _doubleArrow_1 = ObjectExtensions.<JvmTypeParameter>operator_doubleArrow(_createJvmTypeParameter_1, _function_2);
it.setTypeParameters(Collections.<JvmTypeParameter>unmodifiableList(CollectionLiterals.<JvmTypeParameter>newArrayList(_doubleArrow, _doubleArrow_1)));
};
AbstractMethodBuilder _doubleArrow = ObjectExtensions.<AbstractMethodBuilder>operator_doubleArrow(_createMethodBuilder, _function);
StringConcatenation _builder = new StringConcatenation();
_builder.append("def <T,U> foo() {");
_builder.newLine();
_builder.append(" ");
_builder.append(AbstractBuilderTest.DEFAULT_BODY, " ");
_builder.newLineIfNotEmpty();
_builder.append("}");
this.assertBuilds(_doubleArrow, _builder.toString());
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class MethodBuilderTest method testXtendNamedParameter.
@Test
public void testXtendNamedParameter() {
AbstractMethodBuilder _createMethodBuilder = this._codeBuilderFactory.createMethodBuilder(this.getXtendClass());
final Procedure1<AbstractMethodBuilder> _function = (AbstractMethodBuilder it) -> {
it.setContext(this.getXtendClass());
it.setMethodName("foo");
AbstractParameterBuilder _newParameterBuilder = it.newParameterBuilder();
final Procedure1<AbstractParameterBuilder> _function_1 = (AbstractParameterBuilder it_1) -> {
it_1.setName("bar");
it_1.setType(this.createTypeRef(this.getXtendClass()));
};
ObjectExtensions.<AbstractParameterBuilder>operator_doubleArrow(_newParameterBuilder, _function_1);
AbstractParameterBuilder _newParameterBuilder_1 = it.newParameterBuilder();
final Procedure1<AbstractParameterBuilder> _function_2 = (AbstractParameterBuilder it_1) -> {
it_1.setName("baz");
it_1.setType(this.createTypeRef(this.getXtendClass()));
};
ObjectExtensions.<AbstractParameterBuilder>operator_doubleArrow(_newParameterBuilder_1, _function_2);
};
AbstractMethodBuilder _doubleArrow = ObjectExtensions.<AbstractMethodBuilder>operator_doubleArrow(_createMethodBuilder, _function);
StringConcatenation _builder = new StringConcatenation();
_builder.append("def foo(Foo bar, Foo baz) {");
_builder.newLine();
_builder.append(" ");
_builder.append(AbstractBuilderTest.DEFAULT_BODY, " ");
_builder.newLineIfNotEmpty();
_builder.append("}");
this.assertBuilds(_doubleArrow, _builder.toString());
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class MethodBuilderTest method testXtendCustomBody.
@Test
public void testXtendCustomBody() {
AbstractMethodBuilder _createMethodBuilder = this._codeBuilderFactory.createMethodBuilder(this.getXtendClass());
final Procedure1<AbstractMethodBuilder> _function = (AbstractMethodBuilder it) -> {
it.setContext(this.getXtendClass());
it.setMethodName("foo");
final Procedure1<ISourceAppender> _function_1 = (ISourceAppender it_1) -> {
it_1.append("return");
};
it.setBodyGenerator(_function_1);
};
AbstractMethodBuilder _doubleArrow = ObjectExtensions.<AbstractMethodBuilder>operator_doubleArrow(_createMethodBuilder, _function);
StringConcatenation _builder = new StringConcatenation();
_builder.append("def foo() {");
_builder.newLine();
_builder.append(" ");
_builder.append("return");
_builder.newLine();
_builder.append("}");
this.assertBuilds(_doubleArrow, _builder.toString());
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class MethodBuilderTest method testJavaCustomBody.
@Test
public void testJavaCustomBody() {
AbstractMethodBuilder _createMethodBuilder = this._codeBuilderFactory.createMethodBuilder(this.getJavaClass());
final Procedure1<AbstractMethodBuilder> _function = (AbstractMethodBuilder it) -> {
it.setContext(this.getJavaClass());
it.setMethodName("foo");
final Procedure1<ISourceAppender> _function_1 = (ISourceAppender it_1) -> {
it_1.append("return");
};
it.setBodyGenerator(_function_1);
};
AbstractMethodBuilder _doubleArrow = ObjectExtensions.<AbstractMethodBuilder>operator_doubleArrow(_createMethodBuilder, _function);
StringConcatenation _builder = new StringConcatenation();
_builder.append("void foo() {");
_builder.newLine();
_builder.append(" ");
_builder.append("return;");
_builder.newLine();
_builder.append("}");
this.assertBuilds(_doubleArrow, _builder.toString());
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-xtend by eclipse.
the class DocumentRewriterTest method createDocument.
protected XtextDocument createDocument(final String content) throws Exception {
XtextDocument _xblockexpression = null;
{
final IFile file = this._workbenchTestHelper.createFile("Foo", content);
final Resource resource = this._workbenchTestHelper.getResourceSet().getResource(URI.createPlatformResourceURI(file.getFullPath().toString(), true), true);
XtendDocumentTokenSource _xtendDocumentTokenSource = new XtendDocumentTokenSource();
final Procedure1<XtendDocumentTokenSource> _function = (XtendDocumentTokenSource it) -> {
AntlrTokenDefProvider _antlrTokenDefProvider = new AntlrTokenDefProvider();
final Procedure1<AntlrTokenDefProvider> _function_1 = (AntlrTokenDefProvider it_1) -> {
XtendAntlrTokenFileProvider _xtendAntlrTokenFileProvider = new XtendAntlrTokenFileProvider();
it_1.setAntlrTokenFileProvider(_xtendAntlrTokenFileProvider);
};
AntlrTokenDefProvider _doubleArrow = ObjectExtensions.<AntlrTokenDefProvider>operator_doubleArrow(_antlrTokenDefProvider, _function_1);
it.setTokenDefProvider(_doubleArrow);
final Provider<Lexer> _function_2 = () -> {
InternalXtendLexer _internalXtendLexer = new InternalXtendLexer();
return ((Lexer) _internalXtendLexer);
};
it.setLexer(_function_2);
it.setFlexerFactory(this.flexerFactory);
};
final XtendDocumentTokenSource source = ObjectExtensions.<XtendDocumentTokenSource>operator_doubleArrow(_xtendDocumentTokenSource, _function);
final XtextDocument document = new XtextDocument(source, null, this.outdatedStateManager, this.operationCanceledManager);
document.set(content);
document.setInput(((XtextResource) resource));
_xblockexpression = document;
}
return _xblockexpression;
}
Aggregations