示例#1
0
        KeyValuePair <int, int>?GetMatchIndexes(RoslynCompletion completion, CompletionDescription description)
        {
            if (completion == null || description == null)
            {
                return(null);
            }
            if (stringBuilder == null)
            {
                stringBuilder = new StringBuilder();
            }
            else
            {
                stringBuilder.Clear();
            }
            var displayText = completion.DisplayText;
            int matchIndex  = -1;
            int index       = -1;

            foreach (var part in description.TaggedParts)
            {
                index++;
                if (part.Tag == TextTags.LineBreak)
                {
                    break;
                }
                if (matchIndex < 0)
                {
                    if (!displayText.StartsWith(part.Text))
                    {
                        continue;
                    }
                    matchIndex = index;
                }
                else
                {
                    if (!StartsWith(displayText, stringBuilder.Length, part.Text))
                    {
                        // Partial match, could happen if the type is System.Collections.Generic.List<int> but
                        // the documentation is using System.Collections.Generic.List<T>.
                        return(new KeyValuePair <int, int>(matchIndex, index - 1));
                    }
                }
                stringBuilder.Append(part.Text);
                if (stringBuilder.Length == displayText.Length)
                {
                    if (stringBuilder.ToString() == completion.DisplayText)
                    {
                        return(new KeyValuePair <int, int>(matchIndex, index));
                    }
                    break;
                }
                else if (stringBuilder.Length > displayText.Length)
                {
                    break;
                }
            }
            return(null);
        }
示例#2
0
        KeyValuePair <int, int>?GetMatchIndexes(RoslynCompletion completion, CompletionDescription description)
        {
            if (stringBuilder == null)
            {
                stringBuilder = new StringBuilder();
            }
            else
            {
                stringBuilder.Clear();
            }
            var displayText = completion.DisplayText;
            int matchIndex  = -1;
            int index       = -1;

            foreach (var part in description.TaggedParts)
            {
                index++;
                if (part.Tag == TextTags.LineBreak)
                {
                    break;
                }
                if (matchIndex < 0)
                {
                    if (!displayText.StartsWith(part.Text))
                    {
                        continue;
                    }
                    matchIndex = index;
                }
                stringBuilder.Append(part.Text);
                if (stringBuilder.Length == displayText.Length)
                {
                    if (stringBuilder.ToString() == completion.DisplayText)
                    {
                        return(new KeyValuePair <int, int>(matchIndex, index));
                    }
                    break;
                }
                else if (stringBuilder.Length > displayText.Length)
                {
                    break;
                }
            }
            return(null);
        }
示例#3
0
		KeyValuePair<int, int>? GetMatchIndexes(RoslynCompletion completion, CompletionDescription description) {
			if (completion == null || description == null)
				return null;
			if (stringBuilder == null)
				stringBuilder = new StringBuilder();
			else
				stringBuilder.Clear();
			var displayText = completion.DisplayText;
			int matchIndex = -1;
			int index = -1;
			foreach (var part in description.TaggedParts) {
				index++;
				if (part.Tag == TextTags.LineBreak)
					break;
				if (matchIndex < 0) {
					if (!displayText.StartsWith(part.Text))
						continue;
					matchIndex = index;
				}
				else {
					if (!StartsWith(displayText, stringBuilder.Length, part.Text)) {
						// Partial match, could happen if the type is System.Collections.Generic.List<int> but
						// the documentation is using System.Collections.Generic.List<T>.
						return new KeyValuePair<int, int>(matchIndex, index - 1);
					}
				}
				stringBuilder.Append(part.Text);
				if (stringBuilder.Length == displayText.Length) {
					if (stringBuilder.ToString() == completion.DisplayText)
						return new KeyValuePair<int, int>(matchIndex, index);
					break;
				}
				else if (stringBuilder.Length > displayText.Length)
					break;
			}
			return null;
		}