Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WIP: Possible alternate implementation of UseConsistentWhitespace CheckOperator feature#1607

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
daviesj wants to merge3 commits intoPowerShell:main
base:main
Choose a base branch
Loading
fromdaviesj:operatorfix

Conversation

@daviesj
Copy link
Contributor

PR Summary

OK, so this far from ready, but I wanted to get it out there as a suggestion. It all started with trying to work on unary operator issues describe in#1239. But after discovering the problem in#1606, I was thinking maybe the best thing would be to re-implement the feature and an idea of how to do it came to me.

I started by writing a bunch more tests (3a47f4a) both as a way to establish a baseline for how the feature behaves now, and to hopefully be a tool to help with any fixes for the linked issues. In order to come up with this list of tests, I looked throughabout_Operators and related topics. I added a test for any type of operator that I felt was somehow different, but didn't already have a test and could possibly fall into the category of operators that one might possibly wantCheckOperator to enforce whitespace around (or to ignore).

Then, I wrote a new implementation (d3da1e4) which more-or-less corresponds with the current behavior, except (at least in my opinion) handles unary operators better and fixes the inconsistencies with bitwise operators between PS 5.1 and 7. Since it already passed the tests for most types of operators I decided to go ahead and write code that might handle the other types (3943377). I realize that that code may not be complete enough and maybe not all of those operators should be implemented.

Hopefully the code comments explain the strategy pretty well but I will add a couple things. The code for the visitor is the same as I used in PR#1566. Also, I chose to remove theIsOperator function because it wasn't used anywhere else, and the tests that would be used just to determine whether the token is an operator are so similar to the ones used to determine what sort of operator, I figured it would be simpler not to run through them twice.

With this implementation, it would also be reasonably easy to enforce no whitespace around operators like++,--,-,! as described in#1239 (which could also easily be made optional). Seepossible implementation.

PR Checklist

Copy link
Collaborator

@bergmeisterbergmeister left a comment
edited
Loading

Choose a reason for hiding this comment

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

Thanks for the detailed explanation. Happy to take that and looks ok to me. I see it's largely based on#1566, therefore we should aim to get that PR merged soon.@rjmholt Can you please give your final yes/no on that other PR as you've already reviewed it before? I myself am happy with the other PR already.
After that the diff in this PR will be much smaller but as you said I can already see that the main diff will be just the change of using your Ast visitor instead ofTokenTraits.HasTrait.
This PR will likely cause a merge conflict for my PR#1602 but I am happy to accept that.

privateIEnumerable<DiagnosticRecord>FindOperatorViolations(TokenOperationstokenOperations)
{
foreach(vartokenNodeintokenOperations.GetTokenNodes(IsOperator))
foreach(LinkedListNode<Token>tokenNodeintokenOperations.GetTokenNodes((t)=>true))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
foreach(LinkedListNode<Token>tokenNodeintokenOperations.GetTokenNodes((t)=>true))
foreach(LinkedListNode<Token>tokenNodeintokenOperations.GetTokenNodes(()=>true))

@rjmholtrjmholt marked this pull request as draftApril 21, 2021 20:54
@rjmholt
Copy link
Contributor

Converting this to a draft while it remains a WIP

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@bergmeisterbergmeisterbergmeister left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@daviesj@rjmholt@bergmeister

[8]ページ先頭

©2009-2025 Movatter.jp