示例#1
0
        public SnapshotPoint?getCharAtColumn(SnapshotSpan line, int column)
        {
            ++column;

            int           current   = 0;
            SnapshotPoint result    = line.Start;
            int           charwidth = 0;

            if (result != line.End)
            {
                charwidth = getCharacterWidth(result.GetChar());
            }

            while (current + charwidth < column && result < line.End)
            {
                current += charwidth;
                result   = result.Add(1);

                if (result < line.End)
                {
                    charwidth = getCharacterWidth(result.GetChar());
                }
            }

            if (result >= line.End)
            {
                return(null);
            }
            return(result);
        }
示例#2
0
        public static SnapshotSpan ReadToLineEndWhile(this ITextSnapshot snapshot, ref SnapshotPoint point, Predicate <char> predicate, bool rewindWhiteSpace = true)
        {
            SnapshotPoint start = point;

            while (
                point.Position < snapshot.Length &&
                point.GetChar() != '\n' && point.GetChar() != '\r' &&
                predicate(point.GetChar())
                )
            {
                point = point + 1;
            }

            if (rewindWhiteSpace)
            {
                while (
                    point - 1 >= start &&
                    Char.IsWhiteSpace((point - 1).GetChar())
                    )
                {
                    point = point - 1;
                }
            }

            return(new SnapshotSpan(start, point));
        }
        /// <summary>
        /// Find the previous keyword (if any) that exists BEFORE the provided triggerPoint, and the provided start.
        /// Eg. qqqq xxxxxx yyyyyyy zzzzzz
        ///     ^             ^
        ///     |begin        |end
        /// the previous keyword is xxxxxx
        /// </summary>
        /// <param name="begin"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        private static string getPreviousKeyword(SnapshotPoint begin, SnapshotPoint end)
        {
            if (end == 0)
            {
                return("");
            }

            // find the end of previous keyword
            SnapshotPoint endPrevious = begin;
            SnapshotPoint pos         = end - 1;

            for (; pos >= begin; pos -= 1)
            {
                if (!AsmTools.Tools.isSeparatorChar(pos.GetChar()))
                {
                    endPrevious = pos + 1;
                    break;
                }
            }
            SnapshotPoint beginPrevious = begin;

            for (; pos >= begin; pos -= 1)
            {
                if (AsmTools.Tools.isSeparatorChar(pos.GetChar()))
                {
                    beginPrevious = pos + 1;
                    break;
                }
            }
            var    applicableTo    = end.Snapshot.CreateTrackingSpan(new SnapshotSpan(beginPrevious, endPrevious), SpanTrackingMode.EdgeInclusive);
            string previousKeyword = applicableTo.GetText(end.Snapshot);

            //Debug.WriteLine(string.Format("INFO: getPreviousKeyword; previousKeyword={0}", previousKeyword));
            return(previousKeyword);
        }
示例#4
0
        /// <summary>
        ///     Skips the chars.
        /// </summary>
        public static SnapshotPoint SkipChars(this SnapshotPoint start, char value)
        {
            var currentChar = start.GetChar();

            while (currentChar == value)
            {
                start = start.Add(1);

                currentChar = start.GetChar();
            }

            return(start);
        }
示例#5
0
        private SnapshotPoint?FindMatchEndRegion(SnapshotPoint start)
        {
            SnapshotPoint checkPos   = start;
            int           matchIndex = 1;

            while (checkPos.Position < start.Snapshot.Length - 1)
            {
                checkPos += 1;
                char checkText = checkPos.GetChar();

                if (checkText == '{' && !Utilities.IsInCommentLine(checkPos))
                {
                    matchIndex++;
                }

                if (checkText == '}' && !Utilities.IsInCommentLine(checkPos))
                {
                    matchIndex--;
                }

                if (matchIndex == 0)
                {
                    break;
                }
            }

            if (matchIndex == 0)
            {
                return(checkPos);
            }

            return(null);
        }
        // returns true if brace is actually a brace.
        private bool FindOtherBrace(SnapshotPoint possibleBrace, out SnapshotPoint?otherBrace)
        {
            otherBrace = null;
            var rainbow = this.textBuffer.Get <RainbowProvider>();

            if (rainbow == null)
            {
                return(false);
            }
            if (!possibleBrace.IsValid())
            {
                return(false);
            }

            if (!rainbow.BufferBraces.BraceChars.Contains(possibleBrace.GetChar()))
            {
                return(false);
            }
            var bracePair = rainbow.BufferBraces.GetBracePair(possibleBrace);

            if (bracePair == null)
            {
                return(true);
            }
            if (possibleBrace.Position == bracePair.Item1.Position)
            {
                otherBrace = bracePair.Item2.ToPoint(possibleBrace.Snapshot);
            }
            else
            {
                otherBrace = bracePair.Item1.ToPoint(possibleBrace.Snapshot);
            }
            return(true);
        }
        public static SnapshotSpan ReadComment(this ITextSnapshot snapshot, ref SnapshotPoint point)
        {
            if (point.Position == snapshot.Length || point.GetChar() != RobotsTxtSyntaxFacts.Comment)
                return new SnapshotSpan(point, 0);

            return snapshot.ReadToLineEndWhile(ref point, _ => true);
        }
示例#8
0
        /// <summary>
        /// parses input buffer, searches for region start
        /// </summary>
        /// <param name="parser"></param>
        /// <returns>created region or null</returns>
        public override TextRegion TryCreateRegion(SnapshotParser parser)
        {
            ClassificationSpan span  = parser.CurrentSpan;
            SnapshotPoint      point = parser.CurrentPoint;

            if (span != null)
            {
                switch (span.ClassificationType.Classification)
                {
                case "punctuation":
                    char c = point.GetChar();
                    switch (c)
                    {
                    case '{':
                        return(new TextRegion(span.Span.Start, TextRegionType.Block));

                    case '[':
                        return(new TextRegion(span.Span.Start, TextRegionType.Array));
                    }
                    break;

                case "comment":
                    return(ParseComment(parser, RegionStartRegex, RegionEndRegex));
                }
            }
            return(null);
        }
        private void AddAdornments()
        {
            Debug.Assert(_easyMotionUtil.State == EasyMotionState.LookingForDecision);

            if (_wpfTextView.InLayout)
            {
                return;
            }

            _navigateMap.Clear();
            var textViewLines = _wpfTextView.TextViewLines;
            var startPoint    = textViewLines.FirstVisibleLine.Start;
            var endPoint      = textViewLines.LastVisibleLine.End;
            var snapshot      = startPoint.Snapshot;
            int navigateIndex = 0;

            for (int i = startPoint.Position; i < endPoint.Position; i++)
            {
                var point = new SnapshotPoint(snapshot, i);

                if (Char.ToLower(point.GetChar()) == Char.ToLower(_easyMotionUtil.TargetChar) && navigateIndex < NavigationKeys.Length)
                {
                    string key = NavigationKeys[navigateIndex];
                    navigateIndex++;
                    AddNavigateToPoint(textViewLines, point, key);
                }
            }

            if (navigateIndex == 0)
            {
                _easyMotionUtil.ChangeToLookingCharNotFound();
            }
        }
