public IScope getScope(Resource resource, EReference reference, Predicate<IEObjectDescription> filter) { if (resource == null) throw new IllegalStateException("context must be contained in a resource"); ResourceSet resourceSet = resource.getResourceSet(); if (resourceSet == null) throw new IllegalStateException("context must be contained in a resource set"); EClass referenceType = reference.getEReferenceType(); if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_TYPE, referenceType)) { IJvmTypeProvider typeProvider = getTypeProvider(resourceSet); return createTypeScope(typeProvider, filter); } else if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_CONSTRUCTOR, referenceType)) { IJvmTypeProvider typeProvider = getTypeProvider(resourceSet); return createConstructorScope(typeProvider, filter); } else { return IScope.NULLSCOPE; } }
public IScope getScope(Resource resource, EReference reference) { return getScope(resource, reference, null); }
public IJvmTypeProvider getTypeProvider(ResourceSet resourceSet) { IJvmTypeProvider typeProvider = getTypeProviderFactory().findOrCreateTypeProvider(resourceSet); return typeProvider; }
@Override public AbstractScope get() { IJvmTypeProvider typeProvider = typeScopeProvider.getTypeProvider(resource.getResourceSet()); AbstractTypeScope typeScope = typeScopeProvider.createTypeScope(typeProvider, null); IResourceDescriptions descriptions = resourceDescriptionsProvider.getResourceDescriptions(context.eResource().getResourceSet()); IResourceDescription resourceDescription = descriptions.getResourceDescription(resource.getURI()); if (resourceDescription != null) { typeScope = new LocalResourceFilteringTypeScope(typeScope, resourceDescription); } RecordingTypeScope recordingTypeScope = new RecordingTypeScope(typeScope, getImportedNamesSet(resource), getQualifiedNameConverter()); AbstractScope rootTypeScope = getRootTypeScope(xtendFile, recordingTypeScope); AbstractScope importScope = getImportScope(xtendFile.getImportSection(), rootTypeScope, recordingTypeScope); AbstractScope localTypes = getResourceTypeScope(xtendFile.eResource(), xtendFile.getPackage(), importScope); AbstractScope primitiveAware = new PrimitiveAwareScope(localTypes, typeScope); AbstractScope caching = new CachingTypeScope(primitiveAware); return caching; } });
public JvmType getFactoryType(EObject ctx) { ResourceSet resourceSet = ctx.eResource().getResourceSet(); String factoryName = IFactory.class.getName(); IJvmTypeProvider typeProvider = typeScopeProvider.getTypeProvider(resourceSet); return typeProvider.findTypeByName(factoryName); } }
public IScope createMemberScope(JvmType containerType, Predicate<JvmMember> filter, Function<JvmMember, QualifiedName> names, IScope outer) { if (containerType == null || containerType.eIsProxy()) return outer; if (containerType instanceof JvmDeclaredType) { IScope result = outer; List<JvmTypeReference> superTypes = ((JvmDeclaredType) containerType).getSuperTypes(); for(JvmTypeReference superType: superTypes) { if (superType.getType() != null) result = createMemberScope(superType.getType(), filter, names, result); } List<JvmMember> members = ((JvmDeclaredType) containerType).getMembers(); return Scopes.scopeFor(Iterables.filter(members, filter), names, result); } return outer; }
if (context instanceof XImportDeclaration) { Resource resource = context.eResource(); IJvmTypeProvider typeProvider = typeScopeProvider.getTypeProvider(resource.getResourceSet()); AbstractTypeScope typeScope = typeScopeProvider.createTypeScope(typeProvider, null); IResourceDescriptions descriptions = resourceDescriptionsProvider.getResourceDescriptions(context.eResource().getResourceSet()); IResourceDescription resourceDescription = descriptions.getResourceDescription(resource.getURI());
public IScope createMemberScope(JvmType containerType, Predicate<JvmMember> filter, Function<JvmMember, QualifiedName> names, IScope outer) { if (containerType == null || containerType.eIsProxy()) return outer; if (containerType instanceof JvmDeclaredType) { IScope result = outer; List<JvmTypeReference> superTypes = ((JvmDeclaredType) containerType).getSuperTypes(); for(JvmTypeReference superType: superTypes) { if (superType.getType() != null) result = createMemberScope(superType.getType(), filter, names, result); } List<JvmMember> members = ((JvmDeclaredType) containerType).getMembers(); return Scopes.scopeFor(Iterables.filter(members, filter), names, result); } return outer; }
@Override public IScope getScope(Resource resource, EReference reference, Predicate<IEObjectDescription> filter) { if (resource == null) throw new IllegalStateException("context must be contained in a resource"); ResourceSet resourceSet = resource.getResourceSet(); if (resourceSet == null) throw new IllegalStateException("context must be contained in a resource set"); EClass referenceType = reference.getEReferenceType(); if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_TYPE, referenceType)) { IJvmTypeProvider typeProvider = getTypeProvider(resourceSet); return createTypeScope(typeProvider, filter); } else if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_CONSTRUCTOR, referenceType)) { IJvmTypeProvider typeProvider = getTypeProvider(resourceSet); return createConstructorScope(typeProvider, filter); } else { return IScope.NULLSCOPE; } }
public IScope getScope(Resource resource, EReference reference) { return getScope(resource, reference, null); }
public IJvmTypeProvider getTypeProvider(ResourceSet resourceSet) { IJvmTypeProvider typeProvider = getTypeProviderFactory().findOrCreateTypeProvider(resourceSet); return typeProvider; }
@Override public IScope getScope(Resource resource, EReference reference, Predicate<IEObjectDescription> filter) { EClass referenceType = getEReferenceType(resource, reference); if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_TYPE, referenceType)) { return typeScopeProvider.getScope(resource, reference, filter); } if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_CONSTRUCTOR, referenceType)) { return typeScopeProvider.getScope(resource, reference, filter); } return super.getScope(resource, reference, filter); }
@Override public IScope getScope(Resource resource, EReference reference, Predicate<IEObjectDescription> filter) { EClass referenceType = getEReferenceType(resource, reference); if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_TYPE, referenceType)) { return typeScopeProvider.getScope(resource, reference, filter); } if (EcoreUtil2.isAssignableFrom(TypesPackage.Literals.JVM_CONSTRUCTOR, referenceType)) { return typeScopeProvider.getScope(resource, reference, filter); } return super.getScope(resource, reference, filter); }