private BaseFilterOperation <T> GenerateFilterOperation <T>(FilterNode node, QueryEngine <T> engine, ICollection <QueryError> errors) { var operatorIndex = node.token.position + node.filter.token.Length + (string.IsNullOrEmpty(node.paramValue) ? 0 : node.paramValue.Length); var filterValueIndex = operatorIndex + node.op.token.Length; Type filterValueType; IParseResult parseResult = null; if (QueryEngineUtils.IsNestedQueryToken(node.filterValue)) { if (node.filter?.queryHandlerTransformer == null) { errors.Add(new QueryError(filterValueIndex, node.filterValue.Length, $"No nested query handler transformer set on filter \"{node.filter.token}\".")); return(null); } filterValueType = node.filter.queryHandlerTransformer.rightHandSideType; } else { parseResult = engine.ParseFilterValue(node.filterValue, node.filter, node.op, out filterValueType); if (!parseResult.success) { errors.Add(new QueryError(filterValueIndex, node.filterValue.Length, $"The value \"{node.filterValue}\" could not be converted to any of the supported handler types.")); return(null); } } IFilterOperationGenerator generator = engine.GetGeneratorForType(filterValueType); if (generator == null) { errors.Add(new QueryError(filterValueIndex, node.filterValue.Length, $"Unknown type \"{filterValueType}\". Did you set an operator handler for this type?")); return(null); } var generatorData = new FilterOperationGeneratorData { filterValue = node.filterValue, filterValueParseResult = parseResult, globalStringComparison = engine.globalStringComparison, op = node.op, paramValue = node.paramValue, generator = generator }; var operation = node.filter.GenerateOperation(generatorData, operatorIndex, errors); return(operation as BaseFilterOperation <T>); }
static int MatchEmpty(string text, int startIndex, int endIndex, ICollection <QueryError> errors, out StringView sv, out Match match, out bool matched) { var currentIndex = startIndex; var lengthMatched = 0; matched = false; while (currentIndex < endIndex && QueryEngineUtils.IsWhiteSpaceChar(text[currentIndex])) { ++currentIndex; ++lengthMatched; matched = true; } sv = text.GetStringView(startIndex, startIndex + lengthMatched); match = null; return(lengthMatched); }