示例#10
0
        bool hasopenSignatureSession()
        {
            SnapshotPoint ssp   = this._textView.Caret.Position.BufferPosition;
            var           level = 0;
            bool          done  = false;

            while (ssp.Position > 0 && !done)
            {
                ssp = ssp - 1;
                var ch = ssp.GetChar();
                {
                    switch (ch)
                    {
                    case '(':
                    case '{':
                        level += 1;
                        break;

                    case ')':
                    case '}':
                        level -= 1;
                        break;

                    case '\r':
                    case '\n':
                        done = true;
                        break;
                    }
                }
            }
            return(level > 0);
        }
示例#11
0
        /// <summary>
        /// Is the provided SnapshotPoint preceded by the '+= SomeEventType(Some_HandlerName' line
        /// </summary>
        private bool IsPreceededByEventAddSyntax(SnapshotSpan span)
        {
            // First find the last + character
            var snapshot = span.Snapshot;
            SnapshotPoint? plusPoint = null;
            for (int i = span.Length - 1; i >= 0; i--)
            {
                var position = span.Start.Position + i;
                var point = new SnapshotPoint(snapshot, position);
                if (point.GetChar() == '+')
                {
                    plusPoint = point;
                    break;
                }
            }

            if (plusPoint == null)
            {
                return false;
            }

            var eventSpan = new SnapshotSpan(plusPoint.Value, span.End);
            var eventText = eventSpan.GetText();
            return 
                s_fullEventSyntaxRegex.IsMatch(eventText) ||
                s_shortEventSyntaxRegex.IsMatch(eventText);
        }
示例#12
0
        /// <summary>
        /// tries to close region
        /// </summary>
        /// <param name="parser">parser</param>
        /// <returns>whether region was closed</returns>
        protected override bool TryComplete(TextRegion r, SnapshotParser parser)
        {
            ClassificationSpan span  = parser.CurrentSpan;
            SnapshotPoint      point = parser.CurrentPoint;

            if (span != null)
            {
                string text = span.Span.GetText();
                if (span.ClassificationType.Classification == "punctuation")
                {
                    char c = point.GetChar();
                    //text can be "};", not just "}"
                    if (r.RegionType == TextRegionType.Block && c == '}' ||
                        r.RegionType == TextRegionType.Array && c == ']')
                    {
                        r.EndPoint = span.Span.Start + 1;
                    }
                }
                else if (span.ClassificationType.Classification == "comment" && r.RegionType == TextRegionType.Region)
                {
                    Match m = RegionEndRegex.Match(text);
                    if (m.Success)
                    {
                        r.EndPoint = span.Span.End;
                    }
                }
            }
            return(r.Complete);
        }
示例#13
0
        public IEnumerable <ITagSpan <ITextMarkerTag> > GetTags(NormalizedSnapshotSpanCollection spans)
        {
            if (spans[0].Snapshot != this.textView.TextBuffer.CurrentSnapshot)
            {
                yield break;
            }

            SnapshotPoint?caretPoint = this.textView.Caret.Position.Point.GetPoint(this.textView.TextBuffer, this.textView.Caret.Position.Affinity);

            if (!caretPoint.HasValue || caretPoint.Value.Snapshot.Length == 0)
            {
                yield break;
            }

            SnapshotPoint currPoint;

            if (caretPoint.Value.Position == caretPoint.Value.Snapshot.Length && caretPoint.Value.Position != 0)
            {
                currPoint = caretPoint.Value - 1;
            }
            else
            {
                currPoint = caretPoint.Value;
            }

            SnapshotPoint prevPoint = caretPoint.Value.Position != 0 ? caretPoint.Value - 1 : caretPoint.Value;

            char          currentCharacter = currPoint.GetChar();
            char          lastCharacter    = prevPoint.GetChar();
            SnapshotPoint matchedPoint;

            if (this.bracePairs.ContainsKey(currentCharacter))
            {
                if (this.FindCloseChar(currPoint, currentCharacter, this.bracePairs[currentCharacter], out matchedPoint))
                {
                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(currPoint, 1), this.tag));

                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(matchedPoint, 1), this.tag));
                }
            }
            else if (this.bracePairs.ContainsValue(lastCharacter))
            {
                char openCharacter = (char)0;

                foreach (KeyValuePair <char, char> pair in this.bracePairs)
                {
                    if (pair.Value == lastCharacter)
                    {
                        openCharacter = pair.Key;
                    }
                }

                if (this.FindOpenChar(prevPoint, openCharacter, lastCharacter, out matchedPoint))
                {
                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(matchedPoint, 1), this.tag));

                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(prevPoint, 1), this.tag));
                }
            }
        }
 /// <summary>
 /// Removes a token using the enhanced token stream class.
 /// </summary>
 /// <param name="sql"></param>
 /// <param name="position"></param>
 /// <returns></returns>
 private CommonTokenStream RemoveToken(string sql, SnapshotPoint snapPos)
 {
   MemoryStream ms = new MemoryStream(ASCIIEncoding.ASCII.GetBytes(sql));
   CaseInsensitiveInputStream input = new CaseInsensitiveInputStream(ms);
   //ANTLRInputStream input = new ANTLRInputStream(ms);
   Version ver = LanguageServiceUtil.GetVersion(LanguageServiceUtil.GetConnection().ServerVersion);
   MySQLLexer lexer = new MySQLLexer(input);
   lexer.MySqlVersion = ver;
   TokenStreamRemovable tokens = new TokenStreamRemovable(lexer);      
   IToken tr = null;
   int position = snapPos.Position;
   tokens.Fill();      
   if (!char.IsWhiteSpace(snapPos.GetChar()))
   {
     foreach (IToken t in tokens.GetTokens())
     {
       if ((t.StartIndex <= position) && (t.StopIndex >= position))
       {
         tr = t;
         break;
       }
     }
     tokens.Remove(tr);
   }
   return tokens;
 }    
