public IEnumerable <IQuerySuggestion> Compute(SuggestionState state)
        {
            var expected = state.Expected.Find(item =>
                                               item.RuleIndices[0] == QueryParser.RULE_source);

            // make sure we are in the select part of a query
            if (expected == null)
            {
                return(Enumerable.Empty <IQuerySuggestion>());
            }

            // make sure we are in a path pattern
            if (state.Caret.ParentToken == null ||
                state.Caret.ParentToken.Type != QueryLexer.STRING)
            {
                return(Enumerable.Empty <IQuerySuggestion>());
            }

            // make sure the caret is in the pattern (not after the last quote)
            if (state.Caret.ParentOffset >= state.Caret.ParentToken.Text.Length &&
                state.Caret.ParentToken.Text[state.Caret.ParentOffset - 1] == '\"')
            {
                return(Enumerable.Empty <IQuerySuggestion>());
            }

            var patternParts = Split(state.Caret.ParentPrefix);

            // if the directory name at the caret is a pattern, don't suggest anything
            if (PathPattern.ContainsSpecialCharacters(patternParts.LastPart))
            {
                return(Enumerable.Empty <IQuerySuggestion>());
            }

            if (patternParts.LastPart.Length == 0)
            {
                patternParts.LastPart = "*";
            }
            else
            {
                patternParts.LastPart = "*" + patternParts.LastPart + "*";
            }

            try
            {
                var pattern = Path.Combine(patternParts.Prefix, patternParts.LastPart);
                var finder  = _fileSystem.CreateFileFinder(pattern);
                var result  = finder
                              .GetDirectories()
                              .Select(PathUtils.GetLastPart)
                              .Distinct()
                              .Select(name => new DirectorySuggestion(state.Caret, name));
                return(result);
            }
            catch (ArgumentException) // the pattern contains invalid characters
            {
                // suggestions should not throw for invalid input
                return(Enumerable.Empty <IQuerySuggestion>());
            }
        }