org.eclipse.xtext.xbase.scoping.batch.IFeatureScopeSession Java Examples
The following examples show how to use
org.eclipse.xtext.xbase.scoping.batch.IFeatureScopeSession.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
/** * Returns <code>null</code> if the given operation declares it's own return type or if it does not override * another operation. */ /* @Nullable */ @SuppressWarnings("unused") protected LightweightTypeReference getReturnTypeOfOverriddenOperation(JvmOperation operation, ResolvedTypes resolvedTypes, IFeatureScopeSession session) { if (operation.getVisibility() == JvmVisibility.PRIVATE) return null; if (InferredTypeIndicator.isInferred(operation.getReturnType())) { LightweightTypeReference declaringType = resolvedTypes.getActualType(operation.getDeclaringType()); if (declaringType == null) { throw new IllegalStateException("Cannot determine declaring type of operation: " + operation); } LightweightTypeReference result = overrideHelper.getReturnTypeOfOverriddenOperation(operation, declaringType); return result; } return null; }
Example #2
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected JvmTypeReference createComputedTypeReference( Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmMember member, /* @Nullable */ InferredTypeIndicator indicator, boolean returnType) { XComputedTypeReference result = getServices().getXtypeFactory().createXComputedTypeReference(); if (indicator == null || indicator.getExpression() == null) result.setTypeProvider(createTypeProvider(resolvedTypesByContext, resolvedTypes, featureScopeSession, member, returnType)); else result.setTypeProvider(createTypeProvider(resolvedTypesByContext, resolvedTypes, featureScopeSession, member, indicator.getExpression(), returnType)); // TODO do we need a lightweight computed type reference? // resolvedTypes.setType(member, result); return result; }
Example #3
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
/** * Initializes the type inference strategy for the cache field for create extensions. */ @Override protected void _doPrepare(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmField field, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext) { JvmTypeReference knownType = field.getType(); if (InferredTypeIndicator.isInferred(knownType)) { XComputedTypeReference castedKnownType = (XComputedTypeReference) knownType; EObject sourceElement = associations.getPrimarySourceElement(field); if (sourceElement instanceof XtendFunction) { XtendFunction function = (XtendFunction) sourceElement; if (function.getCreateExtensionInfo() != null) { JvmOperation operation = associations.getDirectlyInferredOperation(function); if (operation != null) { declareTypeParameters(resolvedTypes, field, resolvedTypesByContext); XComputedTypeReference fieldType = getServices().getXtypeFactory().createXComputedTypeReference(); fieldType.setTypeProvider(new CreateCacheFieldTypeReferenceProvider(operation, resolvedTypes, featureScopeSession)); castedKnownType.setEquivalent(fieldType); return; } } } } super._doPrepare(resolvedTypes, featureScopeSession, field, resolvedTypesByContext); doPrepareLocalTypes(resolvedTypesByContext.get(field), featureScopeSession, field, resolvedTypesByContext); }
Example #4
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@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); }
Example #5
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void computeAnnotationTypes(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, List<JvmAnnotationReference> annotations) { for(JvmAnnotationReference annotation: annotations) { EObject sourceElement = getSourceElement(annotation); if (sourceElement != annotation) { computeTypes(resolvedTypes, featureScopeSession, sourceElement); } else { for(JvmAnnotationValue value: annotation.getExplicitValues()) { if (value instanceof JvmCustomAnnotationValue) { JvmCustomAnnotationValue custom = (JvmCustomAnnotationValue) value; for(Object object: custom.getValues()) { if (object instanceof XExpression) { AnnotationValueTypeComputationState state = new AnnotationValueTypeComputationState(resolvedTypes, featureScopeSession, value, (XExpression) object); state.computeTypes(); } } } else if (value instanceof JvmAnnotationAnnotationValue) { computeAnnotationTypes(resolvedTypes, featureScopeSession, ((JvmAnnotationAnnotationValue) value).getValues()); } } } } }
Example #6
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@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); }
Example #7
Source File: RootExpressionTypeComputationState.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected RootExpressionTypeComputationState(StackedResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, AbstractTypeComputationState parent, XExpression expression, /* @Nullable */ LightweightTypeReference expectedType) { super(resolvedTypes, featureScopeSession, parent, expression); this.expectedType = expectedType; this.expectedReturnType = expectedType; }
Example #8
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void computeTypes(Map<JvmIdentifiableElement, ResolvedTypes> preparedResolvedTypes, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, EObject element) { if (element instanceof JvmDeclaredType) { _computeTypes(preparedResolvedTypes, resolvedTypes, featureScopeSession, (JvmDeclaredType) element); } else if (element instanceof JvmConstructor) { _computeTypes(preparedResolvedTypes, resolvedTypes, featureScopeSession, (JvmConstructor) element); } else if (element instanceof JvmField) { _computeTypes(preparedResolvedTypes, resolvedTypes, featureScopeSession, (JvmField) element); } else if (element instanceof JvmOperation) { _computeTypes(preparedResolvedTypes, resolvedTypes, featureScopeSession, (JvmOperation) element); } else { computeTypes(resolvedTypes, featureScopeSession, element); } }
Example #9
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@SuppressWarnings("unused") protected void _doPrepare(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmConstructor constructor, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext) { StackedResolvedTypes childResolvedTypes = declareTypeParameters(resolvedTypes, constructor, resolvedTypesByContext); JvmDeclaredType producedType = constructor.getDeclaringType(); LightweightTypeReference lightweightReference = childResolvedTypes.getReferenceOwner().toLightweightTypeReference(producedType); childResolvedTypes.setType(constructor, lightweightReference); }
Example #10
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void prepareMembers(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmDeclaredType type, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByType) { IFeatureScopeSession childSession = addExtensionsToMemberSession(resolvedTypes, featureScopeSession, type); StackedResolvedTypes childResolvedTypes = declareTypeParameters(resolvedTypes, type, resolvedTypesByType); JvmTypeReference superType = getExtendedClass(type); ITypeReferenceOwner referenceOwner = childResolvedTypes.getReferenceOwner(); if (superType != null) { LightweightTypeReference lightweightSuperType = referenceOwner.toLightweightTypeReference(superType); childResolvedTypes.reassignTypeWithoutMerge(superType.getType(), lightweightSuperType); /* * We use reassignType to make sure that the following works: * * StringList extends AbstractList<String> { * NestedIntList extends AbstractList<Integer> { * } * SubType extends StringList {} * } */ } LightweightTypeReference lightweightThisType = referenceOwner.toLightweightTypeReference(type); childResolvedTypes.reassignTypeWithoutMerge(type, lightweightThisType); List<JvmMember> members = type.getMembers(); int size = members.size(); for(int i = 0; i < size; i++) { doPrepare(childResolvedTypes, childSession, members.get(i), resolvedTypesByType); } }
Example #11
Source File: DefaultReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void computeTypes(ResolvedTypes resolvedTypes, IFeatureScopeSession session, EObject element) { if (element instanceof XExpression) { _computeTypes(resolvedTypes, session, (XExpression) element); } else { throw new IllegalArgumentException("element: " + element); } }
Example #12
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected AbstractReentrantTypeReferenceProvider createTypeProvider( Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmMember member, boolean returnType) { if (member instanceof JvmOperation) { JvmOperation operation = (JvmOperation) member; if (dispatchHelper.isDispatcherFunction(operation)) { return new DispatchReturnTypeReferenceProvider(operation, resolvedTypes, featureScopeSession, this); } } return super.createTypeProvider(resolvedTypesByContext, resolvedTypes, featureScopeSession, member, returnType); }
Example #13
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public InitializerParameterTypeReferenceProvider( JvmFormalParameter param, XtendFunction createFunction, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, XtendReentrantTypeResolver typeResolver) { this.param = param; this.createFunction = createFunction; this.resolvedTypesByContext = resolvedTypesByContext; this.resolvedTypes = resolvedTypes; this.featureScopeSession = featureScopeSession; this.typeResolver = typeResolver; }
Example #14
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override /* @Nullable */ protected JvmTypeReference doGetTypeReference(XComputedTypeReferenceImplCustom context) { try { CreateExtensionInfo createExtensionInfo = createFunction.getCreateExtensionInfo(); XExpression expression = createExtensionInfo.getCreateExpression(); LightweightTypeReference actualType = resolvedTypes.getReturnType(expression); if (actualType == null) { JvmOperation operation = typeResolver.associations.getDirectlyInferredOperation(createFunction); if (operation != null) { IFeatureScopeSession session = operation.isStatic() ? featureScopeSession : featureScopeSession.toInstanceContext(); typeResolver.computeTypes(resolvedTypesByContext, resolvedTypes, session, operation); actualType = resolvedTypes.getReturnType(expression); } } if (actualType == null) return null; // actualType may not be java compliant but still carry more information than the // java compliant reference JvmTypeReference result = typeResolver.toJavaCompliantTypeReference(actualType, featureScopeSession); if (actualType.isMultiType() || result.getType() != actualType.getType()) { resolvedTypes.setType(param, resolvedTypes.getReferenceOwner().toLightweightTypeReference(result)); resolvedTypes.reassignType(param, actualType); } return result; } finally { context.unsetTypeProviderWithoutNotification(); } }
Example #15
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected void computeTypes(ResolvedTypes resolvedTypes, IFeatureScopeSession session) { EObject root = getRoot(); if (root instanceof XtendTypeDeclaration) { computeTypes(resolvedTypes, session, root); } else { super.computeTypes(resolvedTypes, session); } }
Example #16
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected void computeTypes(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, EObject element) { if (element instanceof XtendTypeDeclaration) { if (element == getRoot()) { computeTypes(resolvedTypes, featureScopeSession, (XtendTypeDeclaration) element); } } else if (element instanceof XtendMember) { computeTypes(resolvedTypes, featureScopeSession, (XtendMember) element); } else { super.computeTypes(resolvedTypes, featureScopeSession, element); } }
Example #17
Source File: DefaultReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected IResolvedTypes resolve(CancelIndicator monitor) { operationCanceledManager.checkCanceled(monitor); if (isInvalidRoot()) { return IResolvedTypes.NULL; } RootResolvedTypes result = createResolvedTypes(monitor); IFeatureScopeSession session = batchScopeProvider.newSession(root.eResource()); computeTypes(result, session); result.resolveUnboundTypeParameters(); result.resolveProxies(); result.addDiagnostics(root.eResource()); result.processDeferredLogic(); return result; }
Example #18
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
/** * 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); } }
Example #19
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected AbstractReentrantTypeReferenceProvider createTypeProvider( Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmMember member, /* @Nullable */ XExpression expression, boolean returnType) { if (expression != null) { markToBeInferred(resolvedTypes, expression); return new DemandTypeReferenceProvider(member, expression, resolvedTypesByContext, resolvedTypes, featureScopeSession, returnType); } return new AnyTypeReferenceProvider(member, resolvedTypes, this); }
Example #20
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override protected void computeTypes(ResolvedTypes resolvedTypes, IFeatureScopeSession session) { EObject root = getRoot(); if (root instanceof JvmType) { Map<JvmIdentifiableElement, ResolvedTypes> preparedResolvedTypes = prepare(resolvedTypes, session); computeTypes(preparedResolvedTypes, resolvedTypes, session, root); } else { super.computeTypes(resolvedTypes, session); } }
Example #21
Source File: ScopeProviderAccess.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * Returns a bunch of descriptions most of which are actually {@link IIdentifiableElementDescription describing identifiables}. * The provided iterable is never empty but it may contain a single {@link ErrorDescription error description}. * * @return the available descriptions. */ public Iterable<IEObjectDescription> getCandidateDescriptions(XExpression expression, EReference reference, /* @Nullable */ EObject toBeLinked, IFeatureScopeSession session, IResolvedTypes types) throws IllegalNodeException { if (toBeLinked == null) { return Collections.emptyList(); } if (!toBeLinked.eIsProxy()) { throw new IllegalStateException(expression + " was already linked to " + toBeLinked); } URI uri = EcoreUtil.getURI(toBeLinked); String fragment = uri.fragment(); if (encoder.isCrossLinkFragment(expression.eResource(), fragment)) { INode node = encoder.getNode(expression, fragment); final EClass requiredType = reference.getEReferenceType(); if (requiredType == null) return Collections.emptyList(); final String crossRefString = linkingHelper.getCrossRefNodeAsString(node, true); if (crossRefString != null && !crossRefString.equals("")) { 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)) { INode errorNode = getErrorNode(expression, node); if (errorNode != node) { qualifiedLinkName = getErrorName(errorNode); } return Collections.<IEObjectDescription>singletonList(new ErrorDescription(getErrorNode(expression, node), qualifiedLinkName)); } return descriptions; } else { return Collections.<IEObjectDescription>singletonList(new ErrorDescription(null /* followUp problem */)); } } return Collections.emptyList(); } else { throw new IllegalStateException(expression + " uses unsupported uri fragment " + uri); } }
Example #22
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override protected void computeTypes(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, EObject element) { if (element instanceof JvmConstructor) { throw new IllegalStateException(); } else if (element instanceof JvmField) { throw new IllegalStateException(); } else if (element instanceof JvmOperation) { throw new IllegalStateException(); } else if (element instanceof JvmDeclaredType) { throw new IllegalStateException(); } else { super.computeTypes(resolvedTypes, featureScopeSession, element); } }
Example #23
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void computeLocalTypes( Map<JvmIdentifiableElement, ResolvedTypes> preparedResolvedTypes, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmFeature feature) { for(JvmGenericType localClass: feature.getLocalClasses()) { computeTypes(preparedResolvedTypes, resolvedTypes, featureScopeSession, localClass); } }
Example #24
Source File: DispatchOperationBodyComputationState.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public DispatchOperationBodyComputationState( ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmOperation operation, JvmOperation dispatcher, /* @Nullable */ LightweightTypeReference inheritedExpectedType) { super(resolvedTypes, featureScopeSession, operation); this.dispatcher = dispatcher; this.inheritedExpectedType = inheritedExpectedType; }
Example #25
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@SuppressWarnings("unused") protected void _computeTypes(Map<JvmIdentifiableElement, ResolvedTypes> preparedResolvedTypes, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmDeclaredType type) { ResolvedTypes childResolvedTypes = preparedResolvedTypes.get(type); if (childResolvedTypes == null) throw new IllegalStateException("No resolved type found. Type was: " + type.getIdentifier()); IFeatureScopeSession capturedState = LocalVariableCapturerImpl.findCapturedState(type); if (capturedState != null) { featureScopeSession = capturedState; } IFeatureScopeSession childSession = addThisAndSuper(featureScopeSession, childResolvedTypes.getReferenceOwner(), type); computeMemberTypes(preparedResolvedTypes, childResolvedTypes, childSession, type); computeAnnotationTypes(childResolvedTypes, featureScopeSession, type); mergeChildTypes(childResolvedTypes); }
Example #26
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void computeMemberTypes(Map<JvmIdentifiableElement, ResolvedTypes> preparedResolvedTypes, ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmDeclaredType type) { IFeatureScopeSession childSession = addExtensionsToMemberSession(resolvedTypes, featureScopeSession, type); List<JvmMember> members = type.getMembers(); for(int i = 0; i < members.size(); i++) { computeTypes(preparedResolvedTypes, resolvedTypes, childSession, members.get(i)); } }
Example #27
Source File: OperationBodyComputationState.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public OperationBodyComputationState(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmOperation operation) { super(resolvedTypes.pushExpectedExceptions(operation), featureScopeSession, operation); for(JvmFormalParameter parameter: operation.getParameters()) { addLocalToCurrentScope(parameter); } }
Example #28
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
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; }
Example #29
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected IFeatureScopeSession addExtensionFieldsToMemberSession( ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmDeclaredType type, JvmIdentifiableElement thisFeature, Set<String> seenNames, Set<JvmType> seenTypes) { if (seenTypes.add(type)) { Iterable<JvmField> fields = type.getDeclaredFields(); // collect local fields first, to populate the set of names Map<XExpression, LightweightTypeReference> extensionProviders = null; for(JvmField field: fields) { if (featureScopeSession.isVisible(field) && seenNames.add(field.getSimpleName()) && isExtensionProvider(field)) { if (extensionProviders == null) { extensionProviders = Maps2.newLinkedHashMapWithExpectedSize(3); } XAbstractFeatureCall extensionProvider = createExtensionProvider(thisFeature, field); LightweightTypeReference fieldType = resolvedTypes.getActualType(field); extensionProviders.put(extensionProvider, fieldType); } } // traverse the type hierarchy to create the feature scope sessions JvmTypeReference superType = getExtendedClass(type); IFeatureScopeSession result = featureScopeSession; if (superType != null) { result = addExtensionFieldsToMemberSession(resolvedTypes, featureScopeSession, (JvmDeclaredType) superType.getType(), thisFeature, seenNames, seenTypes); } if (extensionProviders != null) { result = result.addToExtensionScope(extensionProviders); } return result; } return featureScopeSession; }
Example #30
Source File: AbstractStackedTypeComputationState.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected AbstractStackedTypeComputationState( ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, AbstractTypeComputationState parent) { super(resolvedTypes, featureScopeSession); this.parent = parent; }