protected boolean isVisible(JvmType type) { if (type instanceof JvmMember) return getSession().isVisible((JvmMember) type); return true; // primitives et. al }
protected IFeatureScopeSession addExtensionsToMemberSession(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmDeclaredType type) { IEObjectDescription thisDescription = featureScopeSession.getLocalElement(IFeatureNames.THIS); if (thisDescription == null) { throw new IllegalStateException("Cannot find feature 'THIS'"); } JvmIdentifiableElement thisFeature = (JvmIdentifiableElement) thisDescription.getEObjectOrProxy(); IFeatureScopeSession childSession = addExtensionFieldsToMemberSession( resolvedTypes, featureScopeSession, type, thisFeature, Sets.<String>newHashSetWithExpectedSize(8), Sets.<JvmType>newHashSetWithExpectedSize(4)); XFeatureCall thisAccess = getXbaseFactory().createXFeatureCall(); thisAccess.setFeature(thisFeature); LightweightTypeReference thisType = resolvedTypes.getActualType(thisFeature); childSession = childSession.addToExtensionScope(Collections.<XExpression, LightweightTypeReference>singletonMap(thisAccess, thisType)); return childSession; }
@Override protected IFeatureScopeSession addThisTypeToStaticScope(IFeatureScopeSession session, JvmDeclaredType type) { return session.addTypesToStaticScope(Collections.singletonList(type), Collections.singletonList(type)); }
protected IFeatureScopeSession addThisAndSuper( IFeatureScopeSession session, ITypeReferenceOwner owner, JvmDeclaredType thisType, /* @Nullable */ JvmTypeReference superType, boolean addNestedTypes) { IFeatureScopeSession childSession = session; if (thisType.eContainer() != null) { if (thisType.isStatic()) { childSession = childSession.dropLocalElements(); } else { childSession = childSession.captureLocalElements(); } } if (superType != null && superType.getType() != null) { ImmutableMap.Builder<QualifiedName, JvmIdentifiableElement> builder = ImmutableMap.builder(); builder.put(IFeatureNames.THIS, thisType); builder.put(IFeatureNames.SUPER, superType.getType()); childSession = childSession.addLocalElements(builder.build(), owner); } else { childSession = childSession.addLocalElement(IFeatureNames.THIS, thisType, owner); } childSession = addThisTypeToStaticScope(childSession, thisType); if (addNestedTypes) childSession = childSession.addNestedTypesToScope(thisType); return childSession; }
if (featureScopeSession.isVisible(field) && seenNames.add(field.getSimpleName()) && isExtensionProvider(field)) { if (extensionProviders == null) { extensionProviders = Maps2.newLinkedHashMapWithExpectedSize(3); result = result.addToExtensionScope(extensionProviders);
/** * Computes the type of the given expression if it was not yet processed. * Used to compute types for expressions that are contained in heavily broken * models thus the model inferrer could not put them into proper contexts, or * for expressions that are dangling after an active annotation did its job in * an unexpected way. */ protected void computeDanglingExpressionType(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, XtendMember member, XExpression expression) { if (!allRootedExpressions.contains(expression)) { rootedInstances.add(expression); IFeatureScopeSession session = member == null || member.isStatic() ? featureScopeSession : featureScopeSession.toInstanceContext(); super.computeTypes(resolvedTypes, session, expression); } }
@Override protected List<IEObjectDescription> getLocalElementsByName(QualifiedName name) { XAbstractFeatureCall featureCall = getFeatureCall(); if (featureCall.isExplicitOperationCallOrBuilderSyntax()) return Collections.emptyList(); QualifiedName fqn = parentSegments.append(name); IScope typeScope = getSession().getScope(getFeatureCall(), TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, resolvedTypes); IEObjectDescription typeDescription = typeScope.getSingleElement(fqn); if (typeDescription != null) { EObject type = typeDescription.getEObjectOrProxy(); if (type instanceof JvmType) return Collections.<IEObjectDescription>singletonList(new TypeLiteralDescription( new AliasedEObjectDescription(name, typeDescription), isVisible((JvmType) type))); } return Collections.emptyList(); }
List<JvmType> literalClasses = implicitlyImportedFeatures.getStaticImportClasses(context); List<JvmType> extensionClasses = implicitlyImportedFeatures.getExtensionClasses(context); IFeatureScopeSession result = rootSession.addTypesToStaticScope(literalClasses, extensionClasses); if (context.getContents().isEmpty() || !(context instanceof XtextResource)) return result; final XImportSection importSection = importsConfig.getImportSection((XtextResource) context); if(importSection != null) { result = result.addImports(new ITypeImporter.Client() {
@SuppressWarnings("unused") protected void _computeTypes(Map<JvmIdentifiableElement, ResolvedTypes> preparedResolvedTypes, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmConstructor constructor) { ResolvedTypes childResolvedTypes = preparedResolvedTypes.get(constructor); if (childResolvedTypes == null) { if (preparedResolvedTypes.containsKey(constructor)) return; throw new IllegalStateException("No resolved type found. Constructor was: " + constructor.getIdentifier()); } else { preparedResolvedTypes.put(constructor, null); } ConstructorBodyComputationState state = new ConstructorBodyComputationState(childResolvedTypes, featureScopeSession.toInstanceContext().toConstructorContext(), constructor); addExtensionProviders(state, constructor.getParameters()); state.computeTypes(); computeAnnotationTypes(childResolvedTypes, featureScopeSession, constructor); computeLocalTypes(preparedResolvedTypes, childResolvedTypes, featureScopeSession, constructor); mergeChildTypes(childResolvedTypes); }
@Override public void addExtensionsToCurrentScope(List<? extends JvmIdentifiableElement> extensionProviders) { if (extensionProviders.isEmpty()) return; if (extensionProviders.size() == 1) { addExtensionToCurrentScope(extensionProviders.get(0)); return; } Map<XExpression, LightweightTypeReference> prototypeToType = Maps2.newLinkedHashMapWithExpectedSize(extensionProviders.size()); for(JvmIdentifiableElement extensionProvider: extensionProviders) { LightweightTypeReference knownType = getResolvedTypes().getActualType(extensionProvider); if (knownType != null && !knownType.isAny() && !knownType.isUnknown()) { XFeatureCall prototype = getResolver().getXbaseFactory().createXFeatureCall(); prototype.setFeature(extensionProvider); prototypeToType.put(prototype, knownType); } } if (!prototypeToType.isEmpty()) featureScopeSession = featureScopeSession.addToExtensionScope(prototypeToType); }
IEObjectDescription existingElement = featureScopeSession.getLocalElement(elementName); if (existingElement != null) { resolvedTypes.addDiagnostic(new EObjectDiagnosticImpl( featureScopeSession = featureScopeSession.addLocalElement(elementName, element, getReferenceOwner());
@Override public void addImports(ITypeImporter.Client importer) { featureScopeSession = featureScopeSession.addImports(importer); }
@Override public void assignType(QualifiedName name, JvmType rawType, LightweightTypeReference actualType) { resolvedTypes.reassignTypeWithoutMerge(rawType, actualType); featureScopeSession = featureScopeSession.addLocalElement(name, rawType, getReferenceOwner()); }
Map<XExpression, LightweightTypeReference> extensionProviders = null; for (final JvmField field : fields) { if (featureScopeSession.isVisible(field) && seenNames.add(field.getSimpleName()) && isExtensionProvider(field)) { if (extensionProviders == null) { extensionProviders = Maps2.newLinkedHashMapWithExpectedSize(3); result = result.addToExtensionScope(extensionProviders);
@SuppressWarnings("unused") protected void _computeTypes(Map<JvmIdentifiableElement, ResolvedTypes> preparedResolvedTypes, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmOperation operation) { ResolvedTypes childResolvedTypes = preparedResolvedTypes.get(operation); if (childResolvedTypes == null) { if (preparedResolvedTypes.containsKey(operation)) return; throw new IllegalStateException("No resolved type found. Operation was: " + operation.getIdentifier()); } else { preparedResolvedTypes.put(operation, null); } OperationBodyComputationState state = new OperationBodyComputationState(childResolvedTypes, operation.isStatic() ? featureScopeSession : featureScopeSession.toInstanceContext(), operation); addExtensionProviders(state, operation.getParameters()); markComputing(operation.getReturnType()); try { state.computeTypes(); } finally { unmarkComputing(operation.getReturnType()); } computeAnnotationTypes(childResolvedTypes, featureScopeSession, operation); computeLocalTypes(preparedResolvedTypes, childResolvedTypes, featureScopeSession, operation); mergeChildTypes(childResolvedTypes); }
QualifiedName qualifiedLinkName = qualifiedNameConverter.toQualifiedName(crossRefString); if (!qualifiedLinkName.isEmpty()) { final IScope scope = session.getScope(expression, reference, types); Iterable<IEObjectDescription> descriptions = scope.getElements(qualifiedLinkName); if (Iterables.isEmpty(descriptions)) {
@Override public void addExtensionToCurrentScope(JvmIdentifiableElement extensionProvider) { LightweightTypeReference knownType = getResolvedTypes().getActualType(extensionProvider); if (knownType != null && !knownType.isAny() && !knownType.isUnknown()) { XFeatureCall prototype = getResolver().getXbaseFactory().createXFeatureCall(); prototype.setFeature(extensionProvider); featureScopeSession = featureScopeSession.addToExtensionScope(Collections.<XExpression, LightweightTypeReference>singletonMap(prototype, knownType)); } }
protected boolean isVisible(JvmType type) { if (type instanceof JvmMember) return getSession().isVisible((JvmMember) type); return true; // primitives et. al }
preparedResolvedTypes.put(field, null); final FieldTypeComputationState state = new FieldTypeComputationState(childResolvedTypes, field.isStatic() ? featureScopeSession : featureScopeSession.toInstanceContext(), field); markComputing(field.getType()); try {
@Override public void addTypeToStaticImportScope(JvmDeclaredType type) { featureScopeSession = featureScopeSession.addTypesToStaticScope(Collections.<JvmType>singletonList(type), Collections.<JvmType>emptyList()); }