use of org.eclipse.xtext.common.types.JvmAnnotationReference in project xtext-xtend by eclipse.
the class XAnnotationExtensions method isActiveAnnotation.
protected boolean isActiveAnnotation(final JvmAnnotationType annotationType) {
EList<JvmAnnotationReference> _annotations = annotationType.getAnnotations();
for (final JvmAnnotationReference anno : _annotations) {
String _identifier = anno.getAnnotation().getIdentifier();
String _name = Active.class.getName();
boolean _equals = Objects.equal(_identifier, _name);
if (_equals) {
return true;
}
}
return false;
}
use of org.eclipse.xtext.common.types.JvmAnnotationReference in project xtext-xtend by eclipse.
the class AnnotationReferenceProviderImpl method newAnnotationReference.
@Override
public AnnotationReference newAnnotationReference(final String annotationTypeName, final Procedure1<AnnotationReferenceBuildContext> initializer) {
AnnotationReference _xblockexpression = null;
{
this.compilationUnit.checkCanceled();
StringConcatenation _builder = new StringConcatenation();
_builder.append("annotationTypeName cannot be null");
Preconditions.checkArgument((annotationTypeName != null), _builder);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("initializer cannot be null");
Preconditions.checkArgument((initializer != null), _builder_1);
final JvmAnnotationReference jvmAnnotationReference = this.createJvmAnnotationReference(this.compilationUnit.getTypeReferences().findDeclaredType(annotationTypeName, this.compilationUnit.getXtendFile()));
if ((jvmAnnotationReference == null)) {
return null;
}
AnnotationReferenceBuildContextImpl _annotationReferenceBuildContextImpl = new AnnotationReferenceBuildContextImpl();
final Procedure1<AnnotationReferenceBuildContextImpl> _function = (AnnotationReferenceBuildContextImpl it) -> {
it.setDelegate(jvmAnnotationReference);
it.setCompilationUnit(this.compilationUnit);
};
final AnnotationReferenceBuildContextImpl buildContext = ObjectExtensions.<AnnotationReferenceBuildContextImpl>operator_doubleArrow(_annotationReferenceBuildContextImpl, _function);
initializer.apply(buildContext);
_xblockexpression = this.compilationUnit.toAnnotationReference(jvmAnnotationReference);
}
return _xblockexpression;
}
use of org.eclipse.xtext.common.types.JvmAnnotationReference in project xtext-xtend by eclipse.
the class AnnotationReferenceProviderImpl method newAnnotationReference.
@Override
public AnnotationReference newAnnotationReference(final Type annotationTypeDelcaration, final Procedure1<AnnotationReferenceBuildContext> initializer) {
Object _xblockexpression = null;
{
this.compilationUnit.checkCanceled();
StringConcatenation _builder = new StringConcatenation();
_builder.append("annotationTypeDelcaration cannot be null");
Preconditions.checkArgument((annotationTypeDelcaration != null), _builder);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("initializer cannot be null");
Preconditions.checkArgument((initializer != null), _builder_1);
JvmDeclaredType _switchResult = null;
boolean _matched = false;
if (annotationTypeDelcaration instanceof JvmAnnotationTypeDeclarationImpl) {
_matched = true;
_switchResult = ((JvmAnnotationTypeDeclarationImpl) annotationTypeDelcaration).getDelegate();
}
if (!_matched) {
if (annotationTypeDelcaration instanceof XtendAnnotationTypeDeclarationImpl) {
_matched = true;
_switchResult = this.compilationUnit.getJvmModelAssociations().getInferredType(((XtendAnnotationTypeDeclarationImpl) annotationTypeDelcaration).getDelegate());
}
}
if (!_matched) {
throw new IllegalArgumentException(("couldn\'t construct type reference for type " + annotationTypeDelcaration));
}
final JvmDeclaredType type = _switchResult;
if ((type instanceof JvmAnnotationType)) {
final JvmAnnotationReference newJvmAnnotationReference = this.createJvmAnnotationReference(type);
AnnotationReferenceBuildContextImpl _annotationReferenceBuildContextImpl = new AnnotationReferenceBuildContextImpl();
final Procedure1<AnnotationReferenceBuildContextImpl> _function = (AnnotationReferenceBuildContextImpl it) -> {
it.setDelegate(newJvmAnnotationReference);
it.setCompilationUnit(this.compilationUnit);
};
final AnnotationReferenceBuildContextImpl buildContext = ObjectExtensions.<AnnotationReferenceBuildContextImpl>operator_doubleArrow(_annotationReferenceBuildContextImpl, _function);
initializer.apply(buildContext);
return this.compilationUnit.toAnnotationReference(newJvmAnnotationReference);
}
_xblockexpression = null;
}
return ((AnnotationReference) _xblockexpression);
}
use of org.eclipse.xtext.common.types.JvmAnnotationReference in project xtext-xtend by eclipse.
the class AnnotationReferenceProviderImpl method newAnnotationReference.
@Override
public AnnotationReference newAnnotationReference(final AnnotationReference annotationReference, final Procedure1<AnnotationReferenceBuildContext> initializer) {
Object _xblockexpression = null;
{
this.compilationUnit.checkCanceled();
StringConcatenation _builder = new StringConcatenation();
_builder.append("annotationReference cannot be null");
Preconditions.checkArgument((annotationReference != null), _builder);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("initializer cannot be null");
Preconditions.checkArgument((initializer != null), _builder_1);
if ((annotationReference instanceof JvmAnnotationReferenceImpl)) {
final JvmAnnotationReference baseJvmAnnotationReference = ((JvmAnnotationReferenceImpl) annotationReference).getDelegate();
ConditionUtils.notRemoved(baseJvmAnnotationReference, "annotationReference");
final JvmAnnotationReference newJvmAnnotationReference = this.createJvmAnnotationReference(baseJvmAnnotationReference.getAnnotation());
AnnotationReferenceBuildContextImpl _annotationReferenceBuildContextImpl = new AnnotationReferenceBuildContextImpl();
final Procedure1<AnnotationReferenceBuildContextImpl> _function = (AnnotationReferenceBuildContextImpl it) -> {
it.setDelegate(newJvmAnnotationReference);
it.setCompilationUnit(this.compilationUnit);
};
final AnnotationReferenceBuildContextImpl buildContext = ObjectExtensions.<AnnotationReferenceBuildContextImpl>operator_doubleArrow(_annotationReferenceBuildContextImpl, _function);
final Function1<JvmAnnotationValue, String> _function_1 = (JvmAnnotationValue it) -> {
String _elvis = null;
String _valueName = it.getValueName();
if (_valueName != null) {
_elvis = _valueName;
} else {
_elvis = "value";
}
return _elvis;
};
List<String> _map = ListExtensions.<JvmAnnotationValue, String>map(baseJvmAnnotationReference.getExplicitValues(), _function_1);
for (final String valueName : _map) {
{
final Object value = ((JvmAnnotationReferenceImpl) annotationReference).getValue(valueName);
buildContext.set(valueName, value);
}
}
initializer.apply(buildContext);
return this.compilationUnit.toAnnotationReference(newJvmAnnotationReference);
}
_xblockexpression = null;
}
return ((AnnotationReference) _xblockexpression);
}
use of org.eclipse.xtext.common.types.JvmAnnotationReference in project xtext-xtend by eclipse.
the class JvmAnnotationTargetImpl method addAnnotation.
public AnnotationReference addAnnotation(final AnnotationReference annotationReference) {
AnnotationReference _xblockexpression = null;
{
this.checkMutable();
Preconditions.checkArgument((annotationReference != null), "annotationReference cannot be null");
AnnotationReference _xifexpression = null;
if ((annotationReference instanceof JvmAnnotationReferenceImpl)) {
AnnotationReference _xblockexpression_1 = null;
{
final JvmAnnotationReference jvmAnnotationReference = EcoreUtil2.<JvmAnnotationReference>cloneWithProxies(((JvmAnnotationReferenceImpl) annotationReference).getDelegate());
EList<JvmAnnotationReference> _annotations = this.getDelegate().getAnnotations();
_annotations.add(jvmAnnotationReference);
_xblockexpression_1 = this.getCompilationUnit().toAnnotationReference(jvmAnnotationReference);
}
_xifexpression = _xblockexpression_1;
} else {
StringConcatenation _builder = new StringConcatenation();
_builder.append(annotationReference);
_builder.append(" is not annotation reference");
throw new IllegalArgumentException(_builder.toString());
}
_xblockexpression = _xifexpression;
}
return _xblockexpression;
}
Aggregations