Java 类org.eclipse.xtext.common.types.JvmStringAnnotationValue 实例源码

项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testDefaultAnnotationAnnotationValue_02() throws Exception {
    JvmAnnotationAnnotationValue value = (JvmAnnotationAnnotationValue) getDefaultAnnotationValue(
            "annotationArrayValue");
    assertEquals(2, value.getValues().size());
    JvmAnnotationReference reference1 = value.getValues().get(0);
    assertEquals(TestAnnotationWithDefaults.NestedAnnotation.class.getName(),
            reference1.getAnnotation().getIdentifier());
    JvmAnnotationValue nestedAnnotationValue1 = reference1.getValues().get(0);
    assertTrue(nestedAnnotationValue1 instanceof JvmStringAnnotationValue);
    assertEquals("AnotherString", ((JvmStringAnnotationValue) nestedAnnotationValue1).getValues().get(0));
    JvmAnnotationReference reference2 = value.getValues().get(1);
    assertEquals(TestAnnotationWithDefaults.NestedAnnotation.class.getName(),
            reference2.getAnnotation().getIdentifier());
    JvmAnnotationValue nestedAnnotationValue2 = reference2.getValues().get(0);
    assertTrue(nestedAnnotationValue2 instanceof JvmStringAnnotationValue);
    assertEquals("MyString", ((JvmStringAnnotationValue) nestedAnnotationValue2).getValues().get(0));
}
项目:xtext-extras    文件:JvmTypesBuilder.java   
/**
 * Creates and returns an annotation reference of the given annotation type's name and the given value.
 * 
 * @param sourceElement
 *            the source element to associate the created element with.
 * @param annotationTypeName
 *            the type name of the created annotation.
 * @param value
 *            the value of the annotation reference. Can be <code>null</code> if the reference doesn't have any value.
 *            
 * @return a result representing an annotation reference to the given annotation type, <code>null<code> if 
 *      sourceElement or annotationType are <code>null</code>.
 * 
 * @deprecated use {@link JvmAnnotationReferenceBuilder#annotationRef(String, String...)} instead
 */
//TODO Move up the code used in Xtend's CompilationUnitImpl so we can reuse it here.
/* @Nullable */ 
@Deprecated
public JvmAnnotationReference toAnnotation(/* @Nullable */ EObject sourceElement, /* @Nullable */ String annotationTypeName, /* @Nullable */ Object value) {
    JvmAnnotationReference result = typesFactory.createJvmAnnotationReference();
    JvmType jvmType = references.findDeclaredType(annotationTypeName, sourceElement);
    if (jvmType == null) {
        throw new IllegalArgumentException("The type "+annotationTypeName +" is not on the classpath.");
    }
    if (!(jvmType instanceof JvmAnnotationType)) {
        throw new IllegalArgumentException("The given class " + annotationTypeName + " is not an annotation type.");
    }
    result.setAnnotation((JvmAnnotationType) jvmType);
    if (value != null) {
        if (value instanceof String) {
            JvmStringAnnotationValue annotationValue = typesFactory.createJvmStringAnnotationValue();
            annotationValue.getValues().add((String) value);
            result.getExplicitValues().add(annotationValue);
        }
    }
    return result;
}
项目:xtext-extras    文件:JvmAnnotationReferenceBuilder.java   
/**
 * Creates and returns an annotation reference of the given annotation type's name and the given value.
 * 
 * @param annotationTypeName
 *            the type name of the created annotation.
 * @param values
 *            the string value of the annotation's 'values' property.
 *            
 * @return a result representing an annotation reference to the given annotation type, <code>null<code> if 
 *      annotationType are <code>null</code>.  
 */