示例#15
0
        /// <summary>
        /// Is the provided SnapshotPoint preceded by the '+= SomeEventType(Some_HandlerName' line
        /// </summary>
        private bool IsPreceededByEventAddSyntax(SnapshotSpan span)
        {
            // First find the last + character
            var           snapshot  = span.Snapshot;
            SnapshotPoint?plusPoint = null;

            for (int i = span.Length - 1; i >= 0; i--)
            {
                var position = span.Start.Position + i;
                var point    = new SnapshotPoint(snapshot, position);
                if (point.GetChar() == '+')
                {
                    plusPoint = point;
                    break;
                }
            }

            if (plusPoint == null)
            {
                return(false);
            }

            var eventSpan = new SnapshotSpan(plusPoint.Value, span.End);
            var eventText = eventSpan.GetText();

            return
                (s_fullEventSyntaxRegex.IsMatch(eventText) ||
                 s_shortEventSyntaxRegex.IsMatch(eventText));
        }
示例#16
0
        private static SnapshotSpan GetWordSpanFromPosition(SnapshotPoint positon)
        {
            if (positon.Position >= positon.Snapshot.Length)
            {
                return(new SnapshotSpan(positon, 0));
            }

            char              charAtPos = positon.GetChar();
            string            text = positon.Snapshot.GetText();
            ITextSnapshotLine lineSnapshot = positon.Snapshot.GetLineFromPosition(positon);
            int left, right;

            left = right = positon.Position;

            if (IsWordChar(charAtPos))
            {
                while (left - 1 >= lineSnapshot.Start.Position && IsWordChar(text[left - 1]))
                {
                    left--;
                }
                while (right + 1 < lineSnapshot.End.Position && IsWordChar(text[right + 1]))
                {
                    right++;
                }

                return(new SnapshotSpan(positon.Snapshot, left, right + 1 - left));
            }
            else
            {
                return(new SnapshotSpan(positon, 1));
            }
        }
示例#17
0
        protected virtual bool TryRecalculateTags(int revision, SnapshotPoint point, int searchDistance, out IEnumerable <TagSpan <TextMarkerTag> > tags)
        {
            // get the current char and the previous char
            char currentText = point.GetChar();
            // if current char is 0 (beginning of buffer), don't move it back
            SnapshotPoint lastChar = point == 0 ? point : point - 1;
            char          lastText = lastChar.GetChar();
            SnapshotSpan  pairSpan = new SnapshotSpan();

            if (IsMatchStartCharacter(currentText) && !IsInIgnoredSpan(Aggregator, point, TextView.Caret.Position.Affinity))
            {
                char closeChar = GetMatchCloseCharacter(currentText);

                /* TODO: Need to improve handling of larger blocks. this won't highlight if the matching brace is more
                 *       than 1 screen's worth of lines away. Changing this to 10 * TextView.TextViewLines.Count seemed
                 *       to improve the situation.
                 */
                if (FindMatchingCloseChar(revision, point, Aggregator, currentText, closeChar, searchDistance, out pairSpan))
                {
                    tags = new TagSpan <TextMarkerTag>[]
                    {
                        new TagSpan <TextMarkerTag>(new SnapshotSpan(point, 1), PredefinedTextMarkerTags.BraceHighlight),
                        new TagSpan <TextMarkerTag>(pairSpan, PredefinedTextMarkerTags.BraceHighlight)
                    };

                    return(true);
                }
                else
                {
                    tags = new TagSpan <TextMarkerTag> [0];
                    return(false);
                }
            }
            else if (IsMatchCloseCharacter(lastText) && !IsInIgnoredSpan(Aggregator, point, TextView.Caret.Position.Affinity))
            {
                var open = GetMatchOpenCharacter(lastText);
                if (FindMatchingOpenChar(revision, lastChar, Aggregator, open, lastText, searchDistance, out pairSpan))
                {
                    tags = new TagSpan <TextMarkerTag>[]
                    {
                        new TagSpan <TextMarkerTag>(new SnapshotSpan(lastChar, 1), PredefinedTextMarkerTags.BraceHighlight),
                        new TagSpan <TextMarkerTag>(pairSpan, PredefinedTextMarkerTags.BraceHighlight)
                    };

                    return(true);
                }
                else
                {
                    tags = new TagSpan <TextMarkerTag> [0];
                    return(false);
                }
            }
            else
            {
                // successfully identified that there are no matching braces
                tags = new TagSpan <TextMarkerTag> [0];
                return(true);
            }
        }
示例#18
0
        public IEnumerable <ITagSpan <ITextMarkerTag> > GetTags(NormalizedSnapshotSpanCollection spans)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (spans[0].Snapshot != textView.TextBuffer.CurrentSnapshot)
            {
                yield break;
            }

            SnapshotPoint?caretPoint =
                textView.Caret.Position.Point.GetPoint(textView.TextBuffer, textView.Caret.Position.Affinity);

            if (!caretPoint.HasValue || caretPoint.Value.Snapshot.Length == 0)
            {
                yield break;
            }

            SnapshotPoint currPoint;

            if (caretPoint.Value.Position == caretPoint.Value.Snapshot.Length && caretPoint.Value.Position != 0)
            {
                currPoint = caretPoint.Value - 1;
            }
            else
            {
                currPoint = caretPoint.Value;
            }

            if (MplPackage.Options.SharpStyleBraceMatch)
            {
                prevPoint = caretPoint.Value.Position != 0 ? caretPoint.Value - 1 : caretPoint.Value;
            }
            else
            {
                prevPoint = currPoint;
            }

            char          currentCharacter = currPoint.GetChar();
            char          lastCharacter    = prevPoint.GetChar();
            SnapshotPoint matchedPoint;

            if (bracePairs.ContainsKey(currentCharacter))
            {
                if (FindCloseChar(currPoint, braceKind[currentCharacter], out matchedPoint))
                {
                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(currPoint, 1), tag));

                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(matchedPoint, 1), tag));
                }
            }
            else if (bracePairs.ContainsValue(lastCharacter))
            {
                if (FindOpenChar(prevPoint, braceKind[lastCharacter], out matchedPoint))
                {
                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(matchedPoint, 1), tag));

                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(prevPoint, 1), tag));
                }
            }
        }
