Java Code Examples for org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration#findAnnotation()
The following examples show how to use
org.eclipse.xtend.lib.macro.declaration.MutableClassDeclaration#findAnnotation() .
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: FinalFieldsConstructorProcessor.java From xtext-lib with Eclipse Public License 2.0 | 6 votes |
public void addFinalFieldsConstructor(final MutableClassDeclaration it) { boolean _isEmpty = this.getFinalFieldsConstructorArgumentTypes(it).isEmpty(); if (_isEmpty) { final AnnotationReference anno = it.findAnnotation(this.context.findTypeGlobally(FinalFieldsConstructor.class)); StringConcatenation _builder = new StringConcatenation(); _builder.append("There are no final fields, this annotation has no effect"); this.context.addWarning(anno, _builder.toString()); return; } boolean _hasFinalFieldsConstructor = this.hasFinalFieldsConstructor(it); if (_hasFinalFieldsConstructor) { this.context.addError(it, this.getConstructorAlreadyExistsMessage(it)); return; } final Procedure1<MutableConstructorDeclaration> _function = (MutableConstructorDeclaration it_1) -> { this.context.setPrimarySourceElement(it_1, this.context.getPrimarySourceElement(it_1.getDeclaringType())); this.makeFinalFieldsConstructor(it_1); }; it.addConstructor(_function); }
Example 2
Source File: EqualsHashCodeProcessor.java From xtext-lib with Eclipse Public License 2.0 | 5 votes |
@Override public void doTransform(final MutableClassDeclaration it, @Extension final TransformationContext context) { AnnotationReference _findAnnotation = it.findAnnotation(context.findTypeGlobally(Data.class)); boolean _tripleNotEquals = (_findAnnotation != null); if (_tripleNotEquals) { return; } @Extension final EqualsHashCodeProcessor.Util util = new EqualsHashCodeProcessor.Util(context); boolean _hasEquals = util.hasEquals(it); if (_hasEquals) { final AnnotationReference annotation = it.findAnnotation(context.findTypeGlobally(EqualsHashCode.class)); context.addWarning(annotation, "equals is already defined, this annotation has no effect"); } else { boolean _hasHashCode = util.hasHashCode(it); if (_hasHashCode) { context.addWarning(it, "hashCode is already defined, this annotation has no effect"); } else { final Function1<MutableFieldDeclaration, Boolean> _function = (MutableFieldDeclaration it_1) -> { return Boolean.valueOf((((!it_1.isStatic()) && (!it_1.isTransient())) && context.isThePrimaryGeneratedJavaElement(it_1))); }; final Iterable<? extends MutableFieldDeclaration> fields = IterableExtensions.filter(it.getDeclaredFields(), _function); util.addEquals(it, fields, util.hasSuperEquals(it)); util.addHashCode(it, fields, util.hasSuperHashCode(it)); } } }
Example 3
Source File: FinalFieldsConstructorProcessor.java From xtext-lib with Eclipse Public License 2.0 | 5 votes |
protected void _transform(final MutableClassDeclaration it, @Extension final TransformationContext context) { AnnotationReference _findAnnotation = it.findAnnotation(context.findTypeGlobally(Data.class)); boolean _tripleNotEquals = (_findAnnotation != null); if (_tripleNotEquals) { return; } AnnotationReference _findAnnotation_1 = it.findAnnotation(context.findTypeGlobally(Accessors.class)); boolean _tripleNotEquals_1 = (_findAnnotation_1 != null); if (_tripleNotEquals_1) { return; } @Extension final FinalFieldsConstructorProcessor.Util util = new FinalFieldsConstructorProcessor.Util(context); util.addFinalFieldsConstructor(it); }
Example 4
Source File: ToStringProcessor.java From xtext-lib with Eclipse Public License 2.0 | 5 votes |
@Override public void doTransform(final MutableClassDeclaration it, @Extension final TransformationContext context) { AnnotationReference _findAnnotation = it.findAnnotation(context.findTypeGlobally(Data.class)); boolean _tripleNotEquals = (_findAnnotation != null); if (_tripleNotEquals) { return; } @Extension final ToStringProcessor.Util util = new ToStringProcessor.Util(context); final AnnotationReference annotation = it.findAnnotation(context.findTypeGlobally(ToString.class)); final ToStringConfiguration configuration = new ToStringConfiguration(annotation); boolean _hasToString = util.hasToString(it); if (_hasToString) { context.addWarning(annotation, "toString is already defined, this annotation has no effect."); } else { TypeReference _extendedClass = it.getExtendedClass(); TypeReference _object = context.getObject(); boolean _notEquals = (!Objects.equal(_extendedClass, _object)); if (_notEquals) { util.addReflectiveToString(it, configuration); } else { final Function1<MutableFieldDeclaration, Boolean> _function = (MutableFieldDeclaration it_1) -> { return Boolean.valueOf(((context.isThePrimaryGeneratedJavaElement(it_1) && (!it_1.isStatic())) && (!it_1.isTransient()))); }; util.addToString(it, IterableExtensions.filter(it.getDeclaredFields(), _function), configuration); } } }
Example 5
Source File: TypeAdapterImplProcessor.java From lsp4j with Eclipse Public License 2.0 | 5 votes |
@Override public void doTransform(final MutableClassDeclaration annotatedClass, @Extension final TransformationContext context) { final AnnotationReference typeAdapterImplAnnotation = annotatedClass.findAnnotation(context.findTypeGlobally(TypeAdapterImpl.class)); final TypeReference targetType = typeAdapterImplAnnotation.getClassValue("value"); this.generateImpl(annotatedClass, targetType, context); String _qualifiedName = annotatedClass.getQualifiedName(); String _plus = (_qualifiedName + ".Factory"); this.generateFactory(context.findClass(_plus), annotatedClass, targetType, context); }