From 225b8d3f580f1be961385e4b902e6c2242e702e7 Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Mon, 24 Jan 2022 11:12:18 +0000 Subject: [PATCH] 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 Reviewed-by: Devon Carew Commit-Queue: Lasse Nielsen --- tools/verify_docs/bin/verify_docs.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/verify_docs/bin/verify_docs.dart b/tools/verify_docs/bin/verify_docs.dart index 8cba35fc403..ebe1ce78b67 100755 --- a/tools/verify_docs/bin/verify_docs.dart +++ b/tools/verify_docs/bin/verify_docs.dart @@ -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`.