示例#19
0
 static WordKind GetWordKind(SnapshotPoint currentPosition)
 {
     if (currentPosition.Position >= currentPosition.Snapshot.Length)
     {
         return(WordKind.Whitespace);
     }
     return(GetWordKind(currentPosition.GetChar()));
 }
示例#20
0
        public IEnumerable <ITagSpan <TextMarkerTag> > GetTags(NormalizedSnapshotSpanCollection spans)
        {
            if (spans.Count == 0)   //there is no content in the buffer
            {
                yield break;
            }

            //don't do anything if the current SnapshotPoint is not initialized or at the end of the buffer
            if (!CurrentChar.HasValue || CurrentChar.Value.Position >= CurrentChar.Value.Snapshot.Length)
            {
                yield break;
            }

            //hold on to a snapshot of the current character
            SnapshotPoint currentChar = CurrentChar.Value;

            //if the requested snapshot isn't the same as the one the brace is on, translate our spans to the expected snapshot
            if (spans[0].Snapshot != currentChar.Snapshot)
            {
                currentChar = currentChar.TranslateTo(spans[0].Snapshot, PointTrackingMode.Positive);
            }

            //if we are outside the snapshot, bail
            if (currentChar.Position >= currentChar.Snapshot.Length)
            {
                yield break;
            }

            //get the current char and the previous char
            char          currentText = currentChar.GetChar();
            SnapshotPoint lastChar    = currentChar == 0 ? currentChar : currentChar - 1; //if currentChar is 0 (beginning of buffer), don't move it back
            char          lastText    = lastChar.GetChar();
            SnapshotSpan  pairSpan    = new SnapshotSpan();

            if (braceList.ContainsKey(currentText))   //the key is the open brace
            {
                char closeChar;
                braceList.TryGetValue(currentText, out closeChar);
                if (VisualRustBraceMatcher.FindMatchingCloseChar(currentChar, currentText, closeChar, View.TextViewLines.Count, out pairSpan) == true)
                {
                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(currentChar, 1), new TextMarkerTag("bracehighlight")));

                    yield return(new TagSpan <TextMarkerTag>(pairSpan, new TextMarkerTag("bracehighlight")));
                }
            }
            else if (braceList.ContainsValue(lastText))    //the value is the close brace, which is the *previous* character
            {
                var open = from n in braceList
                           where n.Value.Equals(lastText)
                           select n.Key;
                if (VisualRustBraceMatcher.FindMatchingOpenChar(lastChar, (char)open.ElementAt <char>(0), lastText, View.TextViewLines.Count, out pairSpan) == true)
                {
                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(lastChar, 1), new TextMarkerTag("bracehighlight")));

                    yield return(new TagSpan <TextMarkerTag>(pairSpan, new TextMarkerTag("bracehighlight")));
                }
            }
        }
示例#21
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("");
            }

            ITextSnapshot snapshot     = _buffer.CurrentSnapshot;
            var           triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
            {
                return;
            }

            var           line  = triggerPoint.GetContainingLine();
            SnapshotPoint start = triggerPoint;

            var emojiDetected = false;

            while (start > line.Start)
            {
                var chr = start == snapshot.Length
                                        ? '\n'
                                        : start.GetChar();

                if (chr == ':')
                {
                    emojiDetected = true;
                    break;
                }

                var previous = (start - 1).GetChar();

                if (!IsEmojiChar(previous))
                {
                    break;
                }

                start -= 1;
            }

            if (!emojiDetected)
            {
                return;
            }

            var span = new SnapshotSpan(start, triggerPoint);

            if (!_locationHandler.CanHazEmoji(span))
            {
                return;
            }

            var applicableTo = snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeInclusive);

            completionSets.Add(new CompletionSet("All", "All", applicableTo, _emojiCompletions, Enumerable.Empty <Completion>()));
        }
        public static SnapshotSpan ReadComment(this ITextSnapshot snapshot, ref SnapshotPoint point)
        {
            if (point.Position == snapshot.Length || point.GetChar() != RobotsTxtSyntaxFacts.Comment)
            {
                return(new SnapshotSpan(point, 0));
            }

            return(snapshot.ReadToLineEndWhile(ref point, _ => true));
        }
