mirror of
https://github.com/dart-lang/sdk
synced 2024-07-19 20:17:27 +00:00
Make expression-detection in doc verifier more discriminating.
The existing behavior treated `var x = e; // comment` as an expression, and failed spectacularly to insert it after a `return`. The new behavior detects a `;` anywhere in the single line, not just at the end, as a sign that a single line is probably not an expression. Change-Id: Ice5abc8dc802db36511dc3cdcca162dc0e8a8f13 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229155 Auto-Submit: Lasse Nielsen <lrn@google.com> Reviewed-by: Devon Carew <devoncarew@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com>
This commit is contained in:
parent
5106605af6
commit
225b8d3f58
|
@ -270,8 +270,8 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor {
|
|||
template = 'none';
|
||||
} else if (hasTopDeclaration) {
|
||||
template = 'top';
|
||||
} else if (lines.length == 1 && !lines.first.trim().endsWith(';')) {
|
||||
// If single line with no trailing `;`, assume expression.
|
||||
} else if (lines.length == 1 && !lines.first.contains(';')) {
|
||||
// If single line with no `;`, assume expression.
|
||||
template = 'expression';
|
||||
} else {
|
||||
// Otherwise default to `main`.
|
||||
|
|
Loading…
Reference in a new issue