return new ConstructorTypeScopeWrapper(context, protectedIsVisible, IScope.NULLSCOPE) { @Override public Iterable<IEObjectDescription> getElements(EObject object) {
protected Iterable<IEObjectDescription> createFeatureDescriptions(Iterable<IEObjectDescription> original) { List<IEObjectDescription> result = Lists.newArrayListWithCapacity(3); for(IEObjectDescription description: original) { addFeatureDescriptions(description, result); } return result; }
@Override public Iterable<IEObjectDescription> getElements(QualifiedName name) { Iterable<IEObjectDescription> original = typeScope.getElements(name); return createFeatureDescriptions(original); }
protected void addFeatureDescriptions(IEObjectDescription typeDescription, List<IEObjectDescription> result) { EObject proxy = getResolvedProxy(typeDescription); if (!proxy.eIsProxy() && proxy instanceof JvmGenericType) { JvmGenericType type = (JvmGenericType) proxy; if (!type.isInterface()) { for(JvmConstructor constructor: type.getDeclaredConstructors()) { boolean visible = visibilityHelper.isVisible(constructor); ConstructorDescription constructorDescription = createConstructorDescription(typeDescription, constructor, visible); result.add(constructorDescription); } } else if (!strict) { result.add(new SimpleIdentifiableElementDescription(typeDescription)); } } else if (proxy instanceof JvmType) { if (!strict) result.add(new SimpleIdentifiableElementDescription(typeDescription)); } }
@Override public Iterable<IEObjectDescription> getElements(EObject object) { if (!(object instanceof JvmConstructor)) { return Collections.emptyList(); } JvmConstructor constructor = (JvmConstructor) object; Iterable<IEObjectDescription> typeDescriptions = typeScope.getElements(constructor.getDeclaringType()); List<IEObjectDescription> result = Lists.newArrayListWithCapacity(3); boolean visible = visibilityHelper.isVisible(constructor); for(IEObjectDescription typeDescription: typeDescriptions) { ConstructorDescription constructorDescription = createConstructorDescription(typeDescription, constructor, visible); result.add(constructorDescription); } return result; }
protected IScope doCreateConstructorCallSerializationScope(XConstructorCall context) { IScope typeScope = getScope(context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE); ConstructorTypeScopeWrapper result = new ConstructorTypeScopeWrapper(context, IVisibilityHelper.ALL, typeScope); return result; }
protected IScope createAnonymousClassConstructorScope(EObject context, final JvmType superType) { final IScope typeScope = getScope(context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE); ConstructorTypeScopeWrapper result = new ConstructorTypeScopeWrapper(context, IVisibilityHelper.ALL, typeScope) { @Override public Iterable<IEObjectDescription> getElements(EObject object) { if (!(object instanceof JvmConstructor)) { return Collections.emptyList(); } JvmConstructor constructor = (JvmConstructor) object; Iterable<IEObjectDescription> typeDescriptions = typeScope.getElements(superType); List<IEObjectDescription> result = Lists.newArrayListWithCapacity(3); for(IEObjectDescription typeDescription: typeDescriptions) { result.add(EObjectDescription.create(typeDescription.getName(), constructor)); } return result; } }; return result; }
/** * Creates the constructor scope for {@link XConstructorCall}. * The scope will likely contain descriptions for {@link JvmConstructor constructors}. * If there is not constructor declared, it may contain {@link JvmType types}. * * @param session the currently available visibilityHelper data * @param reference the reference that will hold the resolved constructor * @param resolvedTypes the currently known resolved types */ public IScope createConstructorScope(EObject context, EReference reference, IFeatureScopeSession session, IResolvedTypes resolvedTypes) { if (!(context instanceof XConstructorCall)) { return IScope.NULLSCOPE; } /* * We use a type scope here in order to provide better feedback for users, * e.g. if the constructor call refers to an interface or a primitive. */ final IScope delegateScope = typeScopes.createTypeScope(context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, session, resolvedTypes); IScope result = new ConstructorTypeScopeWrapper(context, session, delegateScope); return result; }
IScope result = new ConstructorTypeScopeWrapper(context, IVisibilityHelper.ALL, typeScope, true /* strict scope */); return result; } else {