From aaa64ebaecad2d100eec7ffbcd4a79cb8c0c197e Mon Sep 17 00:00:00 2001 From: Jan Hindermann Date: Fri, 30 Nov 2018 22:15:54 +0100 Subject: [PATCH] Use directive trivia classification method --- .../Classification/Worker_Preprocesser.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Workspaces/CSharp/Portable/Classification/Worker_Preprocesser.cs b/src/Workspaces/CSharp/Portable/Classification/Worker_Preprocesser.cs index 430c46a626c..85e028ae0da 100644 --- a/src/Workspaces/CSharp/Portable/Classification/Worker_Preprocesser.cs +++ b/src/Workspaces/CSharp/Portable/Classification/Worker_Preprocesser.cs @@ -263,20 +263,16 @@ private void ClassifyPragmaWarningDirective(PragmaWarningDirectiveTriviaSyntax n AddClassification(node.WarningKeyword, ClassificationTypeNames.PreprocessorKeyword); AddClassification(node.DisableOrRestoreKeyword, ClassificationTypeNames.PreprocessorKeyword); - // Comments after a "#pragma warning" directive without any error codes are trailing trivia of the "disable"/"restore" token. - foreach (var syntaxTrivia in node.DisableOrRestoreKeyword.TrailingTrivia) + foreach (var nodeOrToken in node.ErrorCodes.GetWithSeparators()) { - if (syntaxTrivia.Kind() == SyntaxKind.WhitespaceTrivia) - { - // Skip the initial whitespace - continue; - } - ClassifyToken(syntaxTrivia.Token); + ClassifyNodeOrToken(nodeOrToken); } - foreach (var nodeOrToken in node.ErrorCodes.GetWithSeparators()) + if (node.ErrorCodes.Count == 0) { - ClassifyNodeOrToken(nodeOrToken); + // When there are no error codes, we need to classify the directive's trivia. + // (When there are error codes, ClassifyNodeOrToken above takes care of that.) + ClassifyDirectiveTrivia(node); } } -- GitLab