org.eclipse.xtend.lib.macro.declaration.FieldDeclaration Java Examples
The following examples show how to use
org.eclipse.xtend.lib.macro.declaration.FieldDeclaration.
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: TypeAdapterImplProcessor.java From lsp4j with Eclipse Public License 2.0 | 6 votes |
private ArrayList<FieldDeclaration> getTargetFields(final TypeReference targetType, @Extension final TransformationContext context) { final Type objectType = context.newTypeReference(Object.class).getType(); final ArrayList<FieldDeclaration> targetFields = CollectionLiterals.<FieldDeclaration>newArrayList(); TypeReference typeRef = targetType; while ((!Objects.equal(typeRef.getType(), objectType))) { { Type _type = typeRef.getType(); final ClassDeclaration clazz = ((ClassDeclaration) _type); final Function1<FieldDeclaration, Boolean> _function = (FieldDeclaration it) -> { boolean _isStatic = it.isStatic(); return Boolean.valueOf((!_isStatic)); }; Iterable<? extends FieldDeclaration> _filter = IterableExtensions.filter(clazz.getDeclaredFields(), _function); Iterables.<FieldDeclaration>addAll(targetFields, _filter); typeRef = clazz.getExtendedClass(); } } return targetFields; }
Example #2
Source File: DeclarationsTest.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Test public void testAnnotation2() { StringConcatenation _builder = new StringConcatenation(); _builder.append("class MyClass {"); _builder.newLine(); _builder.append("\t"); _builder.append("@com.google.inject.Inject() MyClass foo"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> { TypeDeclaration _head = IterableExtensions.head(it.getSourceTypeDeclarations()); final ClassDeclaration sourceClazz = ((ClassDeclaration) _head); final MutableClassDeclaration javaClass = it.getTypeLookup().findClass("MyClass"); Assert.assertEquals(javaClass.getQualifiedName(), sourceClazz.getQualifiedName()); final FieldDeclaration field = IterableExtensions.head(sourceClazz.getDeclaredFields()); Assert.assertEquals(Boolean.FALSE, IterableExtensions.head(field.getAnnotations()).getValue("optional")); final MutableFieldDeclaration javaField = IterableExtensions.head(javaClass.getDeclaredFields()); Object _value = IterableExtensions.head(javaField.getAnnotations()).getValue("optional"); Assert.assertFalse((((Boolean) _value)).booleanValue()); }; this.asCompilationUnit(this.validFile(_builder), _function); }
Example #3
Source File: ExternalizedProcessor.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@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); } } }
Example #4
Source File: AccessorsProcessor.java From xtext-lib with Eclipse Public License 2.0 | 6 votes |
public List<String> getPossibleGetterNames(final FieldDeclaration it) { final ArrayList<String> names = CollectionLiterals.<String>newArrayList(); if ((((this.isBooleanType(this.orObject(it.getType())) && it.getSimpleName().startsWith("is")) && (it.getSimpleName().length() > 2)) && Character.isUpperCase(it.getSimpleName().charAt(2)))) { String _simpleName = it.getSimpleName(); names.add(_simpleName); } List<String> _xifexpression = null; boolean _isBooleanType = this.isBooleanType(this.orObject(it.getType())); if (_isBooleanType) { _xifexpression = Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("is", "get")); } else { _xifexpression = Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("get")); } final Function1<String, String> _function = (String prefix) -> { String _firstUpper = StringExtensions.toFirstUpper(it.getSimpleName()); return (prefix + _firstUpper); }; names.addAll(ListExtensions.<String, String>map(_xifexpression, _function)); return names; }
Example #5
Source File: DeclarationsTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testSimpleClassWithField() { StringConcatenation _builder = new StringConcatenation(); _builder.append("package foo"); _builder.newLine(); _builder.newLine(); _builder.append("class MyClass extends Object implements java.io.Serializable {"); _builder.newLine(); _builder.append("\t"); _builder.append("MyClass foo"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> { Assert.assertEquals("foo", it.getPackageName()); TypeDeclaration _head = IterableExtensions.head(it.getSourceTypeDeclarations()); final ClassDeclaration clazz = ((ClassDeclaration) _head); Assert.assertEquals("foo.MyClass", clazz.getQualifiedName()); Assert.assertEquals("Object", clazz.getExtendedClass().toString()); Assert.assertEquals("Serializable", IterableExtensions.head(clazz.getImplementedInterfaces()).toString()); MemberDeclaration _head_1 = IterableExtensions.head(clazz.getDeclaredMembers()); final FieldDeclaration field = ((FieldDeclaration) _head_1); Assert.assertEquals("foo", field.getSimpleName()); Assert.assertSame(it.getTypeLookup().findClass("foo.MyClass"), field.getType().getType()); }; this.asCompilationUnit(this.validFile(_builder), _function); }
Example #6
Source File: DelegateProcessor.java From xtext-lib with Eclipse Public License 2.0 | 5 votes |
protected CharSequence _delegateAccess(final FieldDeclaration it, final MethodDeclaration method) { StringConcatenation _builder = new StringConcatenation(); _builder.append("this."); String _simpleName = it.getSimpleName(); _builder.append(_simpleName); return _builder; }
Example #7
Source File: JvmClassDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public FieldDeclaration findDeclaredField(final String name) { final Function1<FieldDeclaration, Boolean> _function = (FieldDeclaration it) -> { String _simpleName = it.getSimpleName(); return Boolean.valueOf(Objects.equal(_simpleName, name)); }; return IterableExtensions.<FieldDeclaration>findFirst(Iterables.<FieldDeclaration>filter(this.getDeclaredMembers(), FieldDeclaration.class), _function); }
Example #8
Source File: DelegateProcessor.java From xtext-lib with Eclipse Public License 2.0 | 5 votes |
public boolean isValidDelegate(final MemberDeclaration it) { if (it instanceof MethodDeclaration) { return _isValidDelegate((MethodDeclaration)it); } else if (it instanceof FieldDeclaration) { return _isValidDelegate((FieldDeclaration)it); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it).toString()); } }
Example #9
Source File: DelegateProcessor.java From xtext-lib with Eclipse Public License 2.0 | 5 votes |
public TypeReference getType(final MemberDeclaration it) { if (it instanceof MethodDeclaration) { return _getType((MethodDeclaration)it); } else if (it instanceof FieldDeclaration) { return _getType((FieldDeclaration)it); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it).toString()); } }
Example #10
Source File: JvmTypeDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public FieldDeclaration findDeclaredField(final String name) { final Function1<FieldDeclaration, Boolean> _function = (FieldDeclaration field) -> { String _simpleName = field.getSimpleName(); return Boolean.valueOf(Objects.equal(_simpleName, name)); }; return IterableExtensions.findFirst(this.getDeclaredFields(), _function); }
Example #11
Source File: DelegateProcessor.java From xtext-lib with Eclipse Public License 2.0 | 5 votes |
public CharSequence delegateAccess(final MemberDeclaration it, final MethodDeclaration method) { if (it instanceof MethodDeclaration) { return _delegateAccess((MethodDeclaration)it, method); } else if (it instanceof FieldDeclaration) { return _delegateAccess((FieldDeclaration)it, method); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it, method).toString()); } }
Example #12
Source File: AccessorsProcessor.java From xtext-lib with Eclipse Public License 2.0 | 5 votes |
public boolean hasGetter(final FieldDeclaration it) { final Function1<String, Boolean> _function = (String name) -> { MethodDeclaration _findDeclaredMethod = it.getDeclaringType().findDeclaredMethod(name); return Boolean.valueOf((_findDeclaredMethod != null)); }; return IterableExtensions.<String>exists(this.getPossibleGetterNames(it), _function); }
Example #13
Source File: XtendTypeDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public FieldDeclaration findDeclaredField(final String name) { final Function1<FieldDeclaration, Boolean> _function = (FieldDeclaration field) -> { String _simpleName = field.getSimpleName(); return Boolean.valueOf(Objects.equal(_simpleName, name)); }; return IterableExtensions.findFirst(this.getDeclaredFields(), _function); }
Example #14
Source File: ExternalizedProcessor.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public String getInitializerAsString(final FieldDeclaration f) { Expression _initializer = f.getInitializer(); String _string = null; if (_initializer!=null) { _string=_initializer.toString(); } final String string = _string; if ((string == null)) { return "empty string"; } int _length = string.length(); int _minus = (_length - 1); return string.substring(1, _minus); }
Example #15
Source File: DeclarationsTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Test public void testAnnotation() { StringConcatenation _builder = new StringConcatenation(); _builder.append("@SuppressWarnings(\"unused\")"); _builder.newLine(); _builder.append("class MyClass {"); _builder.newLine(); _builder.append("\t"); _builder.append("@com.google.inject.Inject(optional=true) MyClass foo"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> { Assert.assertNull(it.getPackageName()); TypeDeclaration _head = IterableExtensions.head(it.getSourceTypeDeclarations()); final ClassDeclaration clazz = ((ClassDeclaration) _head); Assert.assertEquals("MyClass", clazz.getQualifiedName()); final AnnotationReference suppressWarning = IterableExtensions.head(clazz.getAnnotations()); final AnnotationTypeDeclaration supressWarningsDeclaration = suppressWarning.getAnnotationTypeDeclaration(); Assert.assertEquals("java.lang.SuppressWarnings", supressWarningsDeclaration.getQualifiedName()); Assert.assertEquals("unused", suppressWarning.getStringArrayValue("value")[0]); Assert.assertEquals(2, IterableExtensions.size(supressWarningsDeclaration.getAnnotations())); final AnnotationTypeElementDeclaration valueProperty = IterableExtensions.<AnnotationTypeElementDeclaration>head(Iterables.<AnnotationTypeElementDeclaration>filter(supressWarningsDeclaration.getDeclaredMembers(), AnnotationTypeElementDeclaration.class)); Assert.assertEquals("String[]", valueProperty.getType().toString()); Assert.assertEquals("value", valueProperty.getSimpleName()); MemberDeclaration _head_1 = IterableExtensions.head(clazz.getDeclaredMembers()); final FieldDeclaration field = ((FieldDeclaration) _head_1); final AnnotationReference inject = IterableExtensions.head(field.getAnnotations()); Object _value = inject.getValue("optional"); Assert.assertTrue((((Boolean) _value)).booleanValue()); }; this.asCompilationUnit(this.validFile(_builder), _function); }
Example #16
Source File: DeclarationsTest.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Test public void testXtendClassWithMethodFieldAndConstructor() { StringConcatenation _builder = new StringConcatenation(); _builder.append("package foo"); _builder.newLine(); _builder.newLine(); _builder.append("class MyClass<T extends CharSequence> {"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("String myField"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("new(String initial) {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("this.myField = initial"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("\t"); _builder.newLine(); _builder.append("\t"); _builder.append("def <T2 extends CharSequence> MyClass myMethod(T2 a, T b) {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("myField = myField + a + b"); _builder.newLine(); _builder.append("\t\t"); _builder.append("return this"); _builder.newLine(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final Procedure1<CompilationUnitImpl> _function = (CompilationUnitImpl it) -> { Assert.assertEquals("foo", it.getPackageName()); TypeDeclaration _head = IterableExtensions.head(it.getSourceTypeDeclarations()); final ClassDeclaration clazz = ((ClassDeclaration) _head); final MutableClassDeclaration genClazz = it.getTypeLookup().findClass("foo.MyClass"); Assert.assertEquals("foo.MyClass", clazz.getQualifiedName()); Assert.assertNull(clazz.getExtendedClass()); Assert.assertTrue(IterableExtensions.isEmpty(clazz.getImplementedInterfaces())); Assert.assertEquals(3, IterableExtensions.size(clazz.getDeclaredMembers())); Assert.assertEquals("T", IterableExtensions.head(clazz.getTypeParameters()).getSimpleName()); Assert.assertEquals("CharSequence", IterableExtensions.head(IterableExtensions.head(clazz.getTypeParameters()).getUpperBounds()).toString()); Assert.assertSame(clazz, IterableExtensions.head(clazz.getTypeParameters()).getTypeParameterDeclarator()); final FieldDeclaration field = IterableExtensions.head(clazz.getDeclaredFields()); Assert.assertSame(clazz, field.getDeclaringType()); Assert.assertEquals("myField", field.getSimpleName()); Assert.assertEquals("String", field.getType().toString()); Assert.assertFalse(field.isFinal()); final ConstructorDeclaration constructor = IterableExtensions.head(clazz.getDeclaredConstructors()); Assert.assertSame(clazz, constructor.getDeclaringType()); Assert.assertEquals("MyClass", constructor.getSimpleName()); Assert.assertEquals("initial", IterableExtensions.head(constructor.getParameters()).getSimpleName()); Assert.assertEquals("String", IterableExtensions.head(constructor.getParameters()).getType().toString()); final MethodDeclaration method = IterableExtensions.head(clazz.getDeclaredMethods()); final MutableMethodDeclaration genMethod = IterableExtensions.head(genClazz.getDeclaredMethods()); Assert.assertSame(clazz, method.getDeclaringType()); Assert.assertEquals("a", IterableExtensions.head(method.getParameters()).getSimpleName()); Assert.assertEquals("T2", IterableExtensions.head(method.getParameters()).getType().toString()); Assert.assertSame(IterableExtensions.head(genMethod.getTypeParameters()), IterableExtensions.head(method.getParameters()).getType().getType()); Assert.assertEquals("T", (((ParameterDeclaration[])Conversions.unwrapArray(method.getParameters(), ParameterDeclaration.class))[1]).getType().toString()); Assert.assertSame(IterableExtensions.head(genClazz.getTypeParameters()), (((ParameterDeclaration[])Conversions.unwrapArray(method.getParameters(), ParameterDeclaration.class))[1]).getType().getType()); Assert.assertSame(genClazz, method.getReturnType().getType()); Assert.assertEquals("T2", IterableExtensions.head(method.getTypeParameters()).getSimpleName()); Assert.assertEquals("CharSequence", IterableExtensions.head(IterableExtensions.head(method.getTypeParameters()).getUpperBounds()).toString()); Assert.assertSame(IterableExtensions.head(method.getTypeParameters()), IterableExtensions.head(method.getTypeParameters())); Assert.assertSame(method, IterableExtensions.head(method.getTypeParameters()).getTypeParameterDeclarator()); Assert.assertSame(field, ((Object[])Conversions.unwrapArray(clazz.getDeclaredMembers(), Object.class))[0]); Assert.assertSame(constructor, ((Object[])Conversions.unwrapArray(clazz.getDeclaredMembers(), Object.class))[1]); Assert.assertSame(method, ((Object[])Conversions.unwrapArray(clazz.getDeclaredMembers(), Object.class))[2]); }; this.asCompilationUnit(this.validFile(_builder), _function); }
Example #17
Source File: MutableJvmClassDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public MutableFieldDeclaration findDeclaredField(final String name) { FieldDeclaration _findDeclaredField = super.findDeclaredField(name); return ((MutableFieldDeclaration) _findDeclaredField); }
Example #18
Source File: MutableJvmAnnotationTypeDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public MutableFieldDeclaration findDeclaredField(final String name) { FieldDeclaration _findDeclaredField = super.findDeclaredField(name); return ((MutableFieldDeclaration) _findDeclaredField); }
Example #19
Source File: MutableJvmAnnotationTypeDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public Iterable<? extends MutableFieldDeclaration> getDeclaredFields() { Iterable<? extends FieldDeclaration> _declaredFields = super.getDeclaredFields(); return ((Iterable<? extends MutableFieldDeclaration>) _declaredFields); }
Example #20
Source File: ToStringProcessor.java From xtext-lib with Eclipse Public License 2.0 | 4 votes |
public void addToString(final MutableClassDeclaration cls, final Iterable<? extends FieldDeclaration> fields, final ToStringConfiguration config) { final Procedure1<MutableMethodDeclaration> _function = (MutableMethodDeclaration it) -> { this.context.setPrimarySourceElement(it, this.context.getPrimarySourceElement(cls)); it.setReturnType(this.context.getString()); it.addAnnotation(this.context.newAnnotationReference(Override.class)); it.addAnnotation(this.context.newAnnotationReference(Pure.class)); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append(ToStringBuilder.class); _builder.append(" b = new "); _builder.append(ToStringBuilder.class); _builder.append("(this);"); _builder.newLineIfNotEmpty(); { boolean _isSkipNulls = config.isSkipNulls(); if (_isSkipNulls) { _builder.append("b.skipNulls();"); } } _builder.newLineIfNotEmpty(); { boolean _isSingleLine = config.isSingleLine(); if (_isSingleLine) { _builder.append("b.singleLine();"); } } _builder.newLineIfNotEmpty(); { boolean _isHideFieldNames = config.isHideFieldNames(); if (_isHideFieldNames) { _builder.append("b.hideFieldNames();"); } } _builder.newLineIfNotEmpty(); { boolean _isVerbatimValues = config.isVerbatimValues(); if (_isVerbatimValues) { _builder.append("b.verbatimValues();"); } } _builder.newLineIfNotEmpty(); { for(final FieldDeclaration field : fields) { _builder.append("b.add(\""); String _simpleName = field.getSimpleName(); _builder.append(_simpleName); _builder.append("\", this."); String _simpleName_1 = field.getSimpleName(); _builder.append(_simpleName_1); _builder.append(");"); _builder.newLineIfNotEmpty(); } } _builder.append("return b.toString();"); _builder.newLine(); } }; it.setBody(_client); }; cls.addMethod("toString", _function); }
Example #21
Source File: MutableJvmClassDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public Iterable<? extends MutableFieldDeclaration> getDeclaredFields() { Iterable<? extends FieldDeclaration> _declaredFields = super.getDeclaredFields(); return ((Iterable<? extends MutableFieldDeclaration>) _declaredFields); }
Example #22
Source File: JvmTypeDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public Iterable<? extends FieldDeclaration> getDeclaredFields() { return Iterables.<FieldDeclaration>filter(this.getDeclaredMembers(), FieldDeclaration.class); }
Example #23
Source File: MutableJvmEnumerationTypeDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public MutableFieldDeclaration findDeclaredField(final String name) { FieldDeclaration _findDeclaredField = super.findDeclaredField(name); return ((MutableFieldDeclaration) _findDeclaredField); }
Example #24
Source File: MutableJvmEnumerationTypeDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public Iterable<? extends MutableFieldDeclaration> getDeclaredFields() { Iterable<? extends FieldDeclaration> _declaredFields = super.getDeclaredFields(); return ((Iterable<? extends MutableFieldDeclaration>) _declaredFields); }
Example #25
Source File: XtendTypeDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public Iterable<? extends FieldDeclaration> getDeclaredFields() { return Iterables.<FieldDeclaration>filter(this.getDeclaredMembers(), FieldDeclaration.class); }
Example #26
Source File: MutableJvmInterfaceDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public MutableFieldDeclaration findDeclaredField(final String name) { FieldDeclaration _findDeclaredField = super.findDeclaredField(name); return ((MutableFieldDeclaration) _findDeclaredField); }
Example #27
Source File: MutableJvmInterfaceDeclarationImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override public Iterable<? extends MutableFieldDeclaration> getDeclaredFields() { Iterable<? extends FieldDeclaration> _declaredFields = super.getDeclaredFields(); return ((Iterable<? extends MutableFieldDeclaration>) _declaredFields); }
Example #28
Source File: JsonRpcDataProcessor.java From lsp4j with Eclipse Public License 2.0 | 4 votes |
protected MutableMethodDeclaration generateToString(final MutableClassDeclaration impl, @Extension final TransformationContext context) { MutableMethodDeclaration _xblockexpression = null; { final ArrayList<FieldDeclaration> toStringFields = CollectionLiterals.<FieldDeclaration>newArrayList(); ClassDeclaration c = impl; do { { Iterable<? extends FieldDeclaration> _declaredFields = c.getDeclaredFields(); Iterables.<FieldDeclaration>addAll(toStringFields, _declaredFields); TypeReference _extendedClass = c.getExtendedClass(); Type _type = null; if (_extendedClass!=null) { _type=_extendedClass.getType(); } c = ((ClassDeclaration) _type); } } while(((c != null) && (!Objects.equal(c, context.getObject())))); final Procedure1<MutableMethodDeclaration> _function = (MutableMethodDeclaration it) -> { it.setReturnType(context.getString()); it.addAnnotation(context.newAnnotationReference(Override.class)); it.addAnnotation(context.newAnnotationReference(Pure.class)); final AccessorsProcessor.Util accessorsUtil = new AccessorsProcessor.Util(context); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append(ToStringBuilder.class); _builder.append(" b = new "); _builder.append(ToStringBuilder.class); _builder.append("(this);"); _builder.newLineIfNotEmpty(); { for(final FieldDeclaration field : toStringFields) { _builder.append("b.add(\""); String _simpleName = field.getSimpleName(); _builder.append(_simpleName); _builder.append("\", "); { TypeDeclaration _declaringType = field.getDeclaringType(); boolean _equals = Objects.equal(_declaringType, impl); if (_equals) { _builder.append("this."); String _simpleName_1 = field.getSimpleName(); _builder.append(_simpleName_1); } else { String _getterName = accessorsUtil.getGetterName(field); _builder.append(_getterName); _builder.append("()"); } } _builder.append(");"); _builder.newLineIfNotEmpty(); } } _builder.append("return b.toString();"); _builder.newLine(); } }; it.setBody(_client); }; _xblockexpression = impl.addMethod("toString", _function); } return _xblockexpression; }
Example #29
Source File: AbstractFieldProcessor.java From xtext-lib with Eclipse Public License 2.0 | 4 votes |
public void doRegisterGlobals(List<? extends FieldDeclaration> annotatedFields, @Extension RegisterGlobalsContext context) { for (FieldDeclaration annotatedField : annotatedFields) { doRegisterGlobals(annotatedField, context); } }
Example #30
Source File: DelegateProcessor.java From xtext-lib with Eclipse Public License 2.0 | 4 votes |
protected TypeReference _getType(final FieldDeclaration it) { return it.getType(); }