/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Features/CSharp/Portable/Completion/CompletionProviders/Scripting/DirectiveCompletionProviderUtilities.cs
32 строки
1 KB
Cyrus Najmabadi
Update c# features to use file scoped namespaces
28 фев 2024, 00:31
28 фев 2024, 00:31
17e64d5
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Threading; using Microsoft.CodeAnalysis.CSharp.Extensions; namespace Microsoft.CodeAnalysis.CSharp.Completion.Providers; internal static class DirectiveCompletionProviderUtilities { internal static bool TryGetStringLiteralToken(SyntaxTree tree, int position, SyntaxKind directiveKind, out SyntaxToken stringLiteral, CancellationToken cancellationToken) { if (tree.IsEntirelyWithinStringLiteral(position, cancellationToken)) { var token = tree.GetRoot(cancellationToken).FindToken(position, findInsideTrivia: true); if (token.Kind() is SyntaxKind.EndOfDirectiveToken or SyntaxKind.EndOfFileToken) { token = token.GetPreviousToken(includeSkipped: true, includeDirectives: true); } if (token.Kind() == SyntaxKind.StringLiteralToken && token.Parent!.Kind() == directiveKind) { stringLiteral = token; return true; } } stringLiteral = default; return false; } }