protected boolean isVariableDeclarationRequired(XMemberFeatureCall expr, @SuppressWarnings("unused") ITreeAppendable b) { return expr.isNullSafe(); }
/** Generate a feature call. * * @param expr the call expression. */ public void generate(XAbstractFeatureCall expr) { if (expr.isTypeLiteral()) { final JvmType type = (JvmType) expr.getFeature(); this.codeReceiver.append(type); //} else if (getExpressionHelper().isShortCircuitOperation(expr)) { // generateShortCircuitInvocation(expr); } else { if (expr instanceof XMemberFeatureCall && ((XMemberFeatureCall) expr).isNullSafe()) { featureCalltoJavaExpression(expr, () -> expr); } else { featureCalltoJavaExpression(expr, null); } } }
protected boolean isPotentialTypeLiteralImpl(XExpression featureCall, /* @Nullable */ IResolvedTypes resolvedTypes, boolean staticNotation) { if (featureCall instanceof XMemberFeatureCall) { XMemberFeatureCall casted = (XMemberFeatureCall) featureCall; if (casted.isExplicitOperationCallOrBuilderSyntax() || casted.isNullSafe()) { return false; } XExpression target = casted.getMemberCallTarget(); if (casted.isExplicitStatic() != staticNotation) { return false; } return isPotentialTypeLiteralImpl(target, resolvedTypes, staticNotation); } if (featureCall instanceof XFeatureCall) { XFeatureCall casted = (XFeatureCall) featureCall; if (casted.isExplicitOperationCallOrBuilderSyntax()) { return false; } if (resolvedTypes == null) return true; LightweightTypeReference knownType = resolvedTypes.getActualType(casted); if (knownType == null || knownType.isUnknown()) { return true; } } return false; }
protected Object _doEvaluate(final XMemberFeatureCall featureCall, final IEvaluationContext context, final CancelIndicator indicator) { if (featureCall.isTypeLiteral()) { JvmType type = (JvmType) featureCall.getFeature(); Object result = translateJvmTypeToResult(type, 0); return result; } else { XExpression receiver = getActualReceiver(featureCall); //, featureCall.getFeature(), featureCall.getImplicitReceiver()); Object receiverObj = receiver==null?null:internalEvaluate(receiver, context, indicator); if (featureCall.isNullSafe() && receiverObj==null) { return getDefaultObjectValue(typeResolver.resolveTypes(featureCall).getActualType(featureCall)); } return invokeFeature(featureCall.getFeature(), featureCall, receiverObj, context, indicator); } }
@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); } } }
if (featureCall.isNullSafe()) acceptor.accept(memberFeatureCallElements.getNullSafeQuestionMarkFullStopKeyword_1_1_0_0_1_1_0()); else if (featureCall.isExplicitStatic())
return !((XMemberFeatureCall) featureCall).isNullSafe();
if (((XMemberFeatureCall) expr.eContainer()).isNullSafe()) { if (expr instanceof XFeatureCall) { JvmIdentifiableElement feature = ((XFeatureCall) expr).getFeature();
if (expr instanceof XMemberFeatureCall && ((XMemberFeatureCall) expr).isNullSafe()) { compileNullSafeFeatureCall((XMemberFeatureCall) expr, b, isReferenced); } else {
final XMemberFeatureCall it = ((XMemberFeatureCall)top); boolean _matched = false; boolean _isNullSafe = it.isNullSafe(); if (_isNullSafe) { _matched=true;
final XMemberFeatureCall it = call; boolean _matched = false; boolean _isNullSafe = it.isNullSafe(); if (_isNullSafe) { _matched=true;