org.eclipse.xtext.xtype.XComputedTypeReference Java Examples
The following examples show how to use
org.eclipse.xtext.xtype.XComputedTypeReference.
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: 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: InferredTypeIndicator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public static boolean isInferred(JvmTypeReference typeReference) { if (typeReference instanceof XComputedTypeReference) { IJvmTypeReferenceProvider typeProvider = ((XComputedTypeReference) typeReference).getTypeProvider(); if (typeProvider instanceof InferredTypeIndicator && !((InferredTypeIndicator)typeProvider).resolved) { return true; } } return false; }
Example #4
Source File: SARLValidator.java From sarl with Apache License 2.0 | 5 votes |
/** This function is overridden in order to add "isIgnore" invocation. * {@inheritDoc} */ @Override @SuppressWarnings("checkstyle:nestedifdepth") protected void validateInferredType(JvmTypeReference inferredType, XtendMember member, String messagePrefix, EAttribute location) { if (inferredType != null) { final TreeIterator<EObject> iterator = EcoreUtil2.eAll(inferredType); while (iterator.hasNext()) { final EObject next = iterator.next(); if (next instanceof JvmParameterizedTypeReference) { final JvmParameterizedTypeReference candidate = (JvmParameterizedTypeReference) next; final JvmType type = candidate.getType(); if (type instanceof JvmGenericType && !((JvmGenericType) type).getTypeParameters().isEmpty()) { if (candidate.getArguments().isEmpty()) { StringBuilder message = new StringBuilder(messagePrefix); message = this.proxyAwareUIStrings.visit(inferredType, message); if (message != null && !isIgnored(org.eclipse.xtext.xbase.validation.IssueCodes.RAW_TYPE)) { StringBuilder msg2 = new StringBuilder(); msg2 = this.proxyAwareUIStrings.appendTypeSignature(type, msg2); final String m = MessageFormat.format(Messages.SARLValidator_6, message.toString(), type.getSimpleName(), msg2.toString()); addIssue(m.toString(), member, location, org.eclipse.xtext.xbase.validation.IssueCodes.RAW_TYPE); } return; } } } else if (next instanceof XComputedTypeReference) { validateInferredType(((XComputedTypeReference) next).getEquivalent(), member, messagePrefix, location); iterator.prune(); } } } }
Example #5
Source File: ConstantExpressionsInterpreter.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public Object evaluate(final XExpression expression, final JvmTypeReference expectedType) { final ClassLoader classLoader = this.classLoaderProvider.getClassLoader(expression); final Map<String, JvmIdentifiableElement> visibleFeatures = this.findVisibleFeatures(expression); JvmTypeReference _xifexpression = null; if ((expectedType instanceof XComputedTypeReference)) { _xifexpression = null; } else { _xifexpression = expectedType; } ClassFinder _classFinder = new ClassFinder(classLoader); LinkedHashSet<XExpression> _newLinkedHashSet = CollectionLiterals.<XExpression>newLinkedHashSet(); Context _context = new Context(_xifexpression, _classFinder, visibleFeatures, _newLinkedHashSet); final Object result = this.evaluate(expression, _context); return result; }
Example #6
Source File: XtendValidator.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected void validateInferredType(JvmTypeReference inferredType, XtendMember member, String messagePrefix, EAttribute location) { if (inferredType != null) { TreeIterator<EObject> iterator = EcoreUtil2.eAll(inferredType); while(iterator.hasNext()) { EObject next = iterator.next(); if (next instanceof JvmParameterizedTypeReference) { JvmParameterizedTypeReference candidate = (JvmParameterizedTypeReference) next; JvmType type = candidate.getType(); if (type instanceof JvmGenericType && !((JvmGenericType) type).getTypeParameters().isEmpty()) { if (candidate.getArguments().isEmpty()) { StringBuilder message = new StringBuilder(messagePrefix); message = proxyAwareUIStrings.visit(inferredType, message); if (message != null) { message.append(" uses the raw type "); message.append(type.getSimpleName()); message.append(". References to generic type "); message = proxyAwareUIStrings.appendTypeSignature(type, message); message.append(" should be parameterized"); warning(message.toString(), member, location, org.eclipse.xtext.xbase.validation.IssueCodes.RAW_TYPE); } return; } } } else if (next instanceof XComputedTypeReference) { validateInferredType(((XComputedTypeReference) next).getEquivalent(), member, messagePrefix, location); iterator.prune(); } } } }
Example #7
Source File: BatchLinkableResourceStorageWritable.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override protected Object beforeSaveEObject(final InternalEObject object, final BinaryResourceImpl.EObjectOutputStream writable) throws IOException { JvmType _xblockexpression = null; { super.beforeSaveEObject(object, writable); JvmType _xifexpression = null; if ((object instanceof XComputedTypeReference)) { _xifexpression = ((XComputedTypeReference)object).getType(); } _xblockexpression = _xifexpression; } return _xblockexpression; }
Example #8
Source File: UnboundTypeReference.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public JvmTypeReference toTypeReference() { if (internalGetResolvedTo() != null) { return resolvedTo.toTypeReference(); } XComputedTypeReference result = getServices().getXtypeFactory().createXComputedTypeReference(); result.setTypeProvider(new UnboundTypeReferenceResolver(this)); return result; }
Example #9
Source File: LightweightTypeReferenceFactory.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override public LightweightTypeReference doVisitComputedTypeReference(XComputedTypeReference reference) { IJvmTypeReferenceProvider typeProvider = reference.getTypeProvider(); if (typeProvider instanceof UnboundTypeReferenceResolver) { UnboundTypeReference typeReference = ((UnboundTypeReferenceResolver) typeProvider).getUnboundTypeReference(); return typeReference.copyInto(owner); } JvmTypeReference equivalent = reference.getEquivalent(); if (equivalent == null) return owner.newUnknownTypeReference(); return super.doVisitComputedTypeReference(reference); }
Example #10
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected void requestCapturedLocalVariables(JvmTypeReference toBeWrapped, JvmDeclaredType type, ResolvedTypes resolvedTypes, Map<JvmIdentifiableElement, ResolvedTypes> resolvedTypesByContext, IAcceptor<JvmTypeReference> result) { LocalVariableCapturerImpl capturer = new LocalVariableCapturerImpl(toBeWrapped, type, this, resolvedTypes, resolvedTypesByContext); XComputedTypeReference ref = getServices().getXtypeFactory().createXComputedTypeReference(); ref.setTypeProvider(capturer); result.accept(ref); capturer.awaitCapturing(); }
Example #11
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * Returns the expression that will be used to infer the given type from. If the type is * already resolved, the result will be null. If no expression can be determined, null is * also returned. */ protected XExpression getInferredFrom(JvmTypeReference typeReference) { if (InferredTypeIndicator.isInferred(typeReference)) { XComputedTypeReference computed = (XComputedTypeReference) typeReference; if (computed.getEquivalent() instanceof XComputedTypeReference) { XComputedTypeReference inferred = (XComputedTypeReference) computed.getEquivalent(); IJvmTypeReferenceProvider typeProvider = inferred.getTypeProvider(); if (typeProvider instanceof DemandTypeReferenceProvider) { return ((DemandTypeReferenceProvider) typeProvider).expression; } } } return null; }
Example #12
Source File: LogicalContainerAwareReentrantTypeResolver.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected AbstractDemandTypeReferenceProvider getComputedTypeReference(JvmTypeReference knownType) { if (InferredTypeIndicator.isInferred(knownType)) { XComputedTypeReference casted = (XComputedTypeReference) knownType; JvmTypeReference equivalent = casted.getEquivalent(); if (equivalent instanceof XComputedTypeReference) { IJvmTypeReferenceProvider typeProvider = ((XComputedTypeReference) equivalent).getTypeProvider(); if (typeProvider instanceof AbstractDemandTypeReferenceProvider) { return (AbstractDemandTypeReferenceProvider) typeProvider; } } } return null; }
Example #13
Source File: LocalVariableCapturer.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected static <R extends LocalVariableCapturer> R findLocalClassSupertype(JvmTypeReference typeReference) { if (InferredTypeIndicator.isInferred(typeReference)) { JvmTypeReference equivalent = ((XComputedTypeReference) typeReference).getEquivalent(); return findLocalClassSupertype(equivalent); } if (typeReference instanceof XComputedTypeReference) { IJvmTypeReferenceProvider typeProvider = ((XComputedTypeReference) typeReference).getTypeProvider(); if (typeProvider instanceof LocalVariableCapturer) { @SuppressWarnings("unchecked") R result = (R) typeProvider; return result; } } return null; }
Example #14
Source File: InferredTypeIndicator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public static void resolveTo(JvmTypeReference inferred, JvmTypeReference resolved) { if (isInferred(inferred)) { XComputedTypeReference casted = (XComputedTypeReference) inferred; casted.setEquivalent(resolved); ((InferredTypeIndicator)casted.getTypeProvider()).resolved = true; } else { throw new IllegalStateException("Cannot resolve a reference that is not inferred"); } }
Example #15
Source File: AbstractXtypeReferenceVisitor.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override public Result doVisitComputedTypeReference(XComputedTypeReference reference) { return doVisitSpecializedTypeReference(reference); }
Example #16
Source File: AbstractXtypeReferenceVisitorWithParameter.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override public Result doVisitComputedTypeReference(XComputedTypeReference reference, Parameter param) { return doVisitSpecializedTypeReference(reference, param); }
Example #17
Source File: XtypePackageImpl.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
/** * Complete the initialization of the package and its meta-model. This * method is guarded to have no affect on any invocation but its first. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void initializePackageContents() { if (isInitialized) return; isInitialized = true; // Initialize package setName(eNAME); setNsPrefix(eNS_PREFIX); setNsURI(eNS_URI); // Obtain other dependent packages TypesPackage theTypesPackage = (TypesPackage)EPackage.Registry.INSTANCE.getEPackage(TypesPackage.eNS_URI); // Create type parameters // Set bounds for type parameters // Add supertypes to classes xFunctionTypeRefEClass.getESuperTypes().add(theTypesPackage.getJvmSpecializedTypeReference()); xComputedTypeReferenceEClass.getESuperTypes().add(theTypesPackage.getJvmSpecializedTypeReference()); // Initialize classes and features; add operations and parameters initEClass(xFunctionTypeRefEClass, XFunctionTypeRef.class, "XFunctionTypeRef", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEReference(getXFunctionTypeRef_ParamTypes(), theTypesPackage.getJvmTypeReference(), null, "paramTypes", null, 0, -1, XFunctionTypeRef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getXFunctionTypeRef_ReturnType(), theTypesPackage.getJvmTypeReference(), null, "returnType", null, 0, 1, XFunctionTypeRef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getXFunctionTypeRef_Type(), theTypesPackage.getJvmType(), null, "type", null, 0, 1, XFunctionTypeRef.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEAttribute(getXFunctionTypeRef_InstanceContext(), ecorePackage.getEBoolean(), "instanceContext", null, 0, 1, XFunctionTypeRef.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(xComputedTypeReferenceEClass, XComputedTypeReference.class, "XComputedTypeReference", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getXComputedTypeReference_TypeProvider(), this.getIJvmTypeReferenceProvider(), "typeProvider", null, 0, 1, XComputedTypeReference.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(xImportSectionEClass, XImportSection.class, "XImportSection", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEReference(getXImportSection_ImportDeclarations(), this.getXImportDeclaration(), null, "importDeclarations", null, 0, -1, XImportSection.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(xImportDeclarationEClass, XImportDeclaration.class, "XImportDeclaration", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getXImportDeclaration_Wildcard(), ecorePackage.getEBoolean(), "wildcard", null, 0, 1, XImportDeclaration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getXImportDeclaration_Extension(), ecorePackage.getEBoolean(), "extension", null, 0, 1, XImportDeclaration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getXImportDeclaration_Static(), ecorePackage.getEBoolean(), "static", null, 0, 1, XImportDeclaration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getXImportDeclaration_ImportedType(), theTypesPackage.getJvmDeclaredType(), null, "importedType", null, 0, 1, XImportDeclaration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getXImportDeclaration_MemberName(), ecorePackage.getEString(), "memberName", null, 0, 1, XImportDeclaration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getXImportDeclaration_ImportedNamespace(), ecorePackage.getEString(), "importedNamespace", null, 0, 1, XImportDeclaration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); addEOperation(xImportDeclarationEClass, ecorePackage.getEString(), "getImportedName", 0, 1, IS_UNIQUE, IS_ORDERED); addEOperation(xImportDeclarationEClass, ecorePackage.getEString(), "getImportedTypeName", 0, 1, IS_UNIQUE, IS_ORDERED); // Initialize data types initEDataType(iJvmTypeReferenceProviderEDataType, IJvmTypeReferenceProvider.class, "IJvmTypeReferenceProvider", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); // Create resource createResource(eNS_URI); }
Example #18
Source File: ProxyAwareUIStrings.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Override public StringBuilder doVisitComputedTypeReference(XComputedTypeReference reference, StringBuilder param) { return doVisitSpecializedTypeReference(reference, param); }
Example #19
Source File: JvmTypesBuilder.java From xtext-extras with Eclipse Public License 2.0 | 3 votes |
/** * Produces an inferred type which will be resolved on demand. It should not be attempted to resolve * this type during the model inference. * * @param expression the expression that will be used resolve the type. May not be <code>null</code>. * @return an inferred type. */ public JvmTypeReference inferredType(XExpression expression) { Preconditions.checkNotNull(expression); XComputedTypeReference result = xtypesFactory.createXComputedTypeReference(); result.setTypeProvider(new InferredTypeIndicator(expression)); return result; }
Example #20
Source File: JvmTypesBuilder.java From xtext-extras with Eclipse Public License 2.0 | 2 votes |
/** * Produces an inferred type which will be resolved on demand. It should not be attempted to resolve * this type during the model inference. * * @return an inferred type. */ public JvmTypeReference inferredType() { XComputedTypeReference result = xtypesFactory.createXComputedTypeReference(); result.setTypeProvider(new InferredTypeIndicator(null)); return result; }
Example #21
Source File: XtypeReferenceVisitorWithParameter.java From xtext-extras with Eclipse Public License 2.0 | votes |
Result doVisitComputedTypeReference(XComputedTypeReference reference, Parameter param);
Example #22
Source File: XtypeReferenceVisitor.java From xtext-extras with Eclipse Public License 2.0 | votes |
Result doVisitComputedTypeReference(XComputedTypeReference reference);