示例#23
0
        public IEnumerable <ITagSpan <TextMarkerTag> > GetTags(NormalizedSnapshotSpanCollection spans)
        {
            if (spans.Count == 0) //there is no content in the buffer
            {
                yield break;
            }

            //don't do anything if the current SnapshotPoint is not initialized
            if (!CurrentChar.HasValue)
            {
                yield break;
            }

            //hold on to a snapshot of the current character
            SnapshotPoint currentChar = CurrentChar.Value;

            //if the requested snapshot isn't the same as the one the brace is on, translate our spans to the expected snapshot
            if (spans[0].Snapshot != currentChar.Snapshot)
            {
                currentChar = currentChar.TranslateTo(spans[0].Snapshot, PointTrackingMode.Positive);
            }

            if (currentChar.Position < spans[0].Snapshot.Length)
            {
                // Check if the current character is an open brace
                char ch = currentChar.GetChar();
                char closeCh;
                if (MatchBrace(currentChar, ch, true, out closeCh))
                {
                    SnapshotSpan pairSpan;
                    if (FindMatchingCloseChar(currentChar, ch, closeCh, View.TextViewLines.Count, out pairSpan))
                    {
                        yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(currentChar, 1), Blue));

                        yield return(new TagSpan <TextMarkerTag>(pairSpan, Blue));
                    }
                }
            }

            if (0 < currentChar.Position)
            {
                // Check if the previous character is a close brace (note, caret may be between a close brace and an open brace, in which case we'll tag two pairs)
                SnapshotPoint prevChar = currentChar - 1;
                char          ch       = prevChar.GetChar();
                char          openCh;
                if (MatchBrace(prevChar, ch, false, out openCh))
                {
                    SnapshotSpan pairSpan;
                    if (FindMatchingOpenChar(prevChar, openCh, ch, View.TextViewLines.Count, out pairSpan))
                    {
                        yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(prevChar, 1), Blue));

                        yield return(new TagSpan <TextMarkerTag>(pairSpan, Blue));
                    }
                }
            }
        }
        public IEnumerable <ITagSpan <TextMarkerTag> > GetTags(NormalizedSnapshotSpanCollection spans)
        {
            if (spans.Count == 0)
            {
                yield break;
            }

            // don't do anything if the current SnapshotPoint is not initialized or at the end of the buffer
            if (!CurrentChar.HasValue || CurrentChar.Value.Position >= CurrentChar.Value.Snapshot.Length)
            {
                yield break;
            }

            // hold on to a snapshot of the current character
            var currentChar = CurrentChar.Value;

            if (IsInCommentOrLiteral(Aggregator, currentChar, TextView.Caret.Position.Affinity))
            {
                yield break;
            }

            // if the requested snapshot isn't the same as the one the brace is on, translate our spans to the expected snapshot
            currentChar = currentChar.TranslateTo(spans[0].Snapshot, PointTrackingMode.Positive);

            // get the current char and the previous char
            char currentText = currentChar.GetChar();
            // if current char is 0 (beginning of buffer), don't move it back
            SnapshotPoint lastChar = currentChar == 0 ? currentChar : currentChar - 1;
            char          lastText = lastChar.GetChar();
            SnapshotSpan  pairSpan = new SnapshotSpan();

            if (IsMatchStartCharacter(currentText))
            {
                char closeChar = GetMatchCloseCharacter(currentText);

                /* TODO: Need to improve handling of larger blocks. this won't highlight if the matching brace is more
                 *       than 1 screen's worth of lines away. Changing this to 10 * TextView.TextViewLines.Count seemed
                 *       to improve the situation.
                 */
                if (BraceMatchingTagger.FindMatchingCloseChar(currentChar, Aggregator, currentText, closeChar, TextView.TextViewLines.Count, out pairSpan))
                {
                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(currentChar, 1), BraceHighlightTag));

                    yield return(new TagSpan <TextMarkerTag>(pairSpan, BraceHighlightTag));
                }
            }
            else if (IsMatchCloseCharacter(lastText))
            {
                var open = GetMatchOpenCharacter(lastText);
                if (BraceMatchingTagger.FindMatchingOpenChar(lastChar, Aggregator, open, lastText, TextView.TextViewLines.Count, out pairSpan))
                {
                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(lastChar, 1), BraceHighlightTag));

                    yield return(new TagSpan <TextMarkerTag>(pairSpan, BraceHighlightTag));
                }
            }
        }
        public static SnapshotSpan ReadExact(this ITextSnapshot snapshot, ref SnapshotPoint point, char @char)
        {
            SnapshotPoint start = point;

            if (point < snapshot.Length && point.GetChar() == @char)
            {
                point = point + 1;
                return new SnapshotSpan(start, point);
            }

            return new SnapshotSpan(point, 0);
        }
示例#26
0
 /// <summary>
 /// Determine whether the provided triggerPoint is in a remark.
 /// </summary>
 /// <param name="triggerPoint"></param>
 /// <param name="lineStart"></param>
 /// <returns></returns>
 private static bool isRemark(SnapshotPoint triggerPoint, SnapshotPoint lineStart)
 {
     // check if the line contains a remark character before the current point
     for (SnapshotPoint pos = (triggerPoint - 1); pos >= lineStart; pos -= 1)
     {
         if (AsmTools.Tools.isRemarkChar(pos.GetChar()))
         {
             return(true);
         }
     }
     return(false);
 }
示例#27
0
        public CommitResult TryCommit(IAsyncCompletionSession session, ITextBuffer buffer, CompletionItem item, char typedChar, CancellationToken token)
        {
            var etoitem = item.Properties["eto"] as Designer.Completion.CompletionItem;

            // only complete on '.' for child properties.
            if (typedChar == '.' && !etoitem.Behavior.HasFlag(Designer.Completion.CompletionBehavior.ChildProperty))
            {
                return(CommitResult.Unhandled);
            }

            var span = session.ApplicableToSpan.GetSpan(buffer.CurrentSnapshot);

            span = FindTokenSpan(span);
            var text   = item.InsertText;
            var result = CommitResult.Handled;

            switch (typedChar)
            {
            case '.':
                if (!text.EndsWith("."))
                {
                    text += ".";
                }
                result = new CommitResult(true, CommitBehavior.CancelCommit | CommitBehavior.SuppressFurtherTypeCharCommandHandlers);
                break;

            case '/':
                text  += " />";
                result = new CommitResult(true, CommitBehavior.SuppressFurtherTypeCharCommandHandlers);
                break;

            case '\n':
                result = new CommitResult(true, CommitBehavior.RaiseFurtherReturnKeyAndTabKeyCommandHandlers);
                break;
            }
            var newSnapshot = buffer.Replace(span, text);
            var endLocation = new SnapshotPoint(newSnapshot, span.End.Position + text.Length - span.Length);

            switch (typedChar)
            {
            case '.':
                session.OpenOrUpdate(new CompletionTrigger(CompletionTriggerReason.Insertion, newSnapshot, '.'), endLocation, token);
                break;
            }
            var ch = endLocation.GetChar();

            if (ch == '\'' || ch == '"')
            {
                endLocation += 1;
                textView.Caret.MoveTo(endLocation);
            }
            return(result);
        }
