Ejemplo n.º 1
0
        public IntellisenseSuggestion(UIString text, SuggestionKind kind, SuggestionIconKind iconKind, DType type, string exactMatch, int argCount, string definition, string functionName, string functionParamDescription, uint sortPriority = 0)
        {
            Contracts.AssertValue(text);
            Contracts.AssertNonEmpty(text.Text);
            Contracts.AssertValid(type);
            Contracts.AssertValue(exactMatch);
            Contracts.AssertValue(definition);
            Contracts.Assert(argCount >= -1);
            Contracts.AssertValueOrNull(functionName);
            Contracts.AssertValueOrNull(functionParamDescription);

            DisplayText     = text;
            _overloads      = new List <IIntellisenseSuggestion>();
            _text           = text.Text;
            Kind            = kind;
            IconKind        = iconKind;
            Type            = type;
            _argIndex       = -1;
            ExactMatch      = exactMatch;
            _argCount       = argCount;
            FunctionName    = functionName;
            SortPriority    = sortPriority;
            ShouldPreselect = sortPriority != 0;

            FunctionParameterDescription = functionParamDescription ?? string.Empty;
            Definition  = definition;
            IsTypeMatch = false;
        }
Ejemplo n.º 2
0
        public bool AddSuggestion(IntellisenseData.IntellisenseData intellisenseData, string suggestion, SuggestionKind suggestionKind, SuggestionIconKind iconKind, DType type, bool requiresSuggestionEscaping, uint sortPriority = 0)
        {
            Contracts.AssertValue(intellisenseData);
            Contracts.AssertValue(suggestion);

            if (!intellisenseData.DetermineSuggestibility(suggestion, type))
            {
                return(false);
            }

            IntellisenseSuggestionList suggestions          = intellisenseData.Suggestions;
            IntellisenseSuggestionList substringSuggestions = intellisenseData.SubstringSuggestions;
            int    matchingLength = intellisenseData.MatchingLength;
            string matchingStr    = intellisenseData.MatchingStr;
            string boundTo        = intellisenseData.BoundTo;

            var valueToSuggest = requiresSuggestionEscaping ? TexlLexer.EscapeName(suggestion) : suggestion;
            int highlightStart = suggestion.IndexOf(matchingStr, StringComparison.OrdinalIgnoreCase);

            // If the suggestion has special characters we need to find the highlightStart index by escaping the matching string as well.
            // Because, the suggestion could be something like 'Ident with Space' and the user might have typed Ident. In this case,
            // we want to highlight only Ident while displaying 'Ident with Space'.
            if (requiresSuggestionEscaping && !string.IsNullOrEmpty(matchingStr) && valueToSuggest != suggestion && highlightStart == 0)
            {
                highlightStart++;
            }
            else
            {
                matchingLength--;
            }

            int highlightEnd = highlightStart + matchingStr.Length;

            if (IntellisenseHelper.IsMatch(suggestion, matchingStr))
            {
                // In special circumstance where the user escapes an identifier where they don't have to, the matching length will
                // include the starting delimiter that user provided, where as the suggestion would not include any delimiters.
                // Hence we have to count for that fact.
                if (matchingLength > 0 & matchingLength > matchingStr.Length)
                {
                    highlightEnd = matchingLength > valueToSuggest.Length ? valueToSuggest.Length : matchingLength;
                }
                UIString UIsuggestion            = ConstructUIString(suggestionKind, type, suggestions, valueToSuggest, highlightStart, highlightEnd);
                IntellisenseSuggestion candidate = new IntellisenseSuggestion(UIsuggestion,
                                                                              suggestionKind,
                                                                              iconKind,
                                                                              type,
                                                                              boundTo,
                                                                              -1,
                                                                              string.Empty,
                                                                              null,
                                                                              sortPriority);
                return(CheckAndAddSuggestion(suggestions, candidate));
            }
            if (highlightStart > -1)
            {
                UIString UIsuggestion            = ConstructUIString(suggestionKind, type, substringSuggestions, valueToSuggest, highlightStart, highlightEnd);
                IntellisenseSuggestion candidate = new IntellisenseSuggestion(UIsuggestion,
                                                                              suggestionKind,
                                                                              iconKind,
                                                                              type,
                                                                              boundTo,
                                                                              -1,
                                                                              string.Empty,
                                                                              null,
                                                                              sortPriority);

                return(CheckAndAddSuggestion(substringSuggestions, candidate));
            }

            return(false);
        }
Ejemplo n.º 3
0
 public IntellisenseSuggestion(UIString text, SuggestionKind kind, SuggestionIconKind iconKind, DType type, string exactMatch, int argCount, string definition, string functionName, uint sortPriority = 0)
     : this(text, kind, iconKind, type, exactMatch, argCount, definition, functionName, string.Empty, sortPriority)
 {
 }
Ejemplo n.º 4
0
 public IntellisenseSuggestion(UIString text, SuggestionKind kind, SuggestionIconKind iconKind, DType type, int argCount, string definition, string functionName, string functionParamDescription)
     : this(text, kind, iconKind, type, string.Empty, argCount, definition, functionName, functionParamDescription, 0)
 {
 }
Ejemplo n.º 5
0
        internal static void AddSuggestionsForMatches(IntellisenseData.IntellisenseData intellisenseData, IEnumerable <string> possibilities, SuggestionKind kind, SuggestionIconKind iconKind, bool requiresSuggestionEscaping, uint sortPriority = 0)
        {
            Contracts.AssertValue(intellisenseData);
            Contracts.AssertValue(possibilities);

            foreach (var possibility in possibilities)
            {
                AddSuggestion(intellisenseData, possibility, kind, iconKind, DType.Unknown, requiresSuggestionEscaping, sortPriority);
            }
        }
Ejemplo n.º 6
0
 internal static bool AddSuggestion(IntellisenseData.IntellisenseData intellisenseData, string suggestion, SuggestionKind suggestionKind, SuggestionIconKind iconKind, DType type, bool requiresSuggestionEscaping, uint sortPriority = 0)
 {
     return(_addSuggestionHelper.AddSuggestion(intellisenseData, suggestion, suggestionKind, iconKind, type, requiresSuggestionEscaping, sortPriority));
 }