use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_nestedInterface_Outer_02.
@Test
public void test_nestedInterface_Outer_02() {
String typeName = NestedInterfaces.class.getName() + "$Outer";
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
List<JvmConstructor> constructors = Lists.newArrayList(type.getDeclaredConstructors());
assertEquals(0, constructors.size());
assertEquals(JvmVisibility.DEFAULT, type.getVisibility());
assertTrue(type.isStatic());
assertTrue(type.isAbstract());
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_staticNestedTypes_constructor.
@Test
public void test_staticNestedTypes_constructor() {
String typeName = Bug347739.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
List<JvmMember> members = type.getMembers();
for (JvmMember member : members) {
if (member instanceof JvmGenericType) {
if ("StackItem".equals(member.getSimpleName())) {
JvmGenericType stackItem = (JvmGenericType) member;
Iterable<JvmConstructor> constructors = stackItem.getDeclaredConstructors();
for (JvmConstructor constructor : constructors) {
assertEquals(2, constructor.getParameters().size());
}
return;
}
}
}
fail("could not find inner class");
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testAnnotatedConstructor_02.
@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);
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method doTestInnerType_WrappedIterator_03.
protected void doTestInnerType_WrappedIterator_03(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() == 4;
}
});
assertNotNull(constructor);
JvmFormalParameter firstParameter = constructor.getParameters().get(0);
assertEquals(0, firstParameter.getAnnotations().size());
assertEquals("int", firstParameter.getParameterType().getIdentifier());
JvmFormalParameter secondParameter = constructor.getParameters().get(1);
assertEquals(1, secondParameter.getAnnotations().size());
assertEquals("java.lang.String", secondParameter.getParameterType().getIdentifier());
assertEquals(TestAnnotationWithDefaults.class.getName(), secondParameter.getAnnotations().get(0).getAnnotation().getQualifiedName());
JvmFormalParameter thirdParameter = constructor.getParameters().get(2);
assertEquals(0, thirdParameter.getAnnotations().size());
assertEquals("int", thirdParameter.getParameterType().getIdentifier());
JvmFormalParameter forthParameter = constructor.getParameters().get(3);
assertEquals(1, forthParameter.getAnnotations().size());
assertEquals("java.lang.String", forthParameter.getParameterType().getIdentifier());
assertEquals(TestAnnotation.NestedAnnotation.class.getName(), forthParameter.getAnnotations().get(0).getAnnotation().getQualifiedName());
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testAnnotatedParameter_01.
@Test
public void testAnnotatedParameter_01() throws Exception {
String typeName = TestAnnotation.Annotated.class.getName();
JvmAnnotationType annotationType = (JvmAnnotationType) getTypeProvider().findTypeByName(TestAnnotation.class.getName());
JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
JvmConstructor constructor = getConstructorFromType(type, TestAnnotation.Annotated.class, "Annotated(java.lang.String,java.lang.String,java.lang.String)");
JvmAnnotationTarget target = constructor.getParameters().get(0);
assertEquals(2, target.getAnnotations().size());
JvmAnnotationReference annotationReference = target.getAnnotations().get(0);
assertSame(annotationType, annotationReference.getAnnotation());
annotationType = (JvmAnnotationType) getTypeProvider().findTypeByName(TestAnnotation.NestedAnnotation.class.getName());
annotationReference = target.getAnnotations().get(1);
assertSame(annotationType, annotationReference.getAnnotation());
}
Aggregations