From 154b473cdb65c2686bb44fedec03ba2deddb80fd Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Wed, 22 Jan 2025 13:00:30 -0800 Subject: [PATCH] [analysis_server] Fix missing dartdoc references in Library comments Fixes https://github.com/dart-lang/sdk/issues/59946 Change-Id: I3b8558f72b6cc932f2c87ee4f2e993c5584907a7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405361 Reviewed-by: Brian Wilkerson Reviewed-by: Samuel Rawlins Commit-Queue: Brian Wilkerson --- .../test/analysis/get_navigation_test.dart | 34 +++++++++++++++++++ .../utilities/navigation/navigation_dart.dart | 1 + 2 files changed, 35 insertions(+) diff --git a/pkg/analysis_server/test/analysis/get_navigation_test.dart b/pkg/analysis_server/test/analysis/get_navigation_test.dart index 98853a60ec7..2a6928a35c3 100644 --- a/pkg/analysis_server/test/analysis/get_navigation_test.dart +++ b/pkg/analysis_server/test/analysis/get_navigation_test.dart @@ -211,6 +211,40 @@ final foo = {"key": ?Foo()}; expect(target.length, 3); } + Future test_documentation() async { + addTestFile(''' +/// [math] +import 'dart:math' as math; +'''); + await waitForTasksFinished(); + await _getNavigation(search: 'math]'); + expect(regions, hasLength(1)); + assertHasRegionString('math'); + expect(testTargets, hasLength(1)); + var target = targets[regions.first.targets.first]; + expect(target.kind, ElementKind.PREFIX); + expect(target.offset, findOffset('math;')); + expect(target.length, 4); + } + + Future test_documentation_library() async { + addTestFile(''' +/// [math] +library; + +import 'dart:math' as math; +'''); + await waitForTasksFinished(); + await _getNavigation(search: 'math]'); + expect(regions, hasLength(1)); + assertHasRegionString('math'); + expect(testTargets, hasLength(1)); + var target = targets[regions.first.targets.first]; + expect(target.kind, ElementKind.PREFIX); + expect(target.offset, findOffset('math;')); + expect(target.length, 4); + } + Future test_field_underscore() async { addTestFile(''' class C { diff --git a/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation_dart.dart b/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation_dart.dart index f484da6a376..dd94da5bc8c 100644 --- a/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation_dart.dart +++ b/pkg/analyzer_plugin/lib/src/utilities/navigation/navigation_dart.dart @@ -438,6 +438,7 @@ class _DartNavigationComputerVisitor extends RecursiveAstVisitor { @override void visitLibraryDirective(LibraryDirective node) { computer._addRegionForElement(node.name2, node.element2); + super.visitLibraryDirective(node); } @override