public QualifiedThisOrSuperDescription(QualifiedName qualifiedName, LightweightTypeReference typeReference, int bucketId, boolean visible, XExpression receiver) { super(qualifiedName, typeReference.getType(), bucketId, visible); this.typeReference = typeReference; this.receiver = receiver; }
/** Replies if the given type is an interface. * * @param type - the type to test. * @return <code>true</code> if the given type is an interface. */ public static boolean isInterface(LightweightTypeReference type) { return type.getType() instanceof JvmGenericType && ((JvmGenericType) type.getType()).isInterface(); }
@Override /* @Nullable */ public JvmType getType() { if (components != null && components.size() == 1) return components.get(0).getType(); // TODO common type? return null; }
private boolean identifierStartWith(LightweightTypeReference typeReference, String prefix) { JvmType type = typeReference.getType(); if (type == null) return false; String identifier = type.getIdentifier(); if (identifier != null) return identifier.startsWith(prefix); return false; }
/** Replies if the given reference is pointing to a class type. * * @param typeRef - the type reference to test. * @return <code>true</code> if the pointed element is a class type. */ public static boolean isClass(LightweightTypeReference typeRef) { final JvmType t = typeRef.getType(); if (t instanceof JvmGenericType) { return !((JvmGenericType) t).isInterface(); } return false; }
/** Extract and replies the Ecore type, provided by {@link SarlPackage} for the given JvmElement. * * @param type the JVM type to test. * @return the code of the type, see {@link SarlPackage}; or {@code 0} if the code is unknown. * @since 0.8 */ public int getSarlElementEcoreType(LightweightTypeReference type) { final JvmType jvmType = type.getType(); if (jvmType instanceof JvmGenericType) { return getSarlElementEcoreType((JvmGenericType) jvmType); } return 0; }
public ContextualVisibilityHelper(IVisibilityHelper parent, LightweightTypeReference contextType, String packageName) { this.parent = parent; this.rawContextType = contextType.getRawTypeReference().getType(); this.packageName = packageName; }
protected LightweightTypeReference getBoundTypeArgument(ParameterizedTypeReference reference, JvmTypeParameter type, Visiting visiting) { LightweightMergedBoundTypeArgument boundTypeArgument = typeParameterMapping.get(type); if (boundTypeArgument != null) { LightweightTypeReference boundReference = boundTypeArgument.getTypeReference(); if (boundReference != null && reference != boundReference && boundReference.getType() != type) { return boundReference.accept(this, visiting); } } return null; }
public ContextualVisibilityHelper(IVisibilityHelper parent, LightweightTypeReference contextType) { this.parent = parent; this.rawContextType = contextType.getRawTypeReference().getType(); if (rawContextType instanceof JvmDeclaredType) { this.packageName = ((JvmDeclaredType) rawContextType).getPackageName(); } }
@Override /* @Nullable */ public JvmType getType() { if (internalIsResolved()) return resolvedTo.getType(); return getTypeParameter(); }
@Override public void accept(LightweightTypeReference type) { for(LightweightTypeReference caughtException: caughtExceptions) { if (type.isSubtypeOf(caughtException.getType())) { return; } } delegate.accept(type); }
@Override /* @Nullable */ protected LightweightMergedBoundTypeArgument getBoundTypeArgument(JvmTypeParameter type, ConstraintVisitingInfo info) { LightweightMergedBoundTypeArgument result = super.getBoundTypeArgument(type, info); if (result != null && result.getTypeReference().getType() == type) { return null; } return result; } };
protected boolean isFinal(LightweightTypeReference expressionTypeRef) { if (expressionTypeRef.isArray()) { return isFinal(expressionTypeRef.getComponentType()); } if (expressionTypeRef.isPrimitive()) return true; return expressionTypeRef.getType() instanceof JvmDeclaredType && ((JvmDeclaredType) expressionTypeRef.getType()).isFinal(); }
@Override public JvmArrayType getType() { JvmType componentType = component.toJavaType().getType(); if (componentType instanceof JvmComponentType) { return Preconditions.checkNotNull(((JvmComponentType) componentType).getArrayType()); } if (component.isUnknown() || componentType.eIsProxy()) { return null; } throw new IllegalStateException("component type seems to be invalid: " + componentType + " / " + component); }
protected List<JvmType> getParamTypes(JvmOperation jvmOperation, boolean wrapPrimitives) { List<JvmType> types = newArrayList(); for (JvmFormalParameter p : jvmOperation.getParameters()) { LightweightTypeReference typeReference = toLightweightTypeReference(p.getParameterType()); if (wrapPrimitives) { typeReference = typeReference.getWrapperTypeIfPrimitive(); } types.add(typeReference.getType()); } return types; }
protected IScope createStaticScope(XAbstractFeatureCall featureCall, XExpression receiver, LightweightTypeReference receiverType, IScope parent, IFeatureScopeSession session, IResolvedTypes resolvedTypes) { IScope result = parent; if (receiver == null) { result = createImplicitStaticScope(THIS, featureCall, session, resolvedTypes, result); result = createImplicitStaticScope(IT, featureCall, session, resolvedTypes, result); return result; } else { TypeBucket receiverBucket = new TypeBucket(-1, Collections.singletonList(receiverType.getType()), resolvedFeaturesProvider); return createStaticFeatureScope(featureCall, receiver, receiverType, receiverBucket, parent, session); } }
protected void appendNullValueUntyped(LightweightTypeReference type, @SuppressWarnings("unused") EObject context, ITreeAppendable b) { if (!type.isPrimitive()) { b.append("null"); } else { b.append(getDefaultLiteral((JvmPrimitiveType) type.getType())); } }
protected IScope createImplicitStaticScope(QualifiedName implicitName, XAbstractFeatureCall featureCall, IFeatureScopeSession session, IResolvedTypes resolvedTypes, IScope parent) { IEObjectDescription thisDescription = session.getLocalElement(implicitName); if (thisDescription != null) { JvmIdentifiableElement thisElement = (JvmIdentifiableElement) thisDescription.getEObjectOrProxy(); LightweightTypeReference type = resolvedTypes.getActualType(thisElement); if (type != null && !type.isUnknown()) { TypeBucket receiverBucket = new TypeBucket(-1, Collections.singletonList(type.getType()), resolvedFeaturesProvider); return createStaticFeatureScope(featureCall, null, type, receiverBucket, parent, session); } } return parent; }
protected boolean isRawTypeInheritance() { List<LightweightTypeReference> superTypes = getContextType().getAllSuperTypes(); JvmDeclaredType declaringType = getDeclaration().getDeclaringType(); for(LightweightTypeReference superType: superTypes) { if (superType.getType() == declaringType && superType.isRawType()) { return true; } } return false; } }