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

Recommenders for data and with #43971

Merged
merged 7 commits into from
May 7, 2020
Merged

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented May 5, 2020

The data recommender is similar to that for public.
The with recommender is like the one for as.

@CyrusNajmabadi
Copy link
Member

What is hte 'data' keyword?

@jcouv
Copy link
Member Author

jcouv commented May 5, 2020

What is hte 'data' keyword?

It's the current keyword for records: data class Person(string first, string last) { }

https://github.com/dotnet/csharplang/blob/master/proposals/records-wip.md

@jcouv jcouv marked this pull request as ready for review May 5, 2020 22:11
@jcouv jcouv requested a review from a team as a code owner May 5, 2020 22:11
@jcouv jcouv closed this May 6, 2020
@jcouv jcouv reopened this May 6, 2020
@jcouv
Copy link
Member Author

jcouv commented May 6, 2020

@CyrusNajmabadi for review. Thanks

@@ -5061,7 +5061,7 @@ class C
</Document>,
showCompletionInArgumentLists:=showCompletionInArgumentLists)

state.SendTypeChars("w")
state.SendTypeChars("z")
Copy link
Member

Choose a reason for hiding this comment

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

intresting :D

{
return
context.IsGlobalStatementContext ||
context.TargetToken.IsUsingKeywordInUsingDirective() ||
Copy link
Member

Choose a reason for hiding this comment

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

why this line?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, I'll remove. This is a bad carry-over from the static recommender I started from.

return CheckPreviousModifiers(context);
}

return false;
Copy link
Member

Choose a reason for hiding this comment

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

do we have test with things like ref data partial struct (and permutations)?

Copy link
Member

Choose a reason for hiding this comment

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

question still applies

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I thought I addressed that comment. We have a test for partial $$ and one for ref $$. I don't think that what follows the $$ matters, but I can add such tests if you think it's useful.

Copy link
Member

Choose a reason for hiding this comment

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

data is a contextual keyword only directly before class at the moment, so if anything here relies on data being a contextual keyword, that won't work.

Copy link
Member Author

Choose a reason for hiding this comment

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

@agocke I've already accounted for that, since you won't have typed class at the time you want to type data. We had a similar problem with partial or ref I think.

Comment on lines 29 to 32
validModifiers: SyntaxKindSet.AllTypeModifiers,
validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
canBePartial: true,
cancellationToken: cancellationToken))
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
validModifiers: SyntaxKindSet.AllTypeModifiers,
validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
canBePartial: true,
cancellationToken: cancellationToken))
validModifiers: SyntaxKindSet.AllTypeModifiers,
validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
canBePartial: true,
cancellationToken: cancellationToken))


#if !CODE_STYLE
private const uint DotDotTokenValueAssertion = -(DataKeyword - SyntaxKind.DataKeyword);
#endif
Copy link
Member

Choose a reason for hiding this comment

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

what's this?

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 is explained below. I forgot to rename the constant though. Will fix

@jcouv jcouv requested a review from CyrusNajmabadi May 7, 2020 03:48
{
var precedingModifiers = context.PrecedingModifiers;
return !precedingModifiers.Contains(SyntaxKind.DataKeyword);
}
Copy link
Member

Choose a reason for hiding this comment

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

this entire method is tiny. i would just inline the entire thing.

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 tried to keep a similar structure to others. I'll adjust in a follow-up PR (want to get this in for demo bits)

@jcouv jcouv merged commit 8663fb4 into dotnet:features/records May 7, 2020
@jcouv jcouv deleted the records-recommend branch May 7, 2020 15:18
@jcouv
Copy link
Member Author

jcouv commented May 7, 2020

FYI @agocke fixed recommenders for class, data and with (in feature branch). WIll merge into demo branch (PR #44048)
Today, I'll take a look at other completion/formatting scenarios today in demo branch (using new syntax).

@jcouv jcouv mentioned this pull request May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants