use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testAnnotatedParameter_03.
@Test
public void testAnnotatedParameter_03() throws Exception {
String typeName = TestAnnotation.Annotated.class.getName();
JvmAnnotationType annotationType = (JvmAnnotationType) getTypeProvider().findTypeByName(TestAnnotation.NestedAnnotation.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(2);
assertEquals(1, target.getAnnotations().size());
JvmAnnotationReference annotationReference = target.getAnnotations().get(0);
assertSame(annotationType, annotationReference.getAnnotation());
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testAnnotatedConstructor_01.
@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);
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class SourceBasedJdtTypeProviderTest method getConstructorFromType.
@Override
protected JvmConstructor getConstructorFromType(EObject context, Class<?> type, String constructor) {
JvmConstructor result = super.getConstructorFromType(context, type, constructor);
if (result != null) {
IJavaElement found = elementFinder.findElementFor(result);
assertEquals(IJavaElement.METHOD, found.getElementType());
assertEquals(result.getSimpleName(), found.getElementName());
IMethod foundMethod = (IMethod) found;
assertEquals(result.getParameters().size(), foundMethod.getNumberOfParameters());
}
return result;
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractConstructorScopeTest method testGetElementByInstance_01.
@Test
public void testGetElementByInstance_01() {
JvmConstructor constructor = TypesFactory.eINSTANCE.createJvmConstructor();
JvmGenericType type = TypesFactory.eINSTANCE.createJvmGenericType();
type.setPackageName("java.lang");
type.setSimpleName("Object");
constructor.setSimpleName("Object");
type.getMembers().add(constructor);
IEObjectDescription element = getConstructorScope().getSingleElement(constructor);
assertNotNull(element);
assertEquals(new IQualifiedNameConverter.DefaultImpl().toQualifiedName("java.lang.Object"), element.getName());
assertEquals(new IQualifiedNameConverter.DefaultImpl().toQualifiedName("java.lang.Object"), element.getQualifiedName());
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testEnum_04.
@Test
public void testEnum_04() throws Exception {
String typeName = TestEnum.class.getName();
JvmEnumerationType type = (JvmEnumerationType) getTypeProvider().findTypeByName(typeName);
List<JvmMember> members = type.getMembers();
boolean constructorFound = false;
for (JvmMember member : members) {
if (member instanceof JvmConstructor) {
assertFalse(constructorFound);
constructorFound = true;
List<JvmFormalParameter> parameters = ((JvmConstructor) member).getParameters();
// synthetic parameters are not returned
assertEquals(1, parameters.size());
}
}
assertTrue(constructorFound);
}
Aggregations