org.eclipse.xtext.common.types.JvmBooleanAnnotationValue Java Examples
The following examples show how to use
org.eclipse.xtext.common.types.JvmBooleanAnnotationValue.
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: JdtBasedTypeFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
private JvmAnnotationValue createBooleanAnnotationValue(Object value) { JvmBooleanAnnotationValue annotationValue = TypesFactory.eINSTANCE.createJvmBooleanAnnotationValue(); if (value != null) { @SuppressWarnings("unchecked") InternalEList<Object> values = (InternalEList<Object>)(InternalEList<?>)annotationValue.getValues(); if (value instanceof Object[]) { for (Object element : (Object[])value) { if (element instanceof Boolean) { values.addUnique(element); } } } else { values.addUnique(value); } } return annotationValue; }
Example #2
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testBooleanAnnotationValue_03() throws Exception { JvmBooleanAnnotationValue value = (JvmBooleanAnnotationValue) getConstructorParameterAnnotationValue( "booleanValue"); assertEquals(1, value.getValues().size()); assertFalse(value.getValues().get(0)); }
Example #3
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testDefaultBooleanAnnotationValue_01() throws Exception { JvmBooleanAnnotationValue value = (JvmBooleanAnnotationValue) getDefaultAnnotationValue("booleanValue"); assertEquals(1, value.getValues().size()); Boolean b = value.getValues().get(0); assertEquals(true, b.booleanValue()); }
Example #4
Source File: FeatureCallCompiler.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
private static boolean isConstantExpression(JvmAnnotationReference reference) { for (final JvmAnnotationValue annotationValue: reference.getValues()) { if ("constantExpression".equals(annotationValue.getValueName())) { if (annotationValue instanceof JvmBooleanAnnotationValue) { return ((JvmBooleanAnnotationValue) annotationValue).getValues().get(0).booleanValue(); } else if (annotationValue instanceof JvmCustomAnnotationValue) { final EObject value = ((JvmCustomAnnotationValue) annotationValue).getValues().get(0); if (value instanceof XBooleanLiteral) { return ((XBooleanLiteral) value).isIsTrue(); } } } } return false; }
Example #5
Source File: JvmBooleanAnnotationValueItemProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * This handles model notifications by calling {@link #updateChildren} to update any cached * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void notifyChanged(Notification notification) { updateChildren(notification); switch (notification.getFeatureID(JvmBooleanAnnotationValue.class)) { case TypesPackage.JVM_BOOLEAN_ANNOTATION_VALUE__VALUES: fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); return; } super.notifyChanged(notification); }
Example #6
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testBooleanAnnotationValue_03() throws Exception { JvmBooleanAnnotationValue value = (JvmBooleanAnnotationValue) getConstructorParameterAnnotationValue( "booleanValue"); assertEquals(1, value.getValues().size()); assertFalse(value.getValues().get(0)); }
Example #7
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testDefaultBooleanAnnotationValue_01() throws Exception { JvmBooleanAnnotationValue value = (JvmBooleanAnnotationValue) getDefaultAnnotationValue("booleanValue"); assertEquals(1, value.getValues().size()); Boolean b = value.getValues().get(0); assertEquals(true, b.booleanValue()); }
Example #8
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testDefaultBooleanAnnotationValue_01() throws Exception { JvmBooleanAnnotationValue value = (JvmBooleanAnnotationValue) getDefaultAnnotationValue("booleanValue"); assertEquals(1, value.getValues().size()); Boolean b = value.getValues().get(0); assertEquals(true, b.booleanValue()); }
Example #9
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Test public void testBooleanAnnotationValue_03() throws Exception { JvmBooleanAnnotationValue value = (JvmBooleanAnnotationValue) getConstructorParameterAnnotationValue( "booleanValue"); assertEquals(1, value.getValues().size()); assertFalse(value.getValues().get(0)); }
Example #10
Source File: JavaInlineExpressionCompiler.java From sarl with Apache License 2.0 | 4 votes |
/** Append the inline annotation to the given operation. * * @param target the target of the annotation. * @param resourceSet the resource set that is associated to the given operation. * @param inlineExpression the inline expression. * @param isConstantExpression indicates if the expression is a constant. * @param isStatementExpression indicates if the expression is a statement. * @param types the types to import if the inline expression is used. The references are cloned by this function. */ protected void appendInlineAnnotation(JvmAnnotationTarget target, ResourceSet resourceSet, String inlineExpression, boolean isConstantExpression, boolean isStatementExpression, JvmTypeReference... types) { final JvmAnnotationReferenceBuilder annotationTypesBuilder = this.annotationRefBuilderFactory.create( resourceSet); final JvmAnnotationReference annotationReference = annotationTypesBuilder.annotationRef( Inline.class); final AnnotationInformation annotationInfo = new AnnotationInformation(annotationReference); // Value final JvmStringAnnotationValue annotationValue = this.services.getTypesFactory() .createJvmStringAnnotationValue(); annotationValue.getValues().add(inlineExpression); annotationValue.setOperation(annotationInfo.valueOperation); annotationReference.getExplicitValues().add(annotationValue); // Imported for (final JvmTypeReference type : types) { final JvmTypeAnnotationValue annotationImportedType = this.services.getTypesFactory() .createJvmTypeAnnotationValue(); annotationImportedType.getValues().add(this.typeBuilder.cloneWithProxies(type)); annotationImportedType.setOperation(annotationInfo.importedOperation); annotationReference.getExplicitValues().add(annotationImportedType); } // Constant if (isConstantExpression) { final JvmBooleanAnnotationValue annotationConstant = this.services.getTypesFactory() .createJvmBooleanAnnotationValue(); annotationConstant.getValues().add(Boolean.valueOf(isConstantExpression)); annotationConstant.setOperation(annotationInfo.constantExpressionOperation); annotationReference.getExplicitValues().add(annotationConstant); } // Statement if (isStatementExpression) { final JvmBooleanAnnotationValue annotationStatement = this.services.getTypesFactory() .createJvmBooleanAnnotationValue(); annotationStatement.getValues().add(Boolean.valueOf(isStatementExpression)); annotationStatement.setOperation(annotationInfo.statementExpressionOperation); annotationReference.getExplicitValues().add(annotationStatement); } target.getAnnotations().add(annotationReference); }
Example #11
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Test public void testBooleanAnnotationValue_01() throws Exception { JvmBooleanAnnotationValue value = (JvmBooleanAnnotationValue) getAnnotationValue("booleanValue"); assertEquals(1, value.getValues().size()); assertFalse(value.getValues().get(0)); }
Example #12
Source File: SarlCompiler.java From sarl with Apache License 2.0 | 4 votes |
@SuppressWarnings({"checkstyle:returncount", "checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity"}) private static String getAnnotationStringValue(JvmAnnotationValue value) { if (value instanceof JvmAnnotationAnnotationValue) { return ((JvmAnnotationAnnotationValue) value).getValues().get(0).getAnnotation().getIdentifier(); } if (value instanceof JvmBooleanAnnotationValue) { return ((JvmBooleanAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmByteAnnotationValue) { return ((JvmByteAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmCharAnnotationValue) { return ((JvmCharAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmCustomAnnotationValue) { final EObject evalue = ((JvmCustomAnnotationValue) value).getValues().get(0); if (evalue instanceof XStringLiteral) { return ((XStringLiteral) evalue).getValue(); } if (evalue instanceof XNumberLiteral) { return ((XNumberLiteral) evalue).getValue(); } if (evalue instanceof XBooleanLiteral) { return ((XNumberLiteral) evalue).getValue(); } if (evalue instanceof XTypeLiteral) { return ((XTypeLiteral) evalue).getType().getIdentifier(); } } if (value instanceof JvmDoubleAnnotationValue) { return ((JvmDoubleAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmEnumAnnotationValue) { return ((JvmEnumAnnotationValue) value).getValues().get(0).getSimpleName(); } if (value instanceof JvmFloatAnnotationValue) { return ((JvmFloatAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmIntAnnotationValue) { return ((JvmIntAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmLongAnnotationValue) { return ((JvmLongAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmShortAnnotationValue) { return ((JvmShortAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmStringAnnotationValue) { return ((JvmStringAnnotationValue) value).getValues().get(0); } if (value instanceof JvmTypeAnnotationValue) { return ((JvmTypeAnnotationValue) value).getValues().get(0).getIdentifier(); } return null; }
Example #13
Source File: AnnotationReferenceBuildContextImpl.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
protected void _setValue(final JvmBooleanAnnotationValue it, final boolean[] value, final String componentType, final boolean mustBeArray) { EList<Boolean> _values = it.getValues(); Iterables.<Boolean>addAll(_values, ((Iterable<? extends Boolean>)Conversions.doWrapArray(value))); }
Example #14
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Test public void testBooleanAnnotationValue_02() throws Exception { JvmBooleanAnnotationValue value = (JvmBooleanAnnotationValue) getMethodParameterAnnotationValue("booleanValue"); assertEquals(1, value.getValues().size()); assertFalse(value.getValues().get(0)); }
Example #15
Source File: AbstractTypeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Test public void testBooleanAnnotationValue_01() throws Exception { JvmBooleanAnnotationValue value = (JvmBooleanAnnotationValue) getAnnotationValue("booleanValue"); assertEquals(1, value.getValues().size()); assertFalse(value.getValues().get(0)); }
Example #16
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Test public void testBooleanAnnotationValue_02() throws Exception { JvmBooleanAnnotationValue value = (JvmBooleanAnnotationValue) getMethodParameterAnnotationValue("booleanValue"); assertEquals(1, value.getValues().size()); assertFalse(value.getValues().get(0)); }
Example #17
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Test public void testBooleanAnnotationValue_01() throws Exception { JvmBooleanAnnotationValue value = (JvmBooleanAnnotationValue) getAnnotationValue("booleanValue"); assertEquals(1, value.getValues().size()); assertFalse(value.getValues().get(0)); }
Example #18
Source File: JvmModelGenerator.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public void toJavaLiteral(final JvmAnnotationValue value, final ITreeAppendable appendable, final GeneratorConfig config) { if (value instanceof JvmAnnotationAnnotationValue) { _toJavaLiteral((JvmAnnotationAnnotationValue)value, appendable, config); return; } else if (value instanceof JvmBooleanAnnotationValue) { _toJavaLiteral((JvmBooleanAnnotationValue)value, appendable, config); return; } else if (value instanceof JvmByteAnnotationValue) { _toJavaLiteral((JvmByteAnnotationValue)value, appendable, config); return; } else if (value instanceof JvmCharAnnotationValue) { _toJavaLiteral((JvmCharAnnotationValue)value, appendable, config); return; } else if (value instanceof JvmCustomAnnotationValue) { _toJavaLiteral((JvmCustomAnnotationValue)value, appendable, config); return; } else if (value instanceof JvmDoubleAnnotationValue) { _toJavaLiteral((JvmDoubleAnnotationValue)value, appendable, config); return; } else if (value instanceof JvmEnumAnnotationValue) { _toJavaLiteral((JvmEnumAnnotationValue)value, appendable, config); return; } else if (value instanceof JvmFloatAnnotationValue) { _toJavaLiteral((JvmFloatAnnotationValue)value, appendable, config); return; } else if (value instanceof JvmIntAnnotationValue) { _toJavaLiteral((JvmIntAnnotationValue)value, appendable, config); return; } else if (value instanceof JvmLongAnnotationValue) { _toJavaLiteral((JvmLongAnnotationValue)value, appendable, config); return; } else if (value instanceof JvmShortAnnotationValue) { _toJavaLiteral((JvmShortAnnotationValue)value, appendable, config); return; } else if (value instanceof JvmStringAnnotationValue) { _toJavaLiteral((JvmStringAnnotationValue)value, appendable, config); return; } else if (value instanceof JvmTypeAnnotationValue) { _toJavaLiteral((JvmTypeAnnotationValue)value, appendable, config); return; } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(value, appendable, config).toString()); } }
Example #19
Source File: JvmModelGenerator.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected void _toJavaLiteral(final JvmBooleanAnnotationValue it, final ITreeAppendable appendable, final GeneratorConfig config) { final Procedure1<Boolean> _function = (Boolean it_1) -> { appendable.append(it_1.toString()); }; this._loopExtensions.<Boolean>forEachWithShortcut(appendable, it.getValues(), _function); }
Example #20
Source File: AbstractTypeProviderTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Test public void testBooleanAnnotationValue_02() throws Exception { JvmBooleanAnnotationValue value = (JvmBooleanAnnotationValue) getMethodParameterAnnotationValue("booleanValue"); assertEquals(1, value.getValues().size()); assertFalse(value.getValues().get(0)); }