| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.services.completion.target; | 5 library test.services.completion.target; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; | 7 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 8 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/src/generated/source.dart'; | 9 import 'package:analyzer/src/generated/source.dart'; |
| 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 assertCommon(); | 54 assertCommon(); |
| 55 expect(target.isFunctionalArgument(), isFunctionalArgument); | 55 expect(target.isFunctionalArgument(), isFunctionalArgument); |
| 56 } | 56 } |
| 57 | 57 |
| 58 test_ArgumentList_InstanceCreationExpression() { | 58 test_ArgumentList_InstanceCreationExpression() { |
| 59 // ArgumentList InstanceCreationExpression Block | 59 // ArgumentList InstanceCreationExpression Block |
| 60 addTestSource('main() {new Foo(^)}'); | 60 addTestSource('main() {new Foo(^)}'); |
| 61 assertTarget(')', '()', argIndex: 0); | 61 assertTarget(')', '()', argIndex: 0); |
| 62 } | 62 } |
| 63 | 63 |
| 64 test_ArgumentList_InstanceCreationExpression2() { |
| 65 // ArgumentList InstanceCreationExpression Block |
| 66 addTestSource('main() {new Foo(a,^)}'); |
| 67 if (context.analysisOptions.enableTrailingCommas) { |
| 68 assertTarget(')', '(a)', argIndex: 1); |
| 69 } else { |
| 70 assertTarget('', '(a, )', argIndex: 1); |
| 71 } |
| 72 } |
| 73 |
| 64 test_ArgumentList_InstanceCreationExpression_functionArg2() { | 74 test_ArgumentList_InstanceCreationExpression_functionArg2() { |
| 65 // ArgumentList InstanceCreationExpression Block | 75 // ArgumentList InstanceCreationExpression Block |
| 66 addTestSource('main() {new B(^)} class B{B(f()){}}'); | 76 addTestSource('main() {new B(^)} class B{B(f()){}}'); |
| 67 assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true); | 77 assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true); |
| 68 } | 78 } |
| 69 | 79 |
| 70 test_ArgumentList_MethodInvocation() { | 80 test_ArgumentList_MethodInvocation() { |
| 71 // ArgumentList MethodInvocation Block | 81 // ArgumentList MethodInvocation Block |
| 72 addTestSource('main() {foo(^)}'); | 82 addTestSource('main() {foo(^)}'); |
| 73 assertTarget(')', '()', argIndex: 0); | 83 assertTarget(')', '()', argIndex: 0); |
| 74 } | 84 } |
| 75 | 85 |
| 76 test_ArgumentList_MethodInvocation2() { | 86 test_ArgumentList_MethodInvocation2() { |
| 77 // ArgumentList MethodInvocation Block | 87 // ArgumentList MethodInvocation Block |
| 78 addTestSource('main() {foo(^n)}'); | 88 addTestSource('main() {foo(^n)}'); |
| 79 assertTarget('n', '(n)', argIndex: 0); | 89 assertTarget('n', '(n)', argIndex: 0); |
| 80 } | 90 } |
| 81 | 91 |
| 82 test_ArgumentList_MethodInvocation3() { | 92 test_ArgumentList_MethodInvocation3() { |
| 83 // ArgumentList MethodInvocation Block | 93 // ArgumentList MethodInvocation Block |
| 84 addTestSource('main() {foo(n^)}'); | 94 addTestSource('main() {foo(n^)}'); |
| 85 assertTarget('n', '(n)', argIndex: 0); | 95 assertTarget('n', '(n)', argIndex: 0); |
| 86 } | 96 } |
| 87 | 97 |
| 98 test_ArgumentList_MethodInvocation3a() { |
| 99 // ArgumentList MethodInvocation Block |
| 100 addTestSource('main() {foo((n)^)}'); |
| 101 assertTarget(')', '((n))', argIndex: 0); |
| 102 } |
| 103 |
| 88 test_ArgumentList_MethodInvocation4() { | 104 test_ArgumentList_MethodInvocation4() { |
| 89 // ArgumentList MethodInvocation Block | 105 // ArgumentList MethodInvocation Block |
| 90 addTestSource('main() {foo(n,^)}'); | 106 addTestSource('main() {foo(n,^)}'); |
| 91 assertTarget('', '(n, )', argIndex: 1); | 107 if (context.analysisOptions.enableTrailingCommas) { |
| 108 assertTarget(')', '(n)', argIndex: 1); |
| 109 } else { |
| 110 assertTarget('', '(n, )', argIndex: 1); |
| 111 } |
| 92 } | 112 } |
| 93 | 113 |
| 94 test_ArgumentList_MethodInvocation_functionArg() { | 114 test_ArgumentList_MethodInvocation_functionArg() { |
| 95 // ArgumentList MethodInvocation Block | 115 // ArgumentList MethodInvocation Block |
| 96 addTestSource('main() {foo(^)} foo(f()) {}'); | 116 addTestSource('main() {foo(^)} foo(f()) {}'); |
| 97 assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true); | 117 assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true); |
| 98 } | 118 } |
| 99 | 119 |
| 100 test_ArgumentList_MethodInvocation_functionArg2() { | 120 test_ArgumentList_MethodInvocation_functionArg2() { |
| 101 // ArgumentList MethodInvocation Block | 121 // ArgumentList MethodInvocation Block |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 addTestSource('main() {int b^ = 1;}'); | 570 addTestSource('main() {int b^ = 1;}'); |
| 551 assertTarget('b = 1', 'int b = 1'); | 571 assertTarget('b = 1', 'int b = 1'); |
| 552 } | 572 } |
| 553 | 573 |
| 554 test_VariableDeclaration_lhs_identifier_before() { | 574 test_VariableDeclaration_lhs_identifier_before() { |
| 555 // VariableDeclaration VariableDeclarationList | 575 // VariableDeclaration VariableDeclarationList |
| 556 addTestSource('main() {int ^b = 1;}'); | 576 addTestSource('main() {int ^b = 1;}'); |
| 557 assertTarget('b = 1', 'int b = 1'); | 577 assertTarget('b = 1', 'int b = 1'); |
| 558 } | 578 } |
| 559 } | 579 } |
| OLD | NEW |