use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class KnownTypesScope method doGetSingleElement.
@Override
protected IEObjectDescription doGetSingleElement(QualifiedName name, String firstSegment, int dollarIndex) {
int index = -1;
JvmType result = null;
for (int i = 0; i < types.size(); i++) {
JvmType type = types.get(i);
JvmType exactMatch = getExactMatch(type, index, name);
if (exactMatch != null)
return EObjectDescription.create(name, exactMatch);
if (isMatch(i, type, firstSegment, name)) {
JvmType resolved = getUnambiguousResult(result, index, type, i, name);
if (resolved == null) {
return null;
}
if (resolved != result) {
result = resolved;
index = i;
}
}
}
return toDescription(name, result, dollarIndex, index);
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class NestedTypesScope method findNestedTypeInLocalTypeNonResolving.
/**
* We have to be careful to keep the unresolved super type of a local type which may depend on type resolution.
* Therefore these types are treated differently from other types.
*/
protected IEObjectDescription findNestedTypeInLocalTypeNonResolving(JvmDeclaredType localType, QualifiedName name, String firstSegment, int dollarIndex) {
List<JvmMember> members = localType.getMembers();
for (int i = 0; i < members.size(); i++) {
JvmMember member = members.get(i);
if (member instanceof JvmDeclaredType) {
JvmDeclaredType nestedType = (JvmDeclaredType) member;
if (firstSegment.equals(nestedType.getSimpleName())) {
JvmType candidate = findNestedType(nestedType, 0, name);
if (candidate != null) {
return toDescription(name, candidate, dollarIndex, 0);
}
}
}
}
JvmDeclaredType superType = typeScopeProvider.getSuperTypeOfLocalTypeNonResolving(localType);
if (superType == null) {
return null;
}
return doGetSingleElement(superType, name, firstSegment, dollarIndex);
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class XtendImportedNamespaceScopeProvider method getResourceTypeScope.
private AbstractScope getResourceTypeScope(Resource resource, String packageName, AbstractScope parent) {
List<EObject> contents = resource.getContents();
List<JvmType> knownTypes = Lists.newArrayListWithExpectedSize(contents.size() - 1);
for (EObject content : contents) {
if (content instanceof JvmType) {
if (content instanceof JvmDeclaredType) {
if (Strings.equal(packageName, ((JvmDeclaredType) content).getPackageName())) {
knownTypes.add((JvmType) content);
}
} else {
knownTypes.add((JvmType) content);
}
}
}
if (knownTypes.isEmpty())
return parent;
return new KnownTypesScope(knownTypes, parent);
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class XtendSerializerScopeProvider method doCreateConstructorCallSerializationScope.
@Override
protected IScope doCreateConstructorCallSerializationScope(XConstructorCall context) {
if (context.eContainer() instanceof AnonymousClass) {
final AnonymousClass anonymousClass = (AnonymousClass) context.eContainer();
final JvmType superType = anonymousClassUtil.getSuperType(anonymousClass);
if (superType != null) {
return createAnonymousClassConstructorScope(context, superType);
}
}
return super.doCreateConstructorCallSerializationScope(context);
}
use of org.eclipse.xtext.common.types.JvmType in project xtext-xtend by eclipse.
the class XtendValidator method getParamTypes.
protected List<JvmType> getParamTypes(JvmOperation jvmOperation, boolean wrapPrimitives) {
List<JvmType> types = newArrayList();
for (JvmFormalParameter p : jvmOperation.getParameters()) {
LightweightTypeReference typeReference = toLightweightTypeReference(p.getParameterType());
if (wrapPrimitives) {
typeReference = typeReference.getWrapperTypeIfPrimitive();
}
types.add(typeReference.getType());
}
return types;
}
Aggregations