use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_arrayWildcard_02.
@Test
public void test_arrayWildcard_02() {
JvmOperation arrayWildcard = getMethodFromParameterizedMethods("arrayWildcard(java.util.List[])");
JvmTypeReference paramType = arrayWildcard.getParameters().get(0).getParameterType();
assertEquals("java.util.List<? extends java.lang.Object>[]", paramType.getIdentifier());
assertTrue(paramType.getType() instanceof JvmArrayType);
JvmArrayType arrayType = (JvmArrayType) paramType.getType();
assertTrue(arrayType.getComponentType() instanceof JvmDeclaredType);
assertTrue(paramType instanceof JvmGenericArrayTypeReference);
assertTrue(((JvmGenericArrayTypeReference) paramType).getComponentType() instanceof JvmParameterizedTypeReference);
}
use of org.eclipse.xtext.common.types.JvmDeclaredType 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());
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testDeprecatedBit_02.
@Test
public void testDeprecatedBit_02() {
String typeName = DeprecatedMembers.class.getName();
JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
assertTrue(type.isSetDeprecated());
assertFalse(type.isDeprecated());
for (JvmMember member : type.getMembers()) {
assertTrue(member.isSetDeprecated());
assertTrue(member.isDeprecated());
}
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testBug428340.
@Test
public void testBug428340() {
String typeName = Bug428340.class.getName();
JvmDeclaredType type = (JvmDeclaredType) getTypeProvider().findTypeByName(typeName);
JvmAnnotationReference myAnnotation = type.getAnnotations().get(0);
assertEquals("MyAnnotation", myAnnotation.getAnnotation().getSimpleName());
}
use of org.eclipse.xtext.common.types.JvmDeclaredType in project xtext-eclipse by eclipse.
the class JdtTypeMirror method initialize.
/**
* @since 2.7
*/
@Override
public void initialize(TypeResource typeResource, Map<?, ?> options) {
try {
if (typeFactory instanceof ITypeFactory.OptionsAware<?, ?>) {
JvmDeclaredType jvmType = ((ITypeFactory.OptionsAware<IType, JvmDeclaredType>) typeFactory).createType(mirroredType, typeResource, options);
typeResource.getContents().add(jvmType);
} else {
typeResource.getContents().add(typeFactory.createType(mirroredType));
}
} catch (RuntimeException e) {
if (typeResourceServices != null) {
typeResourceServices.getOperationCanceledManager().propagateAsErrorIfCancelException(e);
}
LOG.error("Error initializing type " + typeResource.getURI(), e);
throw e;
}
this.typeResource = typeResource;
}
Aggregations