示例#28
0
        private static bool IsFollowedByComment(SnapshotPoint point, ISplitCommentService splitCommentService)
        {
            var line = point.GetContainingLine();

            // skip past following whitespace.
            while (point < line.End && char.IsWhiteSpace(point.GetChar()))
            {
                point += 1;
            }

            return(MatchesCommentStart(splitCommentService.CommentStart, point));
        }
        private ITrackingSpan FindApplicableSpan(ICompletionSession session)
        {
            // We eventually want to use an ITextStructureNavigator to expand the current point, but
            // first we have to teach it what out structure is.  For now, we just understand the Rtype
            // syntax directly.
            ////ITextStructureNavigator navigator = this.sourceProvider.NavigatorService.GetTextStructureNavigator(this.textBuffer);

            ITextSnapshot  snapshot     = session.TextView.TextSnapshot;
            ITrackingPoint triggerPoint = session.GetTriggerPoint(session.TextView.TextBuffer);

            // Look left and right until we're at a contextual break.
            SnapshotPoint initialPoint = triggerPoint.GetPoint(snapshot);
            SnapshotPoint leftPoint    = initialPoint;
            SnapshotPoint rightPoint   = initialPoint;

            ITextSnapshotLine line = leftPoint.GetContainingLine();

            // look left...
            if (leftPoint > line.Start)
            {
                leftPoint -= 1;
                while (leftPoint > line.Start && CompletionSource.IsTokenTermCharacter(leftPoint.GetChar()))
                {
                    leftPoint -= 1;
                }

                // If we bailed because of the character, advance back to the right.
                if (!CompletionSource.IsTokenTermCharacter(leftPoint.GetChar()))
                {
                    leftPoint += 1;
                }
            }

            // look right...
            // In theory, we might need to include spaces that are inside a quoted region, but we don't know if we've
            // just added the start-quote and might over-extend the selection.  It's safer to be conservative even if
            // it means leaving cruft in the buffer... it's easier for the user to delete the extra than to recover it if
            // we removed it.
            while (rightPoint < line.End && CompletionSource.IsTokenTermCharacter(rightPoint.GetChar()))
            {
                rightPoint += 1;
            }

            ITrackingSpan applicableSpan = snapshot.CreateTrackingSpan(
                leftPoint,
                rightPoint - leftPoint,
                SpanTrackingMode.EdgeInclusive);

            ////System.Diagnostics.Debug.WriteLine("**FindApplicableSpan: final span={0} ('{1}')", applicableSpan, applicableSpan.GetText(leftPoint.Snapshot));

            return(applicableSpan);
        }
        public static SnapshotSpan ReadToLineEndWhile(this ITextSnapshot snapshot, ref SnapshotPoint point, Predicate<char> predicate, bool rewindWhiteSpace = true)
        {
            SnapshotPoint start = point;

            while (
                point.Position < snapshot.Length &&
                point.GetChar() != '\n' && point.GetChar() != '\r' &&
                predicate(point.GetChar())
            )
                point = point + 1;

            if (rewindWhiteSpace)
            {
                while (
                    point - 1 >= start &&
                    Char.IsWhiteSpace((point - 1).GetChar())
                )
                    point = point - 1;
            }

            return new SnapshotSpan(start, point);
        }
示例#31
0
        private static SnapshotSpan CalculateApplicableToSpan(SnapshotPoint triggerPoint, ITextSnapshotLine line)
        {
            SnapshotPoint start = line.Start;

            while (start < triggerPoint && char.IsWhiteSpace(start.GetChar()))
            {
                start += 1;
            }

            var applicableToSpan = new SnapshotSpan(start, triggerPoint);

            return(applicableToSpan);
        }
        public static SnapshotSpan ReadDelimiter(this ITextSnapshot snapshot, ref SnapshotPoint point)
        {
            if (point.Position == snapshot.Length)
                return new SnapshotSpan(point, 0);

            var @char = point.GetChar();

            if (@char != RobotsTxtSyntaxFacts.NameValueDelimiter)
                return new SnapshotSpan(point, 0);

            point = point + 1;
            return new SnapshotSpan(point - 1, 1);
        }
示例#33
0
        private SnapshotPoint?FindFirstNonWhiteSpaceChar(ITextViewLine line)
        {
            SnapshotSpan span = line.Extent;

            for (SnapshotPoint i = span.Start; i < span.End; i += 1)
            {
                if (!Char.IsWhiteSpace(i.GetChar()))
                {
                    return(i);
                }
            }
            return(null);
        }
示例#34
0
        public IEnumerable <ITagSpan <TextMarkerTag> > GetTags(NormalizedSnapshotSpanCollection spans)
        {
            // Don't do anything if there is no content in the buffer or
            // the current SnapshotPoint is not initialized or at the end of the buffer .
            if (spans.Count == 0 || !_currentChar.HasValue || _currentChar.Value.Position > _currentChar.Value.Snapshot.Length)
            {
                yield break;
            }

            // If the requested snapshot isn't the same as the one the brace is on, translate our spans to the expected snapshot.
            SnapshotPoint currentChar = _currentChar.Value;

            if (spans[0].Snapshot != currentChar.Snapshot)
            {
                currentChar = currentChar.TranslateTo(spans[0].Snapshot, PointTrackingMode.Positive);
            }

            // Get the current char and the previous char.
            SnapshotPoint lastChar = currentChar == 0 ? currentChar : currentChar - 1;
            SnapshotSpan  pairSpan = new SnapshotSpan();
            char          currentText;
            char          lastText;
            char          closeChar;

            if (currentChar.Position < currentChar.Snapshot.Length - 1 &&
                _braceList.TryGetValue(currentText = currentChar.GetChar(), out closeChar))
            {
                // The value is an opening brace, which is the *next/current* character, we will find the closing character.
                if (BraceMatchingTagger.FindMatchingCloseChar(currentChar, currentText, closeChar, _view.TextViewLines.Count, out pairSpan) == true)
                {
                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(currentChar, 1), _tag));

                    yield return(new TagSpan <TextMarkerTag>(pairSpan, _tag));
                }
            }
            else if (currentChar.Snapshot.Length > 1 &&
                     lastChar.Position < currentChar.Snapshot.Length &&
                     _braceList.ContainsValue(lastText = lastChar.GetChar()))
            {
                // The value is a closing brace, which is the *previous* character, we will find the opening character.
                var open = from n in _braceList
                           where n.Value.Equals(lastText)
                           select n.Key;
                if (BraceMatchingTagger.FindMatchingOpenChar(lastChar, open.Single(), lastText, _view.TextViewLines.Count, out pairSpan) == true)
                {
                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(lastChar, 1), _tag));

                    yield return(new TagSpan <TextMarkerTag>(pairSpan, _tag));
                }
            }
        }
        public IEnumerable <ITagSpan <TextMarkerTag> > GetTags(NormalizedSnapshotSpanCollection spans)
        {
            if (spans.Count == 0)
            { //there is no content in the buffer
                yield break;
            }
            //don't do anything if the current SnapshotPoint is not initialized or at the end of the buffer
            if (!this.currentChar_.HasValue || this.currentChar_.Value.Position >= this.currentChar_.Value.Snapshot.Length)
            {
                yield break;
            }
            //hold on to a snapshot of the current character
            SnapshotPoint currentChar = this.currentChar_.Value;

            //if the requested snapshot isn't the same as the one the brace is on, translate our spans to the expected snapshot
            if (spans[0].Snapshot != currentChar.Snapshot)
            {
                currentChar = currentChar.TranslateTo(spans[0].Snapshot, PointTrackingMode.Positive);
            }

            //get the current char and the previous char
            char          currentText = currentChar.GetChar();
            SnapshotPoint lastChar    = currentChar == 0 ? currentChar : currentChar - 1; //if currentChar is 0 (beginning of buffer), don't move it back
            char          lastText    = lastChar.GetChar();
            SnapshotSpan  pairSpan    = default(SnapshotSpan);

            if (this.braceList_.ContainsKey(currentText))
            { //the key is the open brace
                this.braceList_.TryGetValue(currentText, out char closeChar);
                if (FindMatchingCloseChar(currentChar, currentText, closeChar, this.view_.TextViewLines.Count, out pairSpan) == true)
                {
                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(currentChar, 1), new TextMarkerTag("blue")));

                    yield return(new TagSpan <TextMarkerTag>(pairSpan, new TextMarkerTag("blue")));
                }
            }
            else if (this.braceList_.ContainsValue(lastText))
            { //the value is the close brace, which is the *previous* character
                IEnumerable <char> open = from n in this.braceList_
                                          where n.Value.Equals(lastText)
                                          select n.Key;
                if (FindMatchingOpenChar(lastChar, open.ElementAt(0), lastText, this.view_.TextViewLines.Count, out pairSpan) == true)
                {
                    yield return(new TagSpan <TextMarkerTag>(new SnapshotSpan(lastChar, 1), new TextMarkerTag("blue")));

                    yield return(new TagSpan <TextMarkerTag>(pairSpan, new TextMarkerTag("blue")));
                }
            }
        }
        void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            ITextSnapshot snapshot     = m_textBuffer.CurrentSnapshot;
            SnapshotPoint?triggerPoint = session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
            {
                return;
            }
            SnapshotPoint end   = triggerPoint.Value;
            SnapshotPoint start = end;

            // go back to either a delimiter, a whitespace char or start of line.
            while (start > 0)
            {
                SnapshotPoint prev = start - 1;
                if (IsWhiteSpaceOrDelimiter(prev.GetChar()))
                {
                    break;
                }
                start += -1;
            }

            var span = new SnapshotSpan(start, end);
            // The ApplicableTo span is what text will be replaced by the completion item
            ITrackingSpan applicableTo = snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeInclusive);

            var bindings = m_textBuffer.Properties["SchemeBindings"] as Dictionary <string, BindingType>;

            m_compList = new List <Completion>();

            foreach (string key in bindings.Keys.OrderBy(x => x))
            {
                var str = key;
                var v   = bindings[key];
                if (v != BindingType.Record)
                {
                    m_compList.Add(new Completion(str, str, v.ToString(), v == BindingType.Procedure ? procedure_image : syntax_image, null));
                }
            }

            completionSets.Add(new CompletionSet(
                                   "Tokens", //the non-localized title of the tab
                                   "Tokens", //the display title of the tab
                                   applicableTo,
                                   m_compList,
                                   null));
        }
