[DAS] Fixes import and library doc comments. Adds missing enum test
R=srawlins@google.com
Bug: https://github.com/dart-lang/sdk/issues/59724
Change-Id: I580b39acc96697990b12527aea699cdf09d788e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411360
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart b/pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart
index 2793ca4..c4203f3 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart
@@ -403,6 +403,8 @@
if (parent is ClassMember) {
assert(node is CommentReference);
parent = parent.parent;
+ } else if (parent is Directive) {
+ parent = parent.parent;
} else if (parent is CompilationUnit) {
parent = containingMember;
}
diff --git a/pkg/analysis_server/test/services/completion/dart/location/dart_doc_test.dart b/pkg/analysis_server/test/services/completion/dart/location/dart_doc_test.dart
index da0200b..34cf97c 100644
--- a/pkg/analysis_server/test/services/completion/dart/location/dart_doc_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/location/dart_doc_test.dart
@@ -61,6 +61,21 @@
''');
}
+ Future<void> test_enum() async {
+ allowedIdentifiers = const {'MyEnum'};
+ await computeSuggestions('''
+/// This doc should suggest the commented enum name [MyE^].
+enum MyEnum { value1 }
+''');
+ assertResponse(r'''
+replacement
+ left: 3
+suggestions
+ MyEnum
+ kind: enum
+''');
+ }
+
Future<void> test_extension() async {
allowedIdentifiers = const {'MyExt'};
await computeSuggestions('''
@@ -160,23 +175,21 @@
''');
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/59724')
Future<void> test_importPrefix() async {
- allowedIdentifiers = const {'myPrefix'};
+ allowedIdentifiers = const {'async'};
await computeSuggestions('''
-/// This doc should suggest the commented import prefix name [myP^].
-import 'dart:async' as myPrefix;
+/// This doc should suggest the commented import prefix name [asy^].
+import 'dart:async' as async;
''');
assertResponse(r'''
replacement
left: 3
suggestions
- myPrefix
- kind: importPrefix
+ async
+ kind: library
''');
}
- @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/59724')
Future<void> test_library() async {
allowedIdentifiers = const {'MyClass1'};
await computeSuggestions('''
diff --git a/pkg/analysis_server/test/services/completion/dart/location/test_all.dart b/pkg/analysis_server/test/services/completion/dart/location/test_all.dart
index 4c6299e..d1859c6 100644
--- a/pkg/analysis_server/test/services/completion/dart/location/test_all.dart
+++ b/pkg/analysis_server/test/services/completion/dart/location/test_all.dart
@@ -20,7 +20,7 @@
import 'conditional_expression_test.dart' as conditional_expression;
import 'constructor_declaration_test.dart' as constructor_declaration;
import 'constructor_invocation_test.dart' as constructor_invocation;
-import 'dart_doc_test.dart' as dart_doc_test;
+import 'dart_doc_test.dart' as dart_doc;
import 'directive_uri_test.dart' as directive_uri;
import 'enum_constant_test.dart' as enum_constant;
import 'enum_declaration_test.dart' as enum_declaration;
@@ -102,7 +102,7 @@
conditional_expression.main();
constructor_declaration.main();
constructor_invocation.main();
- dart_doc_test.main();
+ dart_doc.main();
directive_uri.main();
enum_constant.main();
enum_declaration.main();