use of org.eclipse.xtext.xbase.lib.Extension in project xtext-eclipse by eclipse.
the class AbstractHierarchyBuilderTest method testBuildHierarchy.
protected void testBuildHierarchy(final Procedure1<? super AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration> configurator) {
@Extension final AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration configuration = new AbstractHierarchyBuilderTest.HierarchyBuilderTestConfiguration();
configurator.apply(configuration);
final ResourceSet resourceSet = this.createResourceSet(configuration);
final IHierarchyBuilder hierarchyBuilder = configuration.hierarchyBuilderProvider.apply(resourceSet);
String _xifexpression = null;
if ((configuration.resourceURI == null)) {
_xifexpression = IterableExtensions.<Pair<String, String>>last(configuration.models).getKey();
} else {
_xifexpression = configuration.resourceURI;
}
final String resourceURI = _xifexpression;
Resource _resource = resourceSet.getResource(URI.createURI(resourceURI), false);
final XtextResource resource = ((XtextResource) _resource);
final URI rootURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(this._eObjectAtOffsetHelper.resolveElementAt(resource, configuration.index));
final String actualHierarchy = this.toExpectation(rootURI, hierarchyBuilder);
Assert.assertEquals(configuration.expectedHierarchy, actualHierarchy);
}
use of org.eclipse.xtext.xbase.lib.Extension in project xtext-lib by eclipse.
the class AccessorsProcessor method _transform.
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;
}
@Extension final FinalFieldsConstructorProcessor.Util requiredArgsUtil = new FinalFieldsConstructorProcessor.Util(context);
if ((requiredArgsUtil.needsFinalFieldConstructor(it) || (it.findAnnotation(context.findTypeGlobally(FinalFieldsConstructor.class)) != null))) {
requiredArgsUtil.addFinalFieldsConstructor(it);
}
final Function1<MutableFieldDeclaration, Boolean> _function = (MutableFieldDeclaration it_1) -> {
return Boolean.valueOf(((!it_1.isStatic()) && context.isThePrimaryGeneratedJavaElement(it_1)));
};
final Consumer<MutableFieldDeclaration> _function_1 = (MutableFieldDeclaration it_1) -> {
this._transform(it_1, context);
};
IterableExtensions.filter(it.getDeclaredFields(), _function).forEach(_function_1);
}
use of org.eclipse.xtext.xbase.lib.Extension in project xtext-lib by eclipse.
the class ToStringProcessor method doTransform.
@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);
}
}
}
use of org.eclipse.xtext.xbase.lib.Extension in project xtext-lib by eclipse.
the class FinalFieldsConstructorProcessor method _transform.
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);
}
Aggregations