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; }
protected virtual UIString ConstructUIString(SuggestionKind suggestionKind, DType type, IntellisenseSuggestionList suggestions, string valueToSuggest, int highlightStart, int highlightEnd) { return(IntellisenseHelper.DisambiguateGlobals(suggestions, new UIString(valueToSuggest, highlightStart, highlightEnd), suggestionKind, type)); }
private CompletionItemKind GetCompletionItemKind(SuggestionKind kind) { switch (kind) { case SuggestionKind.Function: return(CompletionItemKind.Method); case SuggestionKind.KeyWord: return(CompletionItemKind.Keyword); case SuggestionKind.Global: return(CompletionItemKind.Variable); case SuggestionKind.Field: return(CompletionItemKind.Field); case SuggestionKind.Alias: return(CompletionItemKind.Variable); case SuggestionKind.Enum: return(CompletionItemKind.Enum); case SuggestionKind.BinaryOperator: return(CompletionItemKind.Operator); case SuggestionKind.Local: return(CompletionItemKind.Variable); case SuggestionKind.ServiceFunctionOption: return(CompletionItemKind.Method); case SuggestionKind.Service: return(CompletionItemKind.Module); case SuggestionKind.ScopeVariable: return(CompletionItemKind.Variable); default: return(CompletionItemKind.Text); } }
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); }
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) { }
internal static void AddSuggestionsForMatches(IntellisenseData.IntellisenseData intellisenseData, IEnumerable <KeyValuePair <string, SuggestionIconKind> > possibilities, SuggestionKind kind, bool requiresSuggestionEscaping, uint sortPriority = 0) { Contracts.AssertValue(intellisenseData); Contracts.AssertValue(possibilities); foreach (var possibility in possibilities) { AddSuggestion(intellisenseData, possibility.Key, kind, possibility.Value, DType.Unknown, requiresSuggestionEscaping, sortPriority); } }
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) { }
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)); }
public static UIString DisambiguateGlobals(IntellisenseSuggestionList curList, UIString curSuggestion, SuggestionKind suggestionKind, DType type) { Contracts.AssertValue(curList); Contracts.AssertValue(curSuggestion); Contracts.AssertValid(type); UIString retVal = curSuggestion; string sug = curSuggestion.Text; bool suggestionKindIsGlobalOrScope = (suggestionKind == SuggestionKind.Global || suggestionKind == SuggestionKind.ScopeVariable); foreach (var s in curList.SuggestionsForText(sug)) { // Retrive global/appVariable suggestions which // -- Don't have the same type as current suggestion (because, if it's of same type, it will be filtered out anyway) // -- Match the current suggestion text (filtered in the loop definition above for efficiency) if ((!suggestionKindIsGlobalOrScope && s.Kind != SuggestionKind.Global && s.Kind != SuggestionKind.ScopeVariable) || s.Type == type) { continue; } // The retrived list represents collisions. Update the suggestion text with global disambiguation. int punctuatorLen = TexlLexer.PunctuatorAt.Length + TexlLexer.PunctuatorAt.Length; // The suggestion already in the list is global. Update it. if (s.Kind == SuggestionKind.Global || s.Kind == SuggestionKind.ScopeVariable) { int index = curList.IndexOf(s); Contracts.Assert(index >= 0); UIString dispText = curList[index].DisplayText; // If we are already using the global syntax, we should not add it again. if (dispText.Text.StartsWith(TexlLexer.PunctuatorBracketOpen + TexlLexer.PunctuatorAt)) { continue; } curList.UpdateDisplayText(index, new UIString(TexlLexer.PunctuatorBracketOpen + TexlLexer.PunctuatorAt + dispText.Text + TexlLexer.PunctuatorBracketClose, dispText.HighlightStart + punctuatorLen, dispText.HighlightEnd + punctuatorLen)); } // Current suggestion is global. Update it. else { retVal = new UIString(TexlLexer.PunctuatorBracketOpen + TexlLexer.PunctuatorAt + sug + TexlLexer.PunctuatorBracketClose, curSuggestion.HighlightStart + punctuatorLen, curSuggestion.HighlightEnd + punctuatorLen); } } return(retVal); }
protected override UIString ConstructUIString(SuggestionKind suggestionKind, DType type, IntellisenseSuggestionList suggestions, string valueToSuggest, int highlightStart, int highlightEnd) { return(new UIString(valueToSuggest, highlightStart, highlightEnd)); }
public Suggestion(string addition, string prefix, SuggestionKind kind) { Prefix = prefix; Kind = kind; Addition = addition; }
public SuggestionContext(SuggestionKind allowedSuggestions, string prefix) { AllowedSuggestions = allowedSuggestions; Prefix = prefix; }