示例#37
0
 public void GetCharOrDefault2()
 {
     Create("foo", "bar");
     var endPoint = new SnapshotPoint(_buffer.CurrentSnapshot, _buffer.CurrentSnapshot.Length);
     var didSee = false;
     try
     {
         var notUsed = endPoint.GetChar();
     }
     catch (ArgumentException)
     {
         didSee = true;
     }
     Assert.IsTrue(didSee);
     Assert.AreEqual('f', SnapshotPointUtil.GetCharOrDefault(endPoint, 'f'));
 }
示例#38
0
        private static string GetVariableNameAndSpan(SnapshotPoint point, out SnapshotSpan span)
        {
            var line = point.GetContainingLine();
            var hoveredIndex = point.Position - line.Start.Position;

            var c = point.GetChar();
            if (!Char.IsDigit(c) && !Char.IsLetter(c) && (c != '_'))
            {
                span = new SnapshotSpan();
                return null;
            }

            // Find the name of the variable under the mouse pointer (ex: 'gesture.Pose.Name' when the mouse is hovering over the 'o' of pose)
            var match = m_variableExtractor.Matches(line.GetText()).OfType<Match>().SingleOrDefault(x => x.Index <= hoveredIndex && (x.Index + x.Length) >= hoveredIndex);
            if ((match == null) || (match.Value.Length == 0))
            {
                span = new SnapshotSpan();
                return null;
            }
            var name = match.Value;

            // Find the first '.' after the hoveredIndex and cut it off
            int relativeIndex = hoveredIndex - match.Index;
            var lastIndex = name.IndexOf('.', relativeIndex);
            if (lastIndex >= 0)
            {
                name = name.Substring(0, lastIndex);
            }
            else
            {
                lastIndex = name.Length;
            }

            var matchStartIndex = name.LastIndexOf('.', relativeIndex) + 1;
            span = new SnapshotSpan(line.Start.Add(match.Index + matchStartIndex), lastIndex - matchStartIndex);

            return name;
        }
