From b1b41e03ddc5e634a94644e367d130ef6cef4178 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 28 May 2020 09:40:33 -0700 Subject: [PATCH] Update TopSyntaxComparer for top-level statements --- .../CSharpTest/EditAndContinue/StatementEditingTests.cs | 2 +- .../CSharp/Portable/EditAndContinue/TopSyntaxComparer.cs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/EditAndContinue/StatementEditingTests.cs b/src/EditorFeatures/CSharpTest/EditAndContinue/StatementEditingTests.cs index 810650bdd95..a751e3608b9 100644 --- a/src/EditorFeatures/CSharpTest/EditAndContinue/StatementEditingTests.cs +++ b/src/EditorFeatures/CSharpTest/EditAndContinue/StatementEditingTests.cs @@ -9766,7 +9766,7 @@ public void TupleType_LocalVariables() "Update [y = (3, 4)]@56 -> [y2 = (3, 4)]@96"); } - [Fact(Skip = "https://github.com/dotnet/roslyn/issues/44423")] + [Fact] [WorkItem(44423, "https://github.com/dotnet/roslyn/issues/44423")] public void TupleElementName() { diff --git a/src/Features/CSharp/Portable/EditAndContinue/TopSyntaxComparer.cs b/src/Features/CSharp/Portable/EditAndContinue/TopSyntaxComparer.cs index 65005e0471f..bb8ec2d5684 100644 --- a/src/Features/CSharp/Portable/EditAndContinue/TopSyntaxComparer.cs +++ b/src/Features/CSharp/Portable/EditAndContinue/TopSyntaxComparer.cs @@ -106,6 +106,7 @@ internal enum Label IndexerDeclaration, // tied to parent EventDeclaration, // tied to parent EnumMemberDeclaration, // tied to parent + GlobalStatement, // tied to parent AccessorList, // tied to parent AccessorDeclaration, // tied to parent @@ -145,6 +146,7 @@ private static int TiedToAncestor(Label label) case Label.IndexerDeclaration: case Label.EventDeclaration: case Label.EnumMemberDeclaration: + case Label.GlobalStatement: case Label.AccessorDeclaration: case Label.AccessorList: case Label.TypeParameterList: @@ -172,9 +174,8 @@ internal static Label Classify(SyntaxKind kind, out bool isLeaf) return Label.CompilationUnit; case SyntaxKind.GlobalStatement: - // TODO: - isLeaf = true; - return Label.Ignored; + isLeaf = false; + return Label.GlobalStatement; case SyntaxKind.ExternAliasDirective: isLeaf = true; @@ -339,6 +340,7 @@ public override bool ValuesEqual(SyntaxNode left, SyntaxNode right) case SyntaxKind.SetAccessorDeclaration: case SyntaxKind.AddAccessorDeclaration: case SyntaxKind.RemoveAccessorDeclaration: + case SyntaxKind.GlobalStatement: // When comparing method bodies we need to NOT ignore VariableDeclaration and VariableDeclarator children, // but when comparing field definitions we should ignore VariableDeclarations children. @@ -375,6 +377,7 @@ private static SyntaxNode GetBody(SyntaxNode node) { case BaseMethodDeclarationSyntax baseMethodDeclarationSyntax: return baseMethodDeclarationSyntax.Body ?? (SyntaxNode)baseMethodDeclarationSyntax.ExpressionBody?.Expression; case AccessorDeclarationSyntax accessorDeclarationSyntax: return accessorDeclarationSyntax.Body ?? (SyntaxNode)accessorDeclarationSyntax.ExpressionBody?.Expression; + case GlobalStatementSyntax globalStatement: return globalStatement.Statement; default: throw ExceptionUtilities.UnexpectedValue(node); } } -- GitLab