Exemplo n.º 1
0
        private async void View_NameChanged(object sender, NameEventArgs e)
        {
            // reset suggestions
            View.Suggestions = new List <Suggestion>();

            var value = e.Value?.Trim();

            if (value == null)
            {
                return;
            }

            _loadingNamePrefix = value;

            var suggestions = await Task.Run(() =>
            {
                var items = new List <Suggestion>();

                // load suggestions
                foreach (var name in _attributeCache.GetNames(value))
                {
                    items.Add(new Suggestion(name, Strings.UserAttribute_Label, null));
                }

                return(items);
            });

            if (_isDisposed || _loadingNamePrefix != value)
            {
                return;
            }

            View.Suggestions = suggestions;
        }
        public IEnumerable <IQuerySuggestion> Compute(SuggestionState state)
        {
            var expected = state.Expected.Find(item =>
                                               item.RuleIndices[0] == QueryParser.RULE_factor &&
                                               item.Tokens.Contains(QueryLexer.ID));

            // only suggest attribute names in an expression factor where an identifier is
            // expected
            if (expected == null)
            {
                return(Enumerable.Empty <IQuerySuggestion>());
            }

            var prefix = state.Caret.ParentPrefix ?? "";

            return(_attributeCache
                   .GetNames(prefix)
                   .Select(name => new IdentifierSuggestion(state.Caret, name, CategoryName)));
        }