Few more IDE scenarios for top-level statements#44455
Merged
jcouv merged 5 commits intodotnet:features/SimpleProgramsfrom May 21, 2020
Merged
Few more IDE scenarios for top-level statements#44455jcouv merged 5 commits intodotnet:features/SimpleProgramsfrom
jcouv merged 5 commits intodotnet:features/SimpleProgramsfrom
Conversation
Member
Author
|
Tagging @CyrusNajmabadi @sharwell @AlekseyTs |
Comment on lines
+84
to
+85
| var switchNode = switchLocation.FindNode(getInnermostNodeForTie: true, cancellationToken); | ||
| var switchStatement = (SwitchStatementSyntax)(switchNode); |
Contributor
There was a problem hiding this comment.
Suggested change
| var switchNode = switchLocation.FindNode(getInnermostNodeForTie: true, cancellationToken); | |
| var switchStatement = (SwitchStatementSyntax)(switchNode); | |
| var switchStatement = (SwitchStatementSyntax)switchLocation.FindNode(getInnermostNodeForTie: true, cancellationToken); |
Comment on lines
103
to
107
| if (nextStatement.IsParentKind(SyntaxKind.GlobalStatement)) | ||
| { | ||
| nextStatement = nextStatement.Parent; | ||
| } | ||
| editor.RemoveNode(nextStatement); |
Contributor
There was a problem hiding this comment.
Suggested change
| if (nextStatement.IsParentKind(SyntaxKind.GlobalStatement)) | |
| { | |
| nextStatement = nextStatement.Parent; | |
| } | |
| editor.RemoveNode(nextStatement); | |
| editor.RemoveNode(nextStatement.IsParentKind(SyntaxKind.GlobalStatement) ? nextStatement.Parent : nextStatement); |
(can keep teh var above as well).
| { | ||
| nodeToRemove = localFunction.Parent; | ||
| } | ||
| editor.RemoveNode(nodeToRemove); |
Contributor
There was a problem hiding this comment.
same feedback.
also, i'm really hating this pattern :-/
| { | ||
| editor.RemoveNode(localFunction); | ||
| SyntaxNode nodeToRemove = localFunction; | ||
| if (localFunction.Parent.Kind() == SyntaxKind.GlobalStatement) |
Contributor
There was a problem hiding this comment.
Suggested change
| if (localFunction.Parent.Kind() == SyntaxKind.GlobalStatement) | |
| if (localFunction.IsParentKind(SyntaxKind.GlobalStatement)) |
| { | ||
| node = node.Parent; | ||
| } | ||
| RemoveNode(editor, node, syntaxFacts); |
Comment on lines
+39
to
+49
| if (!one.IsParentKind(SyntaxKind.GlobalStatement)) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| if (!one.IsParentKind(SyntaxKind.GlobalStatement)) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| return one.Parent.Parent == other.Parent.Parent; |
Contributor
There was a problem hiding this comment.
Suggested change
| if (!one.IsParentKind(SyntaxKind.GlobalStatement)) | |
| { | |
| return false; | |
| } | |
| if (!one.IsParentKind(SyntaxKind.GlobalStatement)) | |
| { | |
| return false; | |
| } | |
| return one.Parent.Parent == other.Parent.Parent; | |
| return one.IsParentKind(SyntaxKind.GlobalStatement) && | |
| one.IsParentKind(SyntaxKind.GlobalStatement) && | |
| one.Parent.Parent == other.Parent.Parent; |
Contributor
There was a problem hiding this comment.
💭 The last condition is redundant. Global statements are always siblings if they are in the same tree.
CyrusNajmabadi
approved these changes
May 20, 2020
sharwell
reviewed
May 20, 2020
Comment on lines
+1916
to
+1922
| await VerifyCS.VerifyCodeFixAsync(source, new[] { | ||
| // error CS9004: Program using top-level statements must be an executable. | ||
| DiagnosticResult.CompilerError("CS9004"), | ||
| // error CS8652: The feature 'top-level statements' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. | ||
| DiagnosticResult.CompilerError("CS8652").WithSpan(2, 1, 2, 11).WithArguments("top-level statements"), | ||
| }, | ||
| fixedSource); |
Contributor
There was a problem hiding this comment.
📝 The test should be run with this feature enabled
await new VerifyCS.Test {
TestCode = source,
FixedCode = fixedSource,
LanguageVersion = LanguageVersion.Preview,
}.RunAsync();
sharwell
reviewed
May 20, 2020
| }"); | ||
| } | ||
|
|
||
| [WorkItem(44454, "https://github.com/dotnet/roslyn/issues/44454")] |
Contributor
There was a problem hiding this comment.
📝 Another pull request is already submitted to fix this
Member
Author
There was a problem hiding this comment.
Awesome. I'll remove this test.
This was referenced Sep 10, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #44272 (RemoveUnusedLocalFunction)
Fixes #44273 (RemoveUnusedVariable)
Fixes ConvertSwitchStatementToExpression