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

Work some 'scoped' issues on IDE #65407

Merged
merged 18 commits into from
Nov 24, 2022
Merged

Conversation

Youssef1313
Copy link
Member

Related to: #64906

Fixes #65403

@Youssef1313 Youssef1313 requested a review from a team as a code owner November 14, 2022 09:29
@ghost ghost added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Nov 14, 2022
@Youssef1313 Youssef1313 marked this pull request as draft November 14, 2022 12:31
@Youssef1313 Youssef1313 marked this pull request as ready for review November 14, 2022 13:17
@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Nov 14, 2022

@cston scoped is still in preview right?


In reply to: 1314272868

@@ -36,7 +36,7 @@ private static bool IsInParameterModifierContext(int position, CSharpSyntaxConte
if (context.SyntaxTree.IsParameterModifierContext(
position, context.LeftToken, includeOperators: true, out var parameterIndex, out var previousModifier))
{
if (previousModifier == SyntaxKind.None)
if (previousModifier is SyntaxKind.None or SyntaxKind.ScopedKeyword)
Copy link
Member

Choose a reason for hiding this comment

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

this feels odd. IsParameterModifierContext should understand Scoped itself right?

Copy link
Member Author

Choose a reason for hiding this comment

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

@CyrusNajmabadi I'm not sure what you mean?

Copy link
Member

Choose a reason for hiding this comment

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

oh, misread. sorry.

Copy link
Member

Choose a reason for hiding this comment

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

can you say this scoped?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think yes. this scoped is valid. I'll add tests for this scoped, this ref, this in, this scoped ref, and this scoped in.

@cston
Copy link
Member

cston commented Nov 14, 2022

@cston scoped is still in preview right?

scoped is no longer in preview; it is available in C#11 with -langversion:11.


In reply to: 1314281670

@CyrusNajmabadi
Copy link
Member

I can look tomorrow. Thanks!

Comment on lines +45 to +46
var previous = token.GetPreviousToken(includeSkipped: true);
return previous.Kind() is SyntaxKind.ForKeyword or SyntaxKind.ForEachKeyword;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var previous = token.GetPreviousToken(includeSkipped: true);
return previous.Kind() is SyntaxKind.ForKeyword or SyntaxKind.ForEachKeyword;
return token.Parent is ForStatementSyntax or CommonForEachStatementSyntax;

Copy link
Member Author

Choose a reason for hiding this comment

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

@CyrusNajmabadi I'm following the same logic as in other keyword recommenders. I think if a change is needed here it should be in all recommenders?

{
parent = token.Parent.Parent;
}
else if (token.IsKind(SyntaxKind.IdentifierToken) && token.Text == "scoped" && token.Parent is IdentifierNameSyntax scopedIdentifierName && scopedIdentifierName.Parent.IsKind(SyntaxKind.Parameter))
Copy link
Member

Choose a reason for hiding this comment

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

feel like there's somet repititino of these checks. but i don't feel strongly about it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@CyrusNajmabadi Could we leave the refactoring for a separate PR?

Copy link
Member

Choose a reason for hiding this comment

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

As mentioned, I don't feel strongly about it. :-)

await VerifyKeywordAsync("""
static class C
{
static void M(this scoped $$)
Copy link
Member Author

Choose a reason for hiding this comment

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

out isn't valid here, but I thought it's not a big deal to offer it for simplicity?

@Youssef1313
Copy link
Member Author

Youssef1313 commented Nov 17, 2022

Merging latest main and re-triggering CI because #65262 might have an impact on the logic in this PR

@Youssef1313
Copy link
Member Author

@CyrusNajmabadi Othan than flaky tests, everything appears to be passing. This can either be merged as is, or revised to make sure there are no dead checks after the parser changes. Unfortunately, I won't be able to validate now if there are dead checks or not.

@Youssef1313
Copy link
Member Author

@CyrusNajmabadi Can you restart CI here? Thanks!

@CyrusNajmabadi CyrusNajmabadi merged commit 62646c2 into dotnet:main Nov 24, 2022
@ghost ghost added this to the Next milestone Nov 24, 2022
@Youssef1313 Youssef1313 deleted the scoped-ide branch November 24, 2022 15:48
allisonchou added a commit to allisonchou/roslyn that referenced this pull request Nov 28, 2022
allisonchou added a commit that referenced this pull request Nov 28, 2022
@allisonchou allisonchou modified the milestones: Next, 17.5 P2 Nov 30, 2022
ryzngard added a commit that referenced this pull request Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

var keyword colorized on the case scoped var refStruct = expr;
5 participants