Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Extract method code (part 3) #76587

Merged
merged 12 commits into from
Jan 3, 2025

Conversation

CyrusNajmabadi
Copy link
Member

Followup to #76585

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 30, 2024
@@ -177,8 +177,8 @@ protected static async Task TestSelectionAsync(
Assert.True(status.Succeeded);
}

if (status.Succeeded && result.SelectionChanged)
Assert.Equal(namedSpans["r"].Single(), result.FinalSpan);
if (status.Succeeded && namedSpans.TryGetValue("r", out var revisedSpans))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these tests were busted. they only ran if the code set this boolean. meaning if the code didn't set the oolean, the test might still specify these spans, but not validate tehm. i've at least updated it to always validate if present.

@@ -25,9 +25,8 @@ internal abstract partial class CSharpSelectionResult
private sealed class ExpressionResult(
SemanticDocument document,
SelectionType selectionType,
TextSpan finalSpan,
bool selectionChanged) : CSharpSelectionResult(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this valiue. it was there to just signal data to tests, but iddn't affect behavior in any way.

@@ -7,7 +7,6 @@ namespace Microsoft.CodeAnalysis.ExtractMethod;
internal enum DeclarationBehavior
{
None,
Delete,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

completely unread. removed since i'm trying to wrap my head around all these values and what tjhey do.


public IEnumerable<VariableInfo> GetVariablesToMoveIntoMethodDefinition(CancellationToken cancellationToken)
=> Variables.Where(v => v.GetDeclarationBehavior(cancellationToken) == DeclarationBehavior.MoveIn);

public IEnumerable<VariableInfo> GetVariablesToMoveOutToCallSite(CancellationToken cancellationToken)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused.

status = TryCheckVariableType(semanticModel, context, analyzeResult.GetVariablesToSplitOrMoveIntoMethodDefinition(cancellationToken), status);
status = TryCheckVariableType(semanticModel, context, analyzeResult.MethodParameters, status);
status = TryCheckVariableType(semanticModel, context, analyzeResult.GetVariablesToMoveOutToCallSite(cancellationToken), status);
status = TryCheckVariableType(semanticModel, context, analyzeResult.GetVariablesToSplitOrMoveOutToCallSite(cancellationToken), status);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code was incredibly wacky. it seemed to be trying to slice the analyzeResult.Variables into all abutting subsets, to then check to see if particular disallowed types were used. But it could just access analyzeResult.Variables insetad.

@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review January 2, 2025 22:23
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner January 2, 2025 22:23
@CyrusNajmabadi
Copy link
Member Author

@JoeRobich @ToddGrun hopefully last cleanup pass PR.

@CyrusNajmabadi CyrusNajmabadi merged commit d29eff1 into dotnet:main Jan 3, 2025
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jan 3, 2025
@CyrusNajmabadi CyrusNajmabadi deleted the extractMethodCleanup5 branch January 3, 2025 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants