Esempio n. 1
0
        private static string TryGetDescriptionToTheRight(IDocumentTokenizer tokenizer, ITokenizerResult tokenizerResult, SnapshotPoint tokenEnd)
        {
            var currentLine        = tokenEnd.GetContainingLine();
            var currentLineComment = tokenizerResult
                                     .GetTokens(new Span(tokenEnd, currentLine.End - tokenEnd))
                                     .Where(t => tokenizer.IsTypeOf(t.Type, RadAsmTokenType.Comment))
                                     .ToList();

            if (currentLineComment.Count == 0)
            {
                return(null);
            }

            var text = currentLineComment
                       .First()
                       .GetText(tokenEnd.Snapshot);

            return(GetCommentText(text));
        }
Esempio n. 2
0
        private static string TryGetDescriptionAbove(IDocumentTokenizer tokenizer, ITokenizerResult tokenizerResult, SnapshotPoint tokenEnd)
        {
            var lines             = new LinkedList <string>();
            var currentLineNumber = tokenEnd.GetContainingLine().LineNumber - 1;
            var snapshot          = tokenEnd.Snapshot;

            while (currentLineNumber >= 0)
            {
                var currentLine        = snapshot.GetLineFromLineNumber(currentLineNumber);
                var currentLineComment = tokenizerResult
                                         .GetTokens(new Span(currentLine.Start, currentLine.Length))
                                         .ToList();

                // if there are some other tokens, then the comment ended
                if (currentLineComment.Any(t =>
                                           !tokenizer.IsTypeOf(t.Type, RadAsmTokenType.Comment) &&
                                           !tokenizer.IsTypeOf(t.Type, RadAsmTokenType.Whitespace)))
                {
                    break;
                }

                currentLineComment.RemoveAll(t =>
                                             tokenizer.IsTypeOf(t.Type, RadAsmTokenType.Whitespace));

                if (currentLineComment.Count != 1)
                {
                    break;
                }

                var trackingToken = currentLineComment.First();
                var tokenSpan     = new SnapshotSpan(snapshot, trackingToken.GetSpan(snapshot));
                var tokenText     = GetCommentText(tokenSpan.GetText());

                lines.AddFirst(tokenText);
                currentLineNumber = tokenSpan.Start.GetContainingLine().LineNumber - 1;
            }

            return(lines.Count != 0
                ? string.Join(System.Environment.NewLine, lines)
                : null);
        }