示例#39
0
        private static SnapshotSpan GetWordSpanFromPosition(SnapshotPoint positon)
        {
            if (positon.Position >= positon.Snapshot.Length)
                return new SnapshotSpan(positon, 0);

            char charAtPos = positon.GetChar();
            string text = positon.Snapshot.GetText();
            ITextSnapshotLine lineSnapshot = positon.Snapshot.GetLineFromPosition(positon);
            int left, right;
            left = right = positon.Position;

            if (IsWordChar(charAtPos))
            {
                while (left - 1 >= lineSnapshot.Start.Position && IsWordChar(text[left - 1]))
                {
                    left--;
                }
                while (right + 1 < lineSnapshot.End.Position && IsWordChar(text[right + 1]))
                {
                    right++;
                }

                return new SnapshotSpan(positon.Snapshot, left, right + 1 - left);
            }
            else
            {
                return new SnapshotSpan(positon, 1);
            }
        }
 private string GetCompleteStatement(
   ITextSnapshot snapshot, SnapshotPoint snapPos, out StringBuilder sbErrors, out ITree treeStmt)
 {
   int position = snapPos.Position;
   StringBuilder sb = new StringBuilder();
   CommonTokenStream tokens;
   string sql = snapshot.GetText();
   MySQL51Parser.statement_list_return r = 
     LanguageServiceUtil.ParseSql( sql, false, out sb, out tokens);
   sbErrors = sb;
   if (sbErrors.Length != 0)
     position--;
   StringBuilder sbTokens = new StringBuilder();
   ITree t = r.Tree as ITree;
   treeStmt = t;
   if (t.IsNil)
   {
     ITree child = null;
     for (int idx = 0; idx < t.ChildCount; idx++)
     {
       child = t.GetChild(idx);
       if (child.TokenStartIndex == -1 || child.TokenStopIndex == -1) return null;
       if ((position >= tokens.Get(child.TokenStartIndex).StartIndex) &&
           (position <= tokens.Get(child.TokenStopIndex).StopIndex))
       {
         break;
       }
     }
     treeStmt = child;
   }
   else
   {
     treeStmt = t;        
   }
   //int upperToken = (sb.Length == 0) ? treeStmt.TokenStopIndex - 1 : treeStmt.TokenStopIndex;
   string sqlOutput;
   int lastToken = treeStmt.TokenStopIndex;
   // Get last not EOF token
   while (tokens.Get(lastToken).Text == "<EOF>" && lastToken > 0)
     lastToken--;
   int len = 
     tokens.Get( treeStmt.TokenStopIndex ).StopIndex - 
     tokens.Get( treeStmt.TokenStartIndex ).StartIndex + 1;
   if (char.IsWhiteSpace(snapPos.GetChar()))
   {
     sqlOutput = sql.Substring(tokens.Get(treeStmt.TokenStartIndex).StartIndex,
       Math.Min(len, sql.Length - tokens.Get(treeStmt.TokenStartIndex).StartIndex));
   }
   else
   {
     // remove last token
     // sometimes the parser itself removes the last token.
     if ((sbErrors.Length == 0) || (tokens.Get(lastToken).StopIndex - 1 == position))
     {
       if (tokens.Get(lastToken).StopIndex - 1 == position && 
         lastToken != treeStmt.TokenStartIndex && lastToken > 0  ) lastToken--;
       int start = tokens.Get(treeStmt.TokenStartIndex).StartIndex,
         stop = tokens.Get( lastToken ).StartIndex;
       sqlOutput = sql.Substring(start, Math.Min(stop - start, sql.Length - start));
     }
     else
     {
       sqlOutput = sql.Substring(tokens.Get(treeStmt.TokenStartIndex).StartIndex, 
         Math.Min(len, sql.Length - tokens.Get(treeStmt.TokenStartIndex).StartIndex));
     }
   }
   //if ( /*treeStmt.TokenStartIndex < treeStmt.TokenStopIndex && */
   //    char.IsWhiteSpace(snapPos.GetChar()))
   //{
   //  stop = tokens.Get(treeStmt.TokenStopIndex - 1).StopIndex;
   //}
   //else
   //{
   //  stop = tokens.Get(treeStmt.TokenStopIndex).StartIndex;
   //}
   //int start = tokens.Get(treeStmt.TokenStartIndex).StartIndex;
   //  //stop = tokens.Get(upperToken).StopIndex;
   ////string sqlOutput = sql.Substring(start, Math.Min(stop - start + 1, sql.Length - start));
   
   //if (treeStmt is CommonErrorNode || sbErrors.Length != 0)
   //{
   //  sqlOutput = sql.Substring(start, sql.Length - start);
   //}
   //else
   //{
   //  sqlOutput = sql.Substring(start, Math.Min(stop - start + 1, sql.Length - start));
   //}
   treeStmt = LanguageServiceUtil.ParseSql(sqlOutput, false, out sbErrors).Tree as ITree;
   return sqlOutput;      
 }
示例#41
0
        // returns true if brace is actually a brace.
        private bool FindOtherBrace(SnapshotPoint possibleBrace, out SnapshotPoint? otherBrace)
        {
            otherBrace = null;
              var rainbow = this.textBuffer.Get<RainbowProvider>();
              if ( rainbow == null ) {
            return false;
              }
              if ( !possibleBrace.IsValid() ) {
            return false;
              }

              if ( !rainbow.BraceCache.Language.BraceList.Contains(possibleBrace.GetChar()) ) {
            return false;
              }
              var bracePair = rainbow.BraceCache.GetBracePair(possibleBrace);
              if ( bracePair == null ) {
            return true;
              }
              if ( possibleBrace.Position == bracePair.Item1.Position ) {
            otherBrace = bracePair.Item2.ToPoint(possibleBrace.Snapshot);
              } else {
            otherBrace = bracePair.Item1.ToPoint(possibleBrace.Snapshot);
              }
              return true;
        }
示例#42
0
文件: WordParser.cs 项目: 0xd4d/dnSpy
		static WordKind GetWordKind(SnapshotPoint currentPosition) {
			if (currentPosition.Position >= currentPosition.Snapshot.Length)
				return WordKind.Whitespace;
			return GetWordKind(currentPosition.GetChar());
		}
        private void AddAdornments()
        {
            Debug.Assert(_easyMotionUtil.State == EasyMotionState.LookingForDecision);

            if (_wpfTextView.InLayout)
            {
                return;
            }

            _navigateMap.Clear();
            var textViewLines = _wpfTextView.TextViewLines;
            var startPoint = textViewLines.FirstVisibleLine.Start;
            var endPoint = textViewLines.LastVisibleLine.End;
            var snapshot = startPoint.Snapshot;

            var count = 0;
            for (int i = startPoint.Position; i < endPoint.Position; i++)
            {
                var point = new SnapshotPoint(snapshot, i);
                if (char.ToLower(point.GetChar()) == char.ToLower(_easyMotionUtil.TargetChar))
                {
                    count++;
                }
            }
            var navigationKeys = _navigationKeysShort;
            if (count > _navigationKeysShort.Length)
            {
                navigationKeys = _navigationKeysLong;
            }
            int navigateIndex = 0;
            for (int i = startPoint.Position; i < endPoint.Position; i++)
            {
                var point = new SnapshotPoint(snapshot, i);

                if (char.ToLower(point.GetChar()) == char.ToLower(_easyMotionUtil.TargetChar) && navigateIndex < navigationKeys.Length)
                {
                    var key = navigationKeys[navigateIndex];
                    navigateIndex++;
                    AddNavigateToPoint(textViewLines, point, key);
                }
            }

            if (navigateIndex == 0)
            {
                _easyMotionUtil.ChangeToLookingCharNotFound();
            }
        }