| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for all the work and detail. Word of warning, getting edge cases in UseConsistent rule is hard, just expect some potential regressions but you've added plenty new test cases, which should overall make it better and be a change for the better. those regressions are often just found with a new release as so many people use PSSA in so many different ways
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks!
Sorry, something went wrong.
| node = rcurlyNode.Next; | ||
| } | ||
|
|
||
| return ranges; |
There was a problem hiding this comment.
Man this looked fun to implement, good job!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
UseConsistentWhitespace's CheckInnerBrace breaks braced member access ($a.{Prop}) by inserting whitespace after the opening and before the closing curly brace ($a.{ Prop }). The inner content of the braces must match the referenced property name exactly. No formatting of the inner content should occur.
Unlike the variable curly-brace format, ${a}, which is tokenised as a variable, no special tokenisation happens for this bracing.
PR introduces a new function, GetBracedMemberAccessRanges(), in TokenOperations.cs, which walks the token list looking for the shape of a braced member access:
The function returns a list of int pairs which represent a range from the startoffset of a LCurly to the endoffset of a RCurly. Formatting within these ranges could break braced member access.
In UseConsistentWhitespace when checking for inner brace violations in FindInnerBraceViolations(), call the function to get the ranges to exclude. Skip whitespace checking for braces within any range (inclusive).
Fixes #2066
When asking copilot to look this over, it told me I could instead have used the AST, looking for MemberExpressionAst who's Member started with a { and ended with a }. I could then infer the offsets of the braces. I could explore that if it's a more desirable/correct solution.
PR Checklist