Search in sources :

Example 6 with FieldDeclaration

use of org.eclipse.xtend.lib.macro.declaration.FieldDeclaration in project xtext-xtend by eclipse.

the class ExternalizedProcessor method doGenerateCode.

@Override
public void doGenerateCode(final List<? extends ClassDeclaration> annotatedSourceElements, @Extension final CodeGenerationContext context) {
    for (final ClassDeclaration clazz : annotatedSourceElements) {
        {
            final Path filePath = clazz.getCompilationUnit().getFilePath();
            Path _targetFolder = context.getTargetFolder(filePath);
            String _replace = clazz.getQualifiedName().replace(".", "/");
            String _plus = (_replace + ".properties");
            final Path file = _targetFolder.append(_plus);
            StringConcatenation _builder = new StringConcatenation();
            {
                Iterable<? extends FieldDeclaration> _declaredFields = clazz.getDeclaredFields();
                for (final FieldDeclaration field : _declaredFields) {
                    String _simpleName = field.getSimpleName();
                    _builder.append(_simpleName);
                    _builder.append(" = ");
                    String _initializerAsString = this.getInitializerAsString(field);
                    _builder.append(_initializerAsString);
                    _builder.newLineIfNotEmpty();
                }
            }
            context.setContents(file, _builder);
        }
    }
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) ClassDeclaration(org.eclipse.xtend.lib.macro.declaration.ClassDeclaration) MutableClassDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) MutableFieldDeclaration(org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration) FieldDeclaration(org.eclipse.xtend.lib.macro.declaration.FieldDeclaration)

Aggregations

FieldDeclaration (org.eclipse.xtend.lib.macro.declaration.FieldDeclaration)6 MutableFieldDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration)6 ClassDeclaration (org.eclipse.xtend.lib.macro.declaration.ClassDeclaration)5 MutableClassDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration)5 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)5 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)4 AnnotationTypeDeclaration (org.eclipse.xtend.lib.macro.declaration.AnnotationTypeDeclaration)4 TypeDeclaration (org.eclipse.xtend.lib.macro.declaration.TypeDeclaration)4 Test (org.junit.Test)4 AccessibleObject (java.lang.reflect.AccessibleObject)3 MemberDeclaration (org.eclipse.xtend.lib.macro.declaration.MemberDeclaration)2 MutableMemberDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableMemberDeclaration)2 AccessorType (org.eclipse.xtend.lib.annotations.AccessorType)1 AccessorsProcessor (org.eclipse.xtend.lib.annotations.AccessorsProcessor)1 EqualsHashCodeProcessor (org.eclipse.xtend.lib.annotations.EqualsHashCodeProcessor)1 FinalFieldsConstructor (org.eclipse.xtend.lib.annotations.FinalFieldsConstructor)1 FinalFieldsConstructorProcessor (org.eclipse.xtend.lib.annotations.FinalFieldsConstructorProcessor)1 ToStringConfiguration (org.eclipse.xtend.lib.annotations.ToStringConfiguration)1 ToStringProcessor (org.eclipse.xtend.lib.annotations.ToStringProcessor)1 AnnotationReference (org.eclipse.xtend.lib.macro.declaration.AnnotationReference)1