From 8a55725513152f114d5549c00a80f4c53ae08ae1 Mon Sep 17 00:00:00 2001 From: Josef Pihrt Date: Tue, 29 Dec 2020 05:05:46 +0100 Subject: [PATCH] Add cancellation checks --- .../CSharp/FixFormattingOfBinaryExpressionChainAnalyzer.cs | 2 ++ .../CSharp/FixFormattingOfCallChainAnalyzer.cs | 2 ++ src/Formatting.Analyzers/CSharp/FixFormattingOfListAnalyzer.cs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/Formatting.Analyzers/CSharp/FixFormattingOfBinaryExpressionChainAnalyzer.cs b/src/Formatting.Analyzers/CSharp/FixFormattingOfBinaryExpressionChainAnalyzer.cs index 842f9eb9ed..db74597a61 100644 --- a/src/Formatting.Analyzers/CSharp/FixFormattingOfBinaryExpressionChainAnalyzer.cs +++ b/src/Formatting.Analyzers/CSharp/FixFormattingOfBinaryExpressionChainAnalyzer.cs @@ -57,6 +57,8 @@ private static void AnalyzeBinaryExpression(SyntaxNodeAnalysisContext context) while (true) { + context.CancellationToken.ThrowIfCancellationRequested(); + ExpressionSyntax left = binaryExpression.Left; SyntaxToken token = binaryExpression.OperatorToken; diff --git a/src/Formatting.Analyzers/CSharp/FixFormattingOfCallChainAnalyzer.cs b/src/Formatting.Analyzers/CSharp/FixFormattingOfCallChainAnalyzer.cs index ba3decbb76..611e86ee87 100644 --- a/src/Formatting.Analyzers/CSharp/FixFormattingOfCallChainAnalyzer.cs +++ b/src/Formatting.Analyzers/CSharp/FixFormattingOfCallChainAnalyzer.cs @@ -53,6 +53,8 @@ private static void AnalyzeExpression(SyntaxNodeAnalysisContext context) do { + context.CancellationToken.ThrowIfCancellationRequested(); + SyntaxKind kind = en.Current.Kind(); if (kind == SyntaxKind.SimpleMemberAccessExpression) diff --git a/src/Formatting.Analyzers/CSharp/FixFormattingOfListAnalyzer.cs b/src/Formatting.Analyzers/CSharp/FixFormattingOfListAnalyzer.cs index 914f0de2e2..7a49374a2b 100644 --- a/src/Formatting.Analyzers/CSharp/FixFormattingOfListAnalyzer.cs +++ b/src/Formatting.Analyzers/CSharp/FixFormattingOfListAnalyzer.cs @@ -170,6 +170,8 @@ private static void Analyze( for (int i = nodes.Count - 1; i >= 0; i--) { + context.CancellationToken.ThrowIfCancellationRequested(); + SyntaxTriviaList trailing = (i == 0) ? openNodeOrToken.GetTrailingTrivia() : nodes.GetSeparator(i - 1).TrailingTrivia;