use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method test_ParameterizedTypes_Inner_06.
@Test
public void test_ParameterizedTypes_Inner_06() {
String typeName = ParameterizedTypes.class.getName();
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
JvmOperation methodV = getMethodFromType(type, ParameterizedTypes.Inner.class, "methodVArray_02()");
JvmTypeReference listV = methodV.getReturnType();
assertEquals("java.util.List<? extends V[]>", listV.getIdentifier());
JvmParameterizedTypeReference listType = (JvmParameterizedTypeReference) listV;
assertEquals(1, listType.getArguments().size());
JvmTypeReference typeArgument = listType.getArguments().get(0);
assertTrue(typeArgument instanceof JvmWildcardTypeReference);
JvmWildcardTypeReference wildcardTypeArgument = (JvmWildcardTypeReference) typeArgument;
assertEquals("? extends V[]", wildcardTypeArgument.getIdentifier());
assertEquals(1, wildcardTypeArgument.getConstraints().size());
JvmUpperBound upperBound = (JvmUpperBound) wildcardTypeArgument.getConstraints().get(0);
JvmType upperBoundType = upperBound.getTypeReference().getType();
assertTrue(upperBoundType instanceof JvmArrayType);
assertTrue(((JvmArrayType) upperBoundType).getComponentType() instanceof JvmTypeParameter);
JvmTypeParameter v = type.getTypeParameters().get(3);
assertSame(v, ((JvmArrayType) upperBoundType).getComponentType());
}
use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-eclipse by eclipse.
the class AbstractTypeProviderTest method testFindTypeByName_AbstractMultimap.
@Test
public void testFindTypeByName_AbstractMultimap() {
String typeName = "com.google.common.collect.AbstractMultimap";
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
assertNotNull(type);
diagnose(type, "java:/Objects/javax.annotation.Nullable#javax.annotation.Nullable");
Resource resource = type.eResource();
getAndResolveAllFragments(resource);
recomputeAndCheckIdentifiers(resource);
}
use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-eclipse by eclipse.
the class JdtTypeProviderTest method testFindTypeByName_$StartsWithDollar_02.
// tests for the presence of the bug above
@Override
@Test
public void testFindTypeByName_$StartsWithDollar_02() {
String typeName = "org.eclipse.xtext.common.types.testSetups.$StartsWithDollar";
JvmGenericType type = (JvmGenericType) getTypeProvider().findTypeByName(typeName);
assertNull(type);
}
use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-eclipse by eclipse.
the class DomainmodelJvmModelInferrer method _infer.
protected void _infer(final Entity entity, @Extension final IJvmDeclaredTypeAcceptor acceptor, final boolean prelinkingPhase) {
final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
this._jvmTypesBuilder.setDocumentation(it, this._jvmTypesBuilder.getDocumentation(entity));
JvmParameterizedTypeReference _superType = entity.getSuperType();
boolean _tripleNotEquals = (_superType != null);
if (_tripleNotEquals) {
EList<JvmTypeReference> _superTypes = it.getSuperTypes();
JvmTypeReference _cloneWithProxies = this._jvmTypesBuilder.cloneWithProxies(entity.getSuperType());
this._jvmTypesBuilder.<JvmTypeReference>operator_add(_superTypes, _cloneWithProxies);
}
EList<JvmMember> _members = it.getMembers();
final Procedure1<JvmConstructor> _function_1 = (JvmConstructor it_1) -> {
};
JvmConstructor _constructor = this._jvmTypesBuilder.toConstructor(entity, _function_1);
this._jvmTypesBuilder.<JvmConstructor>operator_add(_members, _constructor);
final JvmTypeReference procedureType = this._typeReferenceBuilder.typeRef(Procedure1.class, this._typeReferenceBuilder.typeRef(it));
EList<JvmMember> _members_1 = it.getMembers();
final Procedure1<JvmConstructor> _function_2 = (JvmConstructor it_1) -> {
EList<JvmFormalParameter> _parameters = it_1.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(entity, "initializer", procedureType);
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("initializer.apply(this);");
_builder.newLine();
}
};
this._jvmTypesBuilder.setBody(it_1, _client);
};
JvmConstructor _constructor_1 = this._jvmTypesBuilder.toConstructor(entity, _function_2);
this._jvmTypesBuilder.<JvmConstructor>operator_add(_members_1, _constructor_1);
EList<Feature> _features = entity.getFeatures();
for (final Feature f : _features) {
boolean _matched = false;
if (f instanceof Property) {
_matched = true;
final JvmField field = this._jvmTypesBuilder.toField(f, ((Property) f).getName(), ((Property) f).getType());
EList<JvmMember> _members_2 = it.getMembers();
this._jvmTypesBuilder.<JvmField>operator_add(_members_2, field);
EList<JvmMember> _members_3 = it.getMembers();
JvmOperation _getter = this._jvmTypesBuilder.toGetter(f, ((Property) f).getName(), ((Property) f).getType());
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_3, _getter);
EList<JvmMember> _members_4 = it.getMembers();
JvmOperation _setter = this._jvmTypesBuilder.toSetter(f, ((Property) f).getName(), ((Property) f).getType());
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_4, _setter);
}
if (!_matched) {
if (f instanceof Operation) {
_matched = true;
EList<JvmMember> _members_2 = it.getMembers();
String _name = ((Operation) f).getName();
JvmTypeReference _elvis = null;
JvmTypeReference _type = ((Operation) f).getType();
if (_type != null) {
_elvis = _type;
} else {
JvmTypeReference _inferredType = this._jvmTypesBuilder.inferredType();
_elvis = _inferredType;
}
final Procedure1<JvmOperation> _function_3 = (JvmOperation it_1) -> {
this._jvmTypesBuilder.setDocumentation(it_1, this._jvmTypesBuilder.getDocumentation(f));
EList<JvmFormalParameter> _params = ((Operation) f).getParams();
for (final JvmFormalParameter p : _params) {
EList<JvmFormalParameter> _parameters = it_1.getParameters();
JvmFormalParameter _parameter = this._jvmTypesBuilder.toParameter(p, p.getName(), p.getParameterType());
this._jvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter);
}
this._jvmTypesBuilder.setBody(it_1, ((Operation) f).getBody());
};
JvmOperation _method = this._jvmTypesBuilder.toMethod(f, _name, _elvis, _function_3);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _method);
}
}
}
EList<JvmMember> _members_2 = it.getMembers();
JvmOperation _toStringMethod = this._jvmTypesBuilder.toToStringMethod(entity, it);
this._jvmTypesBuilder.<JvmOperation>operator_add(_members_2, _toStringMethod);
};
acceptor.<JvmGenericType>accept(this._jvmTypesBuilder.toClass(entity, this._iQualifiedNameProvider.getFullyQualifiedName(entity)), _function);
}
use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-xtend by eclipse.
the class CompilationUnitImpl method toTypeDeclaration.
public TypeDeclaration toTypeDeclaration(final JvmDeclaredType delegate) {
final Function1<JvmDeclaredType, TypeDeclaration> _function = (JvmDeclaredType it) -> {
JvmTypeDeclarationImpl<? extends JvmDeclaredType> _switchResult = null;
boolean _matched = false;
if (delegate instanceof JvmGenericType) {
boolean _isInterface = ((JvmGenericType) delegate).isInterface();
if (_isInterface) {
_matched = true;
JvmInterfaceDeclarationImpl _xifexpression = null;
boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit) {
MutableJvmInterfaceDeclarationImpl _mutableJvmInterfaceDeclarationImpl = new MutableJvmInterfaceDeclarationImpl();
final Procedure1<MutableJvmInterfaceDeclarationImpl> _function_1 = (MutableJvmInterfaceDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmGenericType) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<MutableJvmInterfaceDeclarationImpl>operator_doubleArrow(_mutableJvmInterfaceDeclarationImpl, _function_1);
} else {
JvmInterfaceDeclarationImpl _jvmInterfaceDeclarationImpl = new JvmInterfaceDeclarationImpl();
final Procedure1<JvmInterfaceDeclarationImpl> _function_2 = (JvmInterfaceDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmGenericType) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<JvmInterfaceDeclarationImpl>operator_doubleArrow(_jvmInterfaceDeclarationImpl, _function_2);
}
_switchResult = _xifexpression;
}
}
if (!_matched) {
if (delegate instanceof JvmGenericType) {
_matched = true;
JvmClassDeclarationImpl _xifexpression = null;
boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit) {
MutableJvmClassDeclarationImpl _mutableJvmClassDeclarationImpl = new MutableJvmClassDeclarationImpl();
final Procedure1<MutableJvmClassDeclarationImpl> _function_1 = (MutableJvmClassDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmGenericType) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<MutableJvmClassDeclarationImpl>operator_doubleArrow(_mutableJvmClassDeclarationImpl, _function_1);
} else {
JvmClassDeclarationImpl _jvmClassDeclarationImpl = new JvmClassDeclarationImpl();
final Procedure1<JvmClassDeclarationImpl> _function_2 = (JvmClassDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmGenericType) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<JvmClassDeclarationImpl>operator_doubleArrow(_jvmClassDeclarationImpl, _function_2);
}
_switchResult = _xifexpression;
}
}
if (!_matched) {
if (delegate instanceof JvmAnnotationType) {
_matched = true;
JvmAnnotationTypeDeclarationImpl _xifexpression = null;
boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit) {
MutableJvmAnnotationTypeDeclarationImpl _mutableJvmAnnotationTypeDeclarationImpl = new MutableJvmAnnotationTypeDeclarationImpl();
final Procedure1<MutableJvmAnnotationTypeDeclarationImpl> _function_1 = (MutableJvmAnnotationTypeDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmAnnotationType) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<MutableJvmAnnotationTypeDeclarationImpl>operator_doubleArrow(_mutableJvmAnnotationTypeDeclarationImpl, _function_1);
} else {
JvmAnnotationTypeDeclarationImpl _jvmAnnotationTypeDeclarationImpl = new JvmAnnotationTypeDeclarationImpl();
final Procedure1<JvmAnnotationTypeDeclarationImpl> _function_2 = (JvmAnnotationTypeDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmAnnotationType) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<JvmAnnotationTypeDeclarationImpl>operator_doubleArrow(_jvmAnnotationTypeDeclarationImpl, _function_2);
}
_switchResult = _xifexpression;
}
}
if (!_matched) {
if (delegate instanceof JvmEnumerationType) {
_matched = true;
JvmEnumerationTypeDeclarationImpl _xifexpression = null;
boolean _isBelongedToCompilationUnit = this.isBelongedToCompilationUnit(delegate);
if (_isBelongedToCompilationUnit) {
MutableJvmEnumerationTypeDeclarationImpl _mutableJvmEnumerationTypeDeclarationImpl = new MutableJvmEnumerationTypeDeclarationImpl();
final Procedure1<MutableJvmEnumerationTypeDeclarationImpl> _function_1 = (MutableJvmEnumerationTypeDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmEnumerationType) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<MutableJvmEnumerationTypeDeclarationImpl>operator_doubleArrow(_mutableJvmEnumerationTypeDeclarationImpl, _function_1);
} else {
JvmEnumerationTypeDeclarationImpl _jvmEnumerationTypeDeclarationImpl = new JvmEnumerationTypeDeclarationImpl();
final Procedure1<JvmEnumerationTypeDeclarationImpl> _function_2 = (JvmEnumerationTypeDeclarationImpl it_1) -> {
it_1.setDelegate(((JvmEnumerationType) delegate));
it_1.setCompilationUnit(this);
};
_xifexpression = ObjectExtensions.<JvmEnumerationTypeDeclarationImpl>operator_doubleArrow(_jvmEnumerationTypeDeclarationImpl, _function_2);
}
_switchResult = _xifexpression;
}
}
return ((TypeDeclaration) _switchResult);
};
return this.<JvmDeclaredType, TypeDeclaration>getOrCreate(delegate, _function);
}
Aggregations