Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart

Issue 2883363002: Support tear-off completions for named params (in constructors) (flutter-intellij#836) (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/optype.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
index d2255d3cedd634cd1318036817d676a853037d2d..ba07b89ac799b4987c07e6de9021cfe755e858c9 100644
--- a/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart
@@ -415,6 +415,37 @@ void main() {new B().bar(^);}''');
assertNotSuggested('print');
}
+ test_ArgumentList_namedFieldParam_tear_off() async {
+ addSource(
+ '/libA.dart',
+ '''
+typedef void VoidCallback();
+
+class Button {
+ final VoidCallback onPressed;
+ Button({this.onPressed});
+}
+''');
+ addTestSource('''
+import '/libA.dart';
+
+class PageState {
+ void _incrementCounter() { }
+ build() =>
+ new Button(
+ onPressed: ^
+ );
+}
+''');
+ await computeSuggestions();
+
+ expect(replacementOffset, completionOffset);
+ expect(replacementLength, 0);
+
+ assertSuggest('_incrementCounter',
+ csKind: CompletionSuggestionKind.IDENTIFIER);
+ }
+
test_ArgumentList_namedParam() async {
// SimpleIdentifier NamedExpression ArgumentList MethodInvocation
// ExpressionStatement
@@ -474,6 +505,96 @@ void main() {expect(foo: ^)}''');
relevance: DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE);
}
+ test_ArgumentList_namedParam_tear_off() async {
+ addSource(
+ '/libA.dart',
+ '''
+typedef void VoidCallback();
+
+class Button {
+ Button({VoidCallback onPressed});
+}
+''');
+ addTestSource('''
+import '/libA.dart';
+
+class PageState {
+ void _incrementCounter() { }
+ build() =>
+ new Button(
+ onPressed: ^
+ );
+}
+''');
+ await computeSuggestions();
+
+ expect(replacementOffset, completionOffset);
+ expect(replacementLength, 0);
+
+ assertSuggest('_incrementCounter',
+ csKind: CompletionSuggestionKind.IDENTIFIER);
+ }
+
+ test_ArgumentList_namedParam_tear_off_1() async {
+ addSource(
+ '/libA.dart',
+ '''
+typedef void VoidCallback();
+
+class Button {
+ Button({VoidCallback onPressed, int x});
+}
+''');
+ addTestSource('''
+import '/libA.dart';
+
+class PageState {
+ void _incrementCounter() { }
+ build() =>
+ new Button(
+ onPressed: ^
+ );
+}
+''');
+ await computeSuggestions();
+
+ expect(replacementOffset, completionOffset);
+ expect(replacementLength, 0);
+
+ assertSuggest('_incrementCounter',
+ csKind: CompletionSuggestionKind.IDENTIFIER);
+ }
+
+ test_ArgumentList_namedParam_tear_off_2() async {
+ addSource(
+ '/libA.dart',
+ '''
+typedef void VoidCallback();
+
+class Button {
+ Button({ int x, VoidCallback onPressed);
+}
+''');
+ addTestSource('''
+import '/libA.dart';
+
+class PageState {
+ void _incrementCounter() { }
+ build() =>
+ new Button(
+ onPressed: ^
+ );
+}
+''');
+ await computeSuggestions();
+
+ expect(replacementOffset, completionOffset);
+ expect(replacementLength, 0);
+
+ assertSuggest('_incrementCounter',
+ csKind: CompletionSuggestionKind.IDENTIFIER);
+ }
+
test_AsExpression_type() async {
// SimpleIdentifier TypeName AsExpression
addTestSource('''
@@ -2026,7 +2147,6 @@ class A {a(blat: ^) { }}''');
assertSuggestClass('A');
assertNotSuggested('String');
assertNotSuggested('identical');
- assertNotSuggested('bar');
}
test_doc_classMember() async {
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart/optype.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698