commit | 5f2d9cf41fd345f9c61c263c88d07a2ee5d3a449 | [log] [tgz] |
---|---|---|
author | Brian Wilkerson <brianwilkerson@google.com> | Fri Apr 14 19:04:48 2023 +0000 |
committer | Commit Queue <dart-scoped@luci-project-accounts.iam.gserviceaccount.com> | Fri Apr 14 19:04:48 2023 +0000 |
tree | 90c3308b3e8c1268f28f9bffa2386685448a075a | |
parent | c454945915d04aad7a4b8681449af668508b578d [diff] |
A cursor at the end of a file should be inside the compilation unit Change-Id: I68ff9337af9a416f18573e500a10eec1194adeaa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295400 Auto-Submit: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/utilities/extensions/ast.dart b/pkg/analyzer/lib/src/utilities/extensions/ast.dart index 581dd2a..6d13b54 100644 --- a/pkg/analyzer/lib/src/utilities/extensions/ast.dart +++ b/pkg/analyzer/lib/src/utilities/extensions/ast.dart
@@ -46,7 +46,7 @@ } if (this is CompilationUnit) { - if (offset < 0 || end >= this.end) { + if (offset < 0 || end > this.end) { return null; } } else if (!containsOffset(this)) {
diff --git a/pkg/analyzer/test/src/utilities/extensions/ast_test.dart b/pkg/analyzer/test/src/utilities/extensions/ast_test.dart index c4a8b39..7bf3504 100644 --- a/pkg/analyzer/test/src/utilities/extensions/ast_test.dart +++ b/pkg/analyzer/test/src/utilities/extensions/ast_test.dart
@@ -42,6 +42,14 @@ node as CompilationUnit; } + Future<void> test_atEOF() async { + var node = await coveringNode(''' +library myLib; + +^'''); + node as CompilationUnit; + } + Future<void> test_before_firstNonEOF() async { var node = await coveringNode(''' ^