Esempio n. 1
0
 internal static TextSpan GetCompletionItemSpan(SourceText text, int position) =>
 CommonCompletionUtilities.GetWordSpan(
     text,
     position,
     IsCompletionItemStartCharacter,
     IsWordCharacter
     );
Esempio n. 2
0
 private static TextSpan GetCompletionItemSpan(SourceText text, int position)
 {
     return(CommonCompletionUtilities.GetWordSpan(
                text,
                position,
                ch => CompletionUtilities.IsCompletionItemStartCharacter(ch) || ch == '{',
                ch => CompletionUtilities.IsWordCharacter(ch) || ch == '{' || ch == '}'));
 }
Esempio n. 3
0
        private static async Task <TextSpan> GetTextChangeSpanAsync(Document document, TextSpan startSpan, CancellationToken cancellationToken)
        {
            var result      = startSpan;
            var syntaxFacts = document.GetLanguageService <ISyntaxFactsService>();
            var root        = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            var token = root.FindToken(result.Start);

            if (syntaxFacts.IsStringLiteral(token) || syntaxFacts.IsVerbatimStringLiteral(token))
            {
                var text = root.GetText();

                // Expand selection in both directions until a double quote or any line break character is reached
                bool IsWordCharacter(char ch) => !(ch == '"' || TextUtilities.IsAnyLineBreakCharacter(ch));

                result = CommonCompletionUtilities.GetWordSpan(
                    text, startSpan.Start, IsWordCharacter, IsWordCharacter, alwaysExtendEndSpan: true);
            }

            return(result);
        }