@Override public boolean isPrimitive() { if (internalIsResolved()) { return resolvedTo.isPrimitive(); } return false; }
protected LightweightTypeReference getResolvedReference(/* @Nullable */ JvmTypeReference unresolved) { ITypeReferenceOwner owner = getContextType().getOwner(); if (unresolved == null) { return owner.newReferenceToObject(); } LightweightTypeReference unresolvedLightweight = owner.toLightweightTypeReference(unresolved); if (unresolvedLightweight.isPrimitive() || unresolvedLightweight.isPrimitiveVoid()) return unresolvedLightweight; TypeParameterSubstitutor<?> substitutor = getSubstitutor(); LightweightTypeReference result = substitutor.substitute(unresolvedLightweight); return result; }
protected boolean containsPrimitiveOrAnyReferences(List<LightweightTypeReference> types) { for(LightweightTypeReference type: types) { if (type.isPrimitive() || type.isAny()) return true; } return false; }
@Override public boolean isPrimitive() { for(LightweightTypeReference component: expose(components)) { if (component.isPrimitive()) return true; } return false; }
@Override public boolean isPrimitive() { return this.getDelegate().isPrimitive(); }
String getDefaultValue(LightweightTypeReference type) { if (type != null && type.isPrimitive()) { Primitive primitiveKind = primitives.primitiveKind((JvmPrimitiveType) type.getType()); if (primitiveKind == Primitive.Boolean) return "false"; else return "0"; } return "null"; }
protected void checkValidExtensionType(JvmIdentifiableElement identifiable, EObject source, EStructuralFeature feature) { LightweightTypeReference type = getActualType(identifiable); if (type != null && type.isPrimitive()) { error(String.format("The primitive type %s is not a valid extension", type.getHumanReadableName()), source, feature, INVALID_EXTENSION_TYPE); } }
protected String getDefaultValueLiteral(XExpression expr) { LightweightTypeReference type = getTypeForVariableDeclaration(expr); if (type.isPrimitive()) { if (type.getPrimitiveKind() == Primitives.Primitive.Boolean) { return "false"; } else { return "(" + type.getSimpleName() + ") 0"; } } return "null"; }
private boolean hasPrimitiveParameters(JvmOperation op) { for (final JvmFormalParameter parameter : op.getParameters()) { final JvmTypeReference type = parameter.getParameterType(); if (type == null || !Utils.toLightweightTypeReference(type, this.services).isPrimitive()) { return false; } } return true; }
private boolean hasPrimitiveParameters(JvmOperation op) { for (final JvmFormalParameter parameter : op.getParameters()) { final JvmTypeReference type = parameter.getParameterType(); if (type == null || !Utils.toLightweightTypeReference(type, this.services).isPrimitive()) { return false; } } return true; }
protected void ensureNotPrimitiveNorWildcard(JvmTypeReference typeRef) { LightweightTypeReference reference = toLightweightTypeReference(typeRef); if (reference.isPrimitive()) { error("Primitives cannot be used as type arguments.", typeRef, null, INVALID_USE_OF_TYPE); } if (reference.isWildcard()) { error("Wildcard types are not allowed in this context", typeRef, null, INSIGNIFICANT_INDEX, INVALID_USE_OF_WILDCARD); } }
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 EvaluationResult _internalEvaluate(final XNumberLiteral it, final EvaluationContext context) { final Number value = this.numberLiterals.numberValue(it, this.numberLiterals.getJavaType(it)); boolean _isPrimitive = context.getResolvedTypes().getActualType(it).isPrimitive(); return new EvaluationResult(value, _isPrimitive); }
@Override public void exec(ITreeAppendable appendable) { TypeConformanceComputationArgument rawNoSynonyms = new TypeConformanceComputationArgument(true, false, true, true, false, false); if (caseParamType.isAssignableFrom(dispatchParamType, rawNoSynonyms) && !dispatchParamType.isPrimitive()) { appendable.append(name).append(" != null"); } else { appendable.append(name).append(" instanceof "); JvmType type = caseParamType.getWrapperTypeIfPrimitive().getType(); if (type == null) { throw new IllegalStateException(String.valueOf(caseParamType)); } appendable.append(type); } } });
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(); }
@Check void checkNullSafeFeatureCallWithPrimitives(XMemberFeatureCall featureCall) { if (featureCall.isNullSafe()) { if (getActualType(featureCall.getMemberCallTarget()).isPrimitive()) { error("Cannot use null-safe feature call on primitive receiver", featureCall, Literals.XMEMBER_FEATURE_CALL__NULL_SAFE, NULL_SAFE_FEATURE_CALL_ON_PRIMITIVE); return; } LightweightTypeReference type = getActualType(featureCall); if (type.isPrimitive() && isValueExpectedRecursive(featureCall)) { addIssue("Null-safe call of primitive-valued feature " + featureCall.getConcreteSyntaxFeatureName() + ", default value "+ getDefaultValue(type) +" will be used", featureCall, NULL_SAFE_FEATURE_CALL_OF_PRIMITIVE_VALUED_FEATURE); } } }
/** Replies if the given reference is referencing a final type. * * @param expressionTypeRef - the type reference to test. * @return <code>true</code> if the given type is final. */ public static 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(); }
private boolean isArrayTypeMismatch(LightweightTypeReference receiverType, LightweightTypeReference parameterType) { if (receiverType.isArray()) { if (parameterType.isArray()) { LightweightTypeReference componentType = parameterType.getComponentType(); if (isArrayTypeMismatch(receiverType.getComponentType(), componentType)) { return true; } return false; } return true; } else { if (!parameterType.isArray() && parameterType.isPrimitive()) { return true; } } return false; }
@Check public void checkTypeGuards(XCasePart casePart) { if (casePart.getTypeGuard() == null) return; LightweightTypeReference typeGuard = toLightweightTypeReference(casePart.getTypeGuard()); if (typeGuard.isPrimitive()) { error("Primitives are not allowed as type guards", Literals.XCASE_PART__TYPE_GUARD, INVALID_USE_OF_TYPE); return; } LightweightTypeReference targetTypeRef = getActualType(((XSwitchExpression) casePart.eContainer()).getSwitch()); checkCast(casePart.getTypeGuard(), typeGuard, targetTypeRef); }
protected void _computeTypes(XSynchronizedExpression expr, ITypeComputationState state) { ITypeComputationState paramState = state.withExpectation(state.getReferenceOwner().newReferenceToObject()); ITypeComputationResult paramType = paramState.computeTypes(expr.getParam()); LightweightTypeReference actualParamType = paramType.getActualExpressionType(); if (actualParamType != null && (actualParamType.isPrimitive() || actualParamType.isAny())) { state.addDiagnostic(new EObjectDiagnosticImpl( Severity.ERROR, IssueCodes.INCOMPATIBLE_TYPES, actualParamType.getHumanReadableName() + " is not a valid type's argument for the synchronized expression.", expr.getParam(), null, -1, new String[] { })); } state.computeTypes(expr.getExpression()); }