use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method doTestInnerType_WrappedIterator_02.
protected void doTestInnerType_WrappedIterator_02(JvmGenericType wrappedIterator) {
assertEquals(3, Iterables.size(wrappedIterator.getDeclaredConstructors()));
JvmConstructor constructor = (JvmConstructor) Iterables.find(wrappedIterator.getMembers(), new Predicate<JvmMember>() {
@Override
public boolean apply(JvmMember input) {
return (input instanceof JvmConstructor) && input.getSimpleName().equals("WrappedIterator") && ((JvmConstructor) input).getParameters().size() == 3;
}
});
assertNotNull(constructor);
JvmFormalParameter firstParameter = constructor.getParameters().get(0);
assertEquals(1, firstParameter.getAnnotations().size());
assertEquals("java.lang.String", firstParameter.getParameterType().getIdentifier());
assertEquals(TestAnnotationWithDefaults.class.getName(), firstParameter.getAnnotations().get(0).getAnnotation().getQualifiedName());
JvmFormalParameter secondParameter = constructor.getParameters().get(1);
assertEquals(0, secondParameter.getAnnotations().size());
assertEquals("int", secondParameter.getParameterType().getIdentifier());
JvmFormalParameter thirdParameter = constructor.getParameters().get(2);
assertEquals(1, thirdParameter.getAnnotations().size());
assertEquals("java.util.Iterator<V>", thirdParameter.getParameterType().getIdentifier());
assertEquals(TestAnnotation.NestedAnnotation.class.getName(), thirdParameter.getAnnotations().get(0).getAnnotation().getQualifiedName());
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testInnerAnnotationType.
@Test
public void testInnerAnnotationType() throws Exception {
JvmDeclaredType declaredType = (JvmDeclaredType) getTypeProvider().findTypeByName(TypeWithInnerAnnotation.class.getName());
assertEquals(2, declaredType.getMembers().size());
// default constructor
assertTrue(Iterables.any(declaredType.getMembers(), new Predicate<JvmMember>() {
@Override
public boolean apply(JvmMember input) {
return (input instanceof JvmConstructor) && input.getSimpleName().equals(TypeWithInnerAnnotation.class.getSimpleName());
}
}));
// inner annotation type
assertTrue(Iterables.any(declaredType.getMembers(), new Predicate<JvmMember>() {
@Override
public boolean apply(JvmMember input) {
return (input instanceof JvmAnnotationType) && input.getIdentifier().equals(TypeWithInnerAnnotation.MyAnnotation.class.getName()) && input.getVisibility() == JvmVisibility.PUBLIC;
}
}));
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_nestedTypes_Outer_Inner_02.
@Test
public void test_nestedTypes_Outer_Inner_02() {
String typeName = NestedTypes.Outer.Inner.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
List<JvmConstructor> constructors = Lists.newArrayList(type.getDeclaredConstructors());
assertEquals(1, constructors.size());
JvmConstructor parameterlessConstructor = constructors.get(0);
assertEquals(1, parameterlessConstructor.getParameters().size());
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method doTestInnerType_WrappedIterator_01.
private void doTestInnerType_WrappedIterator_01(JvmGenericType wrappedIterator) {
assertEquals(2, Iterables.size(wrappedIterator.getDeclaredConstructors()));
// default constructor
assertTrue(Iterables.any(wrappedIterator.getMembers(), new Predicate<JvmMember>() {
@Override
public boolean apply(JvmMember input) {
return (input instanceof JvmConstructor) && input.getSimpleName().equals("Iter") && ((JvmConstructor) input).getParameters().size() == 0;
}
}));
// second constructor
JvmConstructor secondConstructor = (JvmConstructor) Iterables.find(wrappedIterator.getMembers(), new Predicate<JvmMember>() {
@Override
public boolean apply(JvmMember input) {
return (input instanceof JvmConstructor) && input.getSimpleName().equals("Iter") && ((JvmConstructor) input).getParameters().size() == 1;
}
});
assertNotNull(secondConstructor);
JvmFormalParameter firstParameter = secondConstructor.getParameters().get(0);
assertEquals("java.util.Iterator<V>", firstParameter.getParameterType().getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testAnnotatedConstructor_03.
@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);
}
Aggregations