public static bool TryGetExpectedTypeForBinaryOp(TexlBinding binding, TexlNode curNode, int cursorPos, out DType expectedType) { // If we are in a binary operation context, the expected type is relative to the binary operation. if (curNode != null && curNode.Parent != null && curNode.Parent.Kind == NodeKind.BinaryOp) { BinaryOpNode binaryOpNode = curNode.Parent.CastBinaryOp(); DType coercedType; TexlNode expectedNode = null; if (cursorPos < binaryOpNode.Token.Span.Min) { // Cursor is before the binary operator. Expected type is equal to the type of right side. expectedNode = binaryOpNode.Right; } else if (cursorPos > binaryOpNode.Token.Span.Lim) { // Cursor is after the binary operator. Expected type is equal to the type of left side. expectedNode = binaryOpNode.Left; } if (expectedNode != null) { expectedType = binding.TryGetCoercedType(expectedNode, out coercedType) ? coercedType : binding.GetType(expectedNode); return(true); } } expectedType = DType.Error; return(false); }