From 867d6537dfc80438c5e4d93a7ee65b4a1a83a80a Mon Sep 17 00:00:00 2001 From: pq Date: Thu, 13 Feb 2020 21:24:48 +0000 Subject: [PATCH] enum constant and named cons test cases Verifies that our client algorithm addresses issues seen in IntelliJ (https://github.com/dart-lang/sdk/issues/40620) and worked around in VSCode (https://github.com/Dart-Code/Dart-Code/commit/ea7443dab3378a7a86b3bbe40db6843ab1d05ffd) Change-Id: I2029d89559625ff666c947186d90484794f6b38b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135721 Reviewed-by: Brian Wilkerson Commit-Queue: Phil Quitslund --- .../test/client/completion_driver_test.dart | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/pkg/analysis_server/test/client/completion_driver_test.dart b/pkg/analysis_server/test/client/completion_driver_test.dart index 12f1df98ba7..6df33d6d4d6 100644 --- a/pkg/analysis_server/test/client/completion_driver_test.dart +++ b/pkg/analysis_server/test/client/completion_driver_test.dart @@ -227,7 +227,7 @@ class CompletionWithSuggestionsTest extends AbstractCompletionDriverTest { @override String get testFilePath => '$projectPath/lib/test.dart'; - Future test_project_filterImports() async { + Future test_project_filterImports_defaultConstructor() async { await addProjectFile('lib/a.dart', r''' class A {} '''); @@ -249,6 +249,55 @@ void main() { kind: CompletionSuggestionKind.INVOCATION); } + /// see: https://github.com/dart-lang/sdk/issues/40620 + Future test_project_filterImports_enumValues() async { + await addProjectFile('lib/a.dart', r''' +enum E { + e, +} +'''); + + await addProjectFile('lib/b.dart', r''' +export 'a.dart'; +'''); + + await addTestFile(''' +import 'a.dart'; +void main() { + ^ +} +'''); + expectSuggestion( + completion: 'E.e', + element: ElementKind.ENUM_CONSTANT, + kind: CompletionSuggestionKind.INVOCATION); + } + + /// see: https://github.com/dart-lang/sdk/issues/40620 + Future test_project_filterImports_namedConstructors() async { + await addProjectFile('lib/a.dart', r''' +class A { + A.a(); +} +'''); + + await addProjectFile('lib/b.dart', r''' +export 'a.dart'; +'''); + + await addTestFile(''' +import 'a.dart'; +void main() { + ^ +} +'''); + + expectSuggestion( + completion: 'A.a', + element: ElementKind.CONSTRUCTOR, + kind: CompletionSuggestionKind.INVOCATION); + } + Future test_project_filterMultipleImports() async { await addProjectFile('lib/a.dart', r''' class A {}