You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix firstNonCommentToken in anticipation of analyzer fix. (#1503)
This commit fixes a subtle bug in the formatter which is currently
covered up by an analyzer bug. The formatter bug is this:
`AstNodeExtensions.firstNonCommentToken` assumes that if an AST node
doesn't implement `AnnotatedNode`, then it can't possibly begin with a
documentation comment, so it is safe to simply defer to
`beginToken`. But that isn't true `DefaultFormalParameter` doesn't
implement `AnnotatedNode`, but its first child is a
`NormalFormalParameter`, which *can* begin with a documentation
comment.
Currently, analyzer bug dart-lang/sdk#56313
prevents `NormalFormalParameter.beginToken` from properly accounting
for the presence of the documentation comment, so as a result,
`AstNodeExtensions.firstNonCommentToken` works correctly on
`DefaultFormalParameter`. In order to avoid breaking the formatter
when I fix the analyzer bug, I need to first fix the formatter.
The formatter fix is for `AstNodeExtensions.firstNonCommentToken` to
recognize that `DefaultFormalParameter` is unusual, and to compute its
first non-comment token directly (by looking at the first non-cmoment
token of its first child, `parameter`). The formatter fix works
regardless of whether the analyzer bug is fixed, so it is safe to land
the formatter fix first.
0 commit comments