Search in sources :

Example 86 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-xtend by eclipse.

the class ArtificialMethodsProcessor method doTransform.

@Override
public void doTransform(final MutableClassDeclaration annotatedClass, @Extension final TransformationContext context) {
    final Procedure1<MutableMethodDeclaration> _function = (MutableMethodDeclaration it) -> {
        final CompilationStrategy _function_1 = (CompilationStrategy.CompilationContext it_1) -> {
            StringConcatenation _builder = new StringConcatenation();
            return _builder;
        };
        it.setBody(_function_1);
    };
    annotatedClass.addMethod("blank", _function);
    final Procedure1<MutableMethodDeclaration> _function_1 = (MutableMethodDeclaration it) -> {
        final CompilationStrategy _function_2 = (CompilationStrategy.CompilationContext it_1) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("\t\t\t\t");
            _builder.newLine();
            return _builder;
        };
        it.setBody(_function_2);
    };
    annotatedClass.addMethod("blank_1", _function_1);
    final Procedure1<MutableMethodDeclaration> _function_2 = (MutableMethodDeclaration it) -> {
        final CompilationStrategy _function_3 = (CompilationStrategy.CompilationContext it_1) -> {
            return "";
        };
        it.setBody(_function_3);
    };
    annotatedClass.addMethod("blank_2", _function_2);
    final Procedure1<MutableMethodDeclaration> _function_3 = (MutableMethodDeclaration it) -> {
        final CompilationStrategy _function_4 = (CompilationStrategy.CompilationContext it_1) -> {
            return "\n";
        };
        it.setBody(_function_4);
    };
    annotatedClass.addMethod("blank_3", _function_3);
    final Procedure1<MutableMethodDeclaration> _function_4 = (MutableMethodDeclaration it) -> {
        final CompilationStrategy _function_5 = (CompilationStrategy.CompilationContext it_1) -> {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("int foo = 42;");
            _builder.newLine();
            return _builder;
        };
        it.setBody(_function_5);
    };
    annotatedClass.addMethod("blank_4", _function_4);
    final Procedure1<MutableMethodDeclaration> _function_5 = (MutableMethodDeclaration it) -> {
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("int foo = 42;");
                _builder.newLine();
            }
        };
        it.setBody(_client);
    };
    annotatedClass.addMethod("blank_5", _function_5);
    final Procedure1<MutableMethodDeclaration> _function_6 = (MutableMethodDeclaration it) -> {
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append("int foo = 42;");
            }
        };
        it.setBody(_client);
    };
    annotatedClass.addMethod("blank_6", _function_6);
    final Procedure1<MutableMethodDeclaration> _function_7 = (MutableMethodDeclaration it) -> {
        StringConcatenationClient _client = new StringConcatenationClient() {

            @Override
            protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                _builder.append(List.class);
                _builder.append("<? extends Object> list = new ");
                _builder.append(ArrayList.class);
                _builder.append("<");
                _builder.append(BigDecimal.class);
                _builder.append(">();");
            }
        };
        it.setBody(_client);
    };
    annotatedClass.addMethod("blank_7", _function_7);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) MutableMethodDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableMethodDeclaration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) CompilationStrategy(org.eclipse.xtend.lib.macro.declaration.CompilationStrategy) BigDecimal(java.math.BigDecimal)

Example 87 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-xtend by eclipse.

the class ToAnnoProcessor method doTransform.

@Override
public void doTransform(final MutableClassDeclaration annotatedClass, @Extension final TransformationContext context) {
    super.doTransform(annotatedClass, context);
    Type _findTypeGlobally = context.findTypeGlobally(this.generatedAnnotationName(annotatedClass));
    final MutableAnnotationTypeDeclaration annotationType = ((MutableAnnotationTypeDeclaration) _findTypeGlobally);
    final Procedure1<MutableAnnotationTypeElementDeclaration> _function = (MutableAnnotationTypeElementDeclaration it) -> {
        it.setDocComment("Best building strategy game ever");
        it.setType(context.newTypeReference(Integer.TYPE));
        boolean _booleanValue = annotatedClass.findAnnotation(context.findTypeGlobally(ToAnno.class)).getBooleanValue("defaultValue");
        if (_booleanValue) {
            StringConcatenationClient _client = new StringConcatenationClient() {

                @Override
                protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                    _builder.append("1602");
                }
            };
            it.setDefaultValueExpression(_client);
        }
    };
    annotationType.addAnnotationTypeElement("anno", _function);
}
Also used : Type(org.eclipse.xtend.lib.macro.declaration.Type) MutableAnnotationTypeElementDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableAnnotationTypeElementDeclaration) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) ToAnno(org.eclipse.xtend.core.tests.macro.ToAnno) MutableAnnotationTypeDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableAnnotationTypeDeclaration)

Example 88 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-xtend by eclipse.

the class MutableJvmFieldDeclarationImpl method setConstantValueAsString.

@Override
public void setConstantValueAsString(final String value) {
    this.internalGenericSetConstantValue(value);
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("\"");
            String _convertToJavaString = Strings.convertToJavaString(value);
            _builder.append(_convertToJavaString);
            _builder.append("\"");
        }
    };
    this.getCompilationUnit().setCompilationTemplate(this.getDelegate(), _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient)

Example 89 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-xtend by eclipse.

the class MutableJvmFieldDeclarationImpl method setConstantValueAsChar.

@Override
public void setConstantValueAsChar(final char value) {
    this.internalGenericSetConstantValue(Character.valueOf(value));
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append("\'");
            String _convertToJavaString = Strings.convertToJavaString(Character.toString(value));
            _builder.append(_convertToJavaString);
            _builder.append("\'");
        }
    };
    this.getCompilationUnit().setCompilationTemplate(this.getDelegate(), _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient)

Example 90 with StringConcatenationClient

use of org.eclipse.xtend2.lib.StringConcatenationClient in project xtext-xtend by eclipse.

the class MutableJvmFieldDeclarationImpl method setConstantValueAsFloat.

@Override
public void setConstantValueAsFloat(final float value) {
    this.internalGenericSetConstantValue(Float.valueOf(value));
    StringConcatenationClient _client = new StringConcatenationClient() {

        @Override
        protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
            _builder.append(value);
            _builder.append("f");
        }
    };
    this.getCompilationUnit().setCompilationTemplate(this.getDelegate(), _client);
}
Also used : StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient)

Aggregations

StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)194 TypeReference (org.eclipse.xtext.xtext.generator.model.TypeReference)119 GeneratedJavaFileAccess (org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess)24 GuiceModuleAccess (org.eclipse.xtext.xtext.generator.model.GuiceModuleAccess)24 Grammar (org.eclipse.xtext.Grammar)23 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)19 List (java.util.List)18 Test (org.junit.Test)18 Set (java.util.Set)14 JavaFileAccess (org.eclipse.xtext.xtext.generator.model.JavaFileAccess)12 ManifestAccess (org.eclipse.xtext.xtext.generator.model.ManifestAccess)12 EClass (org.eclipse.emf.ecore.EClass)11 EList (org.eclipse.emf.common.util.EList)10 AbstractRule (org.eclipse.xtext.AbstractRule)10 IGeneratorNode (org.eclipse.xtext.generator.trace.node.IGeneratorNode)10 EObject (org.eclipse.emf.ecore.EObject)9 IClassAnnotation (org.eclipse.xtext.xtext.generator.model.annotations.IClassAnnotation)9 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)8 SuppressWarningsAnnotation (org.eclipse.xtext.xtext.generator.model.annotations.SuppressWarningsAnnotation)8 ArrayList (java.util.ArrayList)7