//TODO Move up the code used in Xtend's CompilationUnitImpl so we can reuse it here.
//TODO Support other types and setting non default properties
/* @Nullable */ 
public JvmAnnotationReference annotationRef(/* @Nullable */ String annotationTypeName, /* @Nullable */ String... values) {
    if (context == null || annotationTypeName == null)
        return null;
    JvmAnnotationReference result = typesFactory.createJvmAnnotationReference();
    JvmType jvmType = references.findDeclaredType(annotationTypeName, context);
    if (jvmType == null) {
        throw new IllegalArgumentException("The type "+annotationTypeName +" is not on the classpath.");
    }
    if (!(jvmType instanceof JvmAnnotationType)) {
        throw new IllegalArgumentException("The given class " + annotationTypeName + " is not an annotation type.");
    }
    result.setAnnotation((JvmAnnotationType) jvmType);
    if (values != null && values.length>0) {
        JvmStringAnnotationValue annotationValue = typesFactory.createJvmStringAnnotationValue();
        for (String value : values) {
            annotationValue.getValues().add(value);
        }
        result.getExplicitValues().add(annotationValue);
    }
    return result;
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testDefaultAnnotationAnnotationValue_02() throws Exception {
    JvmAnnotationAnnotationValue value = (JvmAnnotationAnnotationValue) getDefaultAnnotationValue(
            "annotationArrayValue");
    assertEquals(2, value.getValues().size());
    JvmAnnotationReference reference1 = value.getValues().get(0);
    assertEquals(TestAnnotationWithDefaults.NestedAnnotation.class.getName(),
            reference1.getAnnotation().getIdentifier());
    JvmAnnotationValue nestedAnnotationValue1 = reference1.getValues().get(0);
    assertTrue(nestedAnnotationValue1 instanceof JvmStringAnnotationValue);
    assertEquals("AnotherString", ((JvmStringAnnotationValue) nestedAnnotationValue1).getValues().get(0));
    JvmAnnotationReference reference2 = value.getValues().get(1);
    assertEquals(TestAnnotationWithDefaults.NestedAnnotation.class.getName(),
            reference2.getAnnotation().getIdentifier());
    JvmAnnotationValue nestedAnnotationValue2 = reference2.getValues().get(0);
    assertTrue(nestedAnnotationValue2 instanceof JvmStringAnnotationValue);
    assertEquals("MyString", ((JvmStringAnnotationValue) nestedAnnotationValue2).getValues().get(0));
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testStringAnnotationValue_01() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getAnnotationValue("stringValue");
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("stringValue", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testStringAnnotationValue_02() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getAnnotationValue("stringArrayValue");
    assertEquals(4, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("array", s);
    s = value.getValues().get(1);
    assertEquals("value", s);
    s = value.getValues().get(2);
    assertEquals("duplicate", s);
    s = value.getValues().get(3);
    assertEquals("duplicate", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testStringAnnotationValue_03() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getMethodParameterAnnotationValue("stringValue");
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("stringValue", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testStringAnnotationValue_04() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getMethodParameterAnnotationValue(
            "stringArrayValue");
    assertEquals(2, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("array", s);
    s = value.getValues().get(1);
    assertEquals("value", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testStringAnnotationValue_05() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getConstructorParameterAnnotationValue(
            "stringValue");
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("stringValue", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testStringAnnotationValue_06() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getConstructorParameterAnnotationValue(
            "stringArrayValue");
    assertEquals(2, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("array", s);
    s = value.getValues().get(1);
    assertEquals("value", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotationAnnotationValue_01() throws Exception {
    JvmAnnotationAnnotationValue value = (JvmAnnotationAnnotationValue) getAnnotationValue("annotationValue");
    assertEquals(1, value.getValues().size());
    JvmAnnotationReference annotationReference = value.getValues().get(0);
    assertEquals(TestAnnotation.NestedAnnotation.class.getName(),
            annotationReference.getAnnotation().getIdentifier());
    assertEquals(1, annotationReference.getValues().size());
    JvmStringAnnotationValue nestedValue = (JvmStringAnnotationValue) annotationReference.getValues().get(0);
    assertEquals(1, nestedValue.getValues().size());
    assertEquals("MyString", nestedValue.getValues().get(0));
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotationAnnotationValue_02() throws Exception {
    JvmAnnotationAnnotationValue value = (JvmAnnotationAnnotationValue) getConstructorParameterAnnotationValue(
            "annotationValue");
    assertEquals(1, value.getValues().size());
    JvmAnnotationReference annotationReference = value.getValues().get(0);
    assertEquals(TestAnnotation.NestedAnnotation.class.getName(),
            annotationReference.getAnnotation().getIdentifier());
    assertEquals(1, annotationReference.getValues().size());
    JvmStringAnnotationValue nestedValue = (JvmStringAnnotationValue) annotationReference.getValues().get(0);
    assertEquals(1, nestedValue.getValues().size());
    assertEquals("MyString", nestedValue.getValues().get(0));
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotationAnnotationValue_03() throws Exception {
    JvmAnnotationAnnotationValue value = (JvmAnnotationAnnotationValue) getMethodParameterAnnotationValue(
            "annotationValue");
    assertEquals(1, value.getValues().size());
    JvmAnnotationReference annotationReference = value.getValues().get(0);
    assertEquals(TestAnnotation.NestedAnnotation.class.getName(),
            annotationReference.getAnnotation().getIdentifier());
    assertEquals(1, annotationReference.getValues().size());
    JvmStringAnnotationValue nestedValue = (JvmStringAnnotationValue) annotationReference.getValues().get(0);
    assertEquals(1, nestedValue.getValues().size());
    assertEquals("MyString", nestedValue.getValues().get(0));
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotatedMethod_01() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation operation = getMethodFromType(type, TestAnnotation.Annotated.class, "method()");
    assertNotNull(operation);
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getExplicitAnnotationValue("value", operation);
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("method", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotatedConstructor_01() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class, "Annotated()");
    assertNotNull(constructor);
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getExplicitAnnotationValue("value", constructor);
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("constructor", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotatedConstructor_02() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class,
            "Annotated(java.lang.String)");
    assertNotNull(constructor);
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getExplicitAnnotationValue("value", constructor);
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("secondConstructor", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotatedConstructor_03() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class,
            "Annotated(java.lang.String,T)");
    assertNotNull(constructor);
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getExplicitAnnotationValue("value", constructor);
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("parameterizedConstructor", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotatedConstructor_04() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class,
            "Annotated(java.lang.String,java.lang.String)");
    assertNotNull(constructor);
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getExplicitAnnotationValue("value", constructor);
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("thirdConstructorWithBody", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotatedField_01() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmField field = getFieldFromType(type, TestAnnotation.Annotated.class, "field");
    assertNotNull(field);
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getDefaultOrExplicitAnnotationValue("value", field);
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("MyString", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testDefaultAnnotationAnnotationValue_01() throws Exception {
    JvmAnnotationAnnotationValue value = (JvmAnnotationAnnotationValue) getDefaultAnnotationValue(
            "annotationValue");
    assertEquals(1, value.getValues().size());
    JvmAnnotationReference reference = value.getValues().get(0);
    assertEquals(TestAnnotationWithDefaults.NestedAnnotation.class.getName(),
            reference.getAnnotation().getIdentifier());
    JvmAnnotationValue nestedAnnotationValue = reference.getValues().get(0);
    assertTrue(nestedAnnotationValue instanceof JvmStringAnnotationValue);
    assertEquals("AnotherString", ((JvmStringAnnotationValue) nestedAnnotationValue).getValues().get(0));
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testDefaultStringAnnotationValue_01() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getDefaultAnnotationValue("stringValue");
    assertEquals(1, value.getValues().size());
    String string = value.getValues().get(0);
    assertEquals("", string);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testDefaultStringAnnotationValue_02() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getDefaultAnnotationValue("stringArrayValue");
    assertEquals(1, value.getValues().size());
    String string = value.getValues().get(0);
    assertEquals("arrayValue", string);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
protected void checkDefaultAnnotationValues(JvmAnnotationReference annotationReference) {
    List<JvmAnnotationValue> values = annotationReference.getValues();
    assertEquals(2, values.size());
    Map<String, String> nameToValue = Maps.newHashMap();
    nameToValue.put("emptyString", "");
    nameToValue.put("string", "string");
    for (JvmAnnotationValue value : values) {
        String defaultValue = nameToValue.remove(value.getValueName());
        assertNotNull(value.getValueName(), defaultValue);
        JvmStringAnnotationValue castedValue = (JvmStringAnnotationValue) value;
        assertEquals(1, castedValue.getValues().size());
        assertEquals(defaultValue, castedValue.getValues().get(0));
    }
    assertTrue(nameToValue.isEmpty());
}
项目:xtext-extras    文件:JvmModelGenerator.java   
protected void _toJavaLiteral(final JvmStringAnnotationValue it, final ITreeAppendable appendable, final GeneratorConfig config) {
  final Procedure1<String> _function = (String it_1) -> {
    String _doConvertToJavaString = this.doConvertToJavaString(it_1.toString());
    String _plus = ("\"" + _doConvertToJavaString);
    String _plus_1 = (_plus + "\"");
    appendable.append(_plus_1);
  };
  this._loopExtensions.<String>forEachWithShortcut(appendable, it.getValues(), _function);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testStringAnnotationValue_01() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getAnnotationValue("stringValue");
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("stringValue", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testStringAnnotationValue_02() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getAnnotationValue("stringArrayValue");
    assertEquals(4, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("array", s);
    s = value.getValues().get(1);
    assertEquals("value", s);
    s = value.getValues().get(2);
    assertEquals("duplicate", s);
    s = value.getValues().get(3);
    assertEquals("duplicate", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testStringAnnotationValue_03() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getMethodParameterAnnotationValue("stringValue");
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("stringValue", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testStringAnnotationValue_04() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getMethodParameterAnnotationValue(
            "stringArrayValue");
    assertEquals(2, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("array", s);
    s = value.getValues().get(1);
    assertEquals("value", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testStringAnnotationValue_05() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getConstructorParameterAnnotationValue(
            "stringValue");
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("stringValue", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testStringAnnotationValue_06() throws Exception {
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getConstructorParameterAnnotationValue(
            "stringArrayValue");
    assertEquals(2, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("array", s);
    s = value.getValues().get(1);
    assertEquals("value", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotationAnnotationValue_01() throws Exception {
    JvmAnnotationAnnotationValue value = (JvmAnnotationAnnotationValue) getAnnotationValue("annotationValue");
    assertEquals(1, value.getValues().size());
    JvmAnnotationReference annotationReference = value.getValues().get(0);
    assertEquals(TestAnnotation.NestedAnnotation.class.getName(),
            annotationReference.getAnnotation().getIdentifier());
    assertEquals(1, annotationReference.getValues().size());
    JvmStringAnnotationValue nestedValue = (JvmStringAnnotationValue) annotationReference.getValues().get(0);
    assertEquals(1, nestedValue.getValues().size());
    assertEquals("MyString", nestedValue.getValues().get(0));
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotationAnnotationValue_02() throws Exception {
    JvmAnnotationAnnotationValue value = (JvmAnnotationAnnotationValue) getConstructorParameterAnnotationValue(
            "annotationValue");
    assertEquals(1, value.getValues().size());
    JvmAnnotationReference annotationReference = value.getValues().get(0);
    assertEquals(TestAnnotation.NestedAnnotation.class.getName(),
            annotationReference.getAnnotation().getIdentifier());
    assertEquals(1, annotationReference.getValues().size());
    JvmStringAnnotationValue nestedValue = (JvmStringAnnotationValue) annotationReference.getValues().get(0);
    assertEquals(1, nestedValue.getValues().size());
    assertEquals("MyString", nestedValue.getValues().get(0));
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotationAnnotationValue_03() throws Exception {
    JvmAnnotationAnnotationValue value = (JvmAnnotationAnnotationValue) getMethodParameterAnnotationValue(
            "annotationValue");
    assertEquals(1, value.getValues().size());
    JvmAnnotationReference annotationReference = value.getValues().get(0);
    assertEquals(TestAnnotation.NestedAnnotation.class.getName(),
            annotationReference.getAnnotation().getIdentifier());
    assertEquals(1, annotationReference.getValues().size());
    JvmStringAnnotationValue nestedValue = (JvmStringAnnotationValue) annotationReference.getValues().get(0);
    assertEquals(1, nestedValue.getValues().size());
    assertEquals("MyString", nestedValue.getValues().get(0));
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotatedMethod_01() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmOperation operation = getMethodFromType(type, TestAnnotation.Annotated.class, "method()");
    assertNotNull(operation);
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getExplicitAnnotationValue("value", operation);
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("method", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotatedConstructor_01() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class, "Annotated()");
    assertNotNull(constructor);
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getExplicitAnnotationValue("value", constructor);
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("constructor", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotatedConstructor_02() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class,
            "Annotated(java.lang.String)");
    assertNotNull(constructor);
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getExplicitAnnotationValue("value", constructor);
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("secondConstructor", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotatedConstructor_03() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class,
            "Annotated(java.lang.String,T)");
    assertNotNull(constructor);
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getExplicitAnnotationValue("value", constructor);
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("parameterizedConstructor", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotatedConstructor_04() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class,
            "Annotated(java.lang.String,java.lang.String)");
    assertNotNull(constructor);
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getExplicitAnnotationValue("value", constructor);
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("thirdConstructorWithBody", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testAnnotatedField_01() throws Exception {
    String typeName = TestAnnotation.Annotated.class.getName();
    JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
    JvmField field = getFieldFromType(type, TestAnnotation.Annotated.class, "field");
    assertNotNull(field);
    JvmStringAnnotationValue value = (JvmStringAnnotationValue) getDefaultOrExplicitAnnotationValue("value", field);
    assertEquals(1, value.getValues().size());
    String s = value.getValues().get(0);
    assertEquals("MyString", s);
}
项目:xtext-extras    文件:AbstractTypeProviderTest.java   
@Test
public void testDefaultAnnotationAnnotationValue_01() throws Exception {
    JvmAnnotationAnnotationValue value = (JvmAnnotationAnnotationValue) getDefaultAnnotationValue(
            "annotationValue");
    assertEquals(1, value.getValues().size());
    JvmAnnotationReference reference = value.getValues().get(0);
    assertEquals(TestAnnotationWithDefaults.NestedAnnotation.class.getName(),
            reference.getAnnotation().getIdentifier());
    JvmAnnotationValue nestedAnnotationValue = reference.getValues().get(0);
    assertTrue(nestedAnnotationValue instanceof JvmStringAnnotationValue);
    assertEquals("AnotherString", ((JvmStringAnnotationValue) nestedAnnotationValue).getValues().get(0));
}