org.eclipse.xtext.xbase.typesystem.internal.ResolvedTypes Java Examples
The following examples show how to use
org.eclipse.xtext.xbase.typesystem.internal.ResolvedTypes.
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: 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 #2
Source File: TypeComputationStateTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public void computeTypes(XExpression expression, ITypeComputationState state) { try { assertTrue("state is instanceof ExpressionTypeComputationState", (state instanceof ExpressionTypeComputationState)); LightweightTypeReference expectedType = getFirst(state.getExpectations(), null).getExpectedType(); if (expression instanceof XNullLiteral) { ExpressionTypeComputationState casted = ((ExpressionTypeComputationState) state); ResolvedTypes resolution = reflectExtensions.get(casted, "resolvedTypes"); ResolvedTypes parentResolution = reflectExtensions .get(reflectExtensions.<ExpressionTypeComputationState> get(casted, "parent"), "resolvedTypes"); assertNull(parentResolution.getActualType(((XExpression) ((XNullLiteral) expression).eContainer()))); state.acceptActualType(expectedType); assertNull(parentResolution.getActualType(expression)); assertEquals(expectedType.getIdentifier(), resolution.getActualType(expression).getIdentifier()); assertNull(parentResolution.getActualType(((XExpression) ((XNullLiteral) expression).eContainer()))); } else { assertTrue((expression instanceof XBlockExpression)); XNullLiteral nullLiteral = ((XNullLiteral) getFirst(expression.eContents(), null)); state.computeTypes(nullLiteral); ResolvedTypes res = reflectExtensions.get(state, "resolvedTypes"); assertEquals(expectedType.getIdentifier(), res.getActualType(nullLiteral).getIdentifier()); } } catch (IllegalAccessException | SecurityException | NoSuchFieldException | IllegalArgumentException e) { throw Exceptions.sneakyThrow(e); } }
Example #3
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public DispatchParameterTypeReferenceProvider( JvmOperation operation, int idx, ResolvedTypes resolvedTypes, IFeatureScopeSession session, XtendReentrantTypeResolver typeResolver) { this.idx = idx; this.operation = operation; this.resolvedTypes = resolvedTypes; this.session = session; this.typeResolver = typeResolver; }
Example #4
Source File: SuspiciousOverloadedCastOperatorLinkingCandidate.java From sarl with Apache License 2.0 | 5 votes |
@Override public void applyToComputationState() { final ResolvedTypes types = getChosenCandidate().getState().getResolvedTypes(); try { this.reflect.invoke(types, "reassignLinkingInformation", this.chosenCandidate.getExpression(), this); //$NON-NLS-1$ } catch (Throwable exception) { throw new Error(exception); } getChosenCandidate().applyToComputationState(); }
Example #5
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 #6
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override 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); } BottomResolvedOperation resolvedOperation = new BottomResolvedOperation(operation, declaringType, overrideTester); List<IResolvedOperation> overriddenMethods = resolvedOperation.getOverriddenAndImplementedMethods(); if (overriddenMethods.isEmpty()) return null; IResolvedOperation overriddenMethod = overriddenMethods.get(0); JvmOperation declaration = overriddenMethod.getDeclaration(); XExpression inferredFrom = getInferredFrom(declaration.getReturnType()); // guard against active annotations that put an expression into a second method // namely in a synthesized super type - in that case, the expression should not be // inferred in the context of the super type but the subtype thus the return type // of a super method has to be ignored // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=439535 if (inferredFrom != null && (inferredFrom == getInferredFrom(operation.getReturnType()) || isHandled(inferredFrom))) { return null; } LightweightTypeReference result = overriddenMethod.getResolvedReturnType(); return result; } return null; }
Example #7
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 #8
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected LightweightTypeReference normalizeDispatchReturnType(LightweightTypeReference declaredType, List<LightweightTypeReference> computedTypes, LightweightTypeReference implicitVoidOrNull, LightweightTypeReference thrownVoidOrNull, ResolvedTypes resolvedTypes) { LightweightTypeReference result = null; if (declaredType != null) { result = declaredType; } else { if (implicitVoidOrNull != null && !computedTypes.isEmpty()) { List<LightweightTypeReference> wrapped = Lists.newArrayListWithCapacity(computedTypes.size()); for(int i = 0; i < computedTypes.size(); i++) { wrapped.add(computedTypes.get(i).getWrapperTypeIfPrimitive()); } computedTypes = wrapped; } if (computedTypes.isEmpty() && implicitVoidOrNull != null) { result = implicitVoidOrNull; } else { if (computedTypes.isEmpty()) { if (thrownVoidOrNull == null) { throw new IllegalStateException("thrownVoidOrNull may not be null in this situation"); } result = thrownVoidOrNull; } else { result = getServices().getTypeConformanceComputer().getCommonSuperType(computedTypes, resolvedTypes.getReferenceOwner()); } } } return result; }
Example #9
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 #10
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected void computeTypes(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, XtendTypeDeclaration typeDeclaration) { computeXtendAnnotationTypes(resolvedTypes, featureScopeSession, typeDeclaration.getAnnotations()); for (XtendMember member : typeDeclaration.getMembers()) { computeTypes(resolvedTypes, featureScopeSession, member); } }
Example #11
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 #12
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 #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 |
public DispatchReturnTypeReferenceProvider( JvmOperation operation, ResolvedTypes resolvedTypes, IFeatureScopeSession session, XtendReentrantTypeResolver typeResolver) { this.operation = operation; this.resolvedTypes = resolvedTypes; this.session = session; this.typeResolver = typeResolver; }
Example #15
Source File: ValidatingStackedResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public ValidatingStackedResolvedTypes(ResolvedTypes parent) { super(parent); }
Example #16
Source File: ValidatingReassigningResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public ValidatingReassigningResolvedTypes(ResolvedTypes parent) { super(parent); }
Example #17
Source File: SARLReentrantTypeResolver.java From sarl with Apache License 2.0 | 4 votes |
@Override protected IFeatureScopeSession addExtensionFieldsToMemberSession( ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmDeclaredType type, JvmIdentifiableElement thisFeature, Set<String> seenNames, Set<JvmType> seenTypes) { // Overriding for capacity call redirection if (seenTypes.add(type)) { final Iterable<JvmField> fields = type.getDeclaredFields(); 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); } // Sarl specific block of code XAbstractFeatureCall extensionProvider = createSarlCapacityExtensionProvider(thisFeature, field); final LightweightTypeReference fieldType; if (extensionProvider == null) { extensionProvider = createExtensionProvider(thisFeature, field); fieldType = resolvedTypes.getActualType(field); } else { fieldType = getSarlCapacityFieldType(resolvedTypes, field); } // End of Sarl specific extensionProviders.put(extensionProvider, fieldType); } } // traverse the type hierarchy to create the feature scope sessions final 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 #18
Source File: TimedReassigningResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public TimedReassigningResolvedTypes(ResolvedTypes parent, TypeResolutionTimes times) { super(parent); this.times = times; }
Example #19
Source File: TimedStackedResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public TimedStackedResolvedTypes(ResolvedTypes parent, TypeResolutionTimes times) { super(parent); this.times = times; }
Example #20
Source File: ValidatingExpressionAwareResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public ValidatingExpressionAwareResolvedTypes(ResolvedTypes parent, XExpression expression) { super(parent, expression); }
Example #21
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override protected void _doPrepare(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmConstructor constructor, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext) { super._doPrepare(resolvedTypes, featureScopeSession, constructor, resolvedTypesByContext); doPrepareLocalTypes(resolvedTypesByContext.get(constructor), featureScopeSession, constructor, resolvedTypesByContext); }
Example #22
Source File: TimedExpressionAwareResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public TimedExpressionAwareResolvedTypes(ResolvedTypes parent, XExpression expression, TypeResolutionTimes times) { super(parent, expression); this.times = times; }
Example #23
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
protected void computeXtendAnnotationTypes(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, List<XAnnotation> annotations) { for (XAnnotation annotation : annotations) { computeDanglingExpressionType(resolvedTypes, featureScopeSession, null, annotation); } }
Example #24
Source File: PublicStackedResolvedTypes.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public PublicStackedResolvedTypes(final ResolvedTypes parent) { super(parent); }
Example #25
Source File: PublicStackedResolvedTypes.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
public PublicStackedResolvedTypes(ResolvedTypes parent) { super(parent); }
Example #26
Source File: ClosureTypeComputerUnitTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected TestableState(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession) { super(resolvedTypes, featureScopeSession); }
Example #27
Source File: ClosureTypeComputerUnitTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override protected LightweightTypeReference acceptType(ResolvedTypes types, AbstractTypeExpectation expectation, LightweightTypeReference type, boolean returnType, int conformanceHint) { throw new UnsupportedOperationException(); }
Example #28
Source File: ClosureTypeComputerUnitTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override protected LightweightTypeReference acceptType(XExpression alreadyHandled, ResolvedTypes types, AbstractTypeExpectation expectation, LightweightTypeReference type, boolean returnType, int conformanceHint) { throw new UnsupportedOperationException(); }
Example #29
Source File: XtendReentrantTypeResolver.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public CreateCacheFieldTypeReferenceProvider(JvmOperation createOperation, ResolvedTypes resolvedTypes, IFeatureScopeSession session) { this.createOperation = createOperation; this.resolvedTypes = resolvedTypes; this.session = session; }
Example #30
Source File: PublicStackedResolvedTypes.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public PublicStackedResolvedTypes(ResolvedTypes parent) { super(parent); }