| 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.toplevel; | 5 library test.services.completion.toplevel; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:analysis_server/src/services/completion/imported_computer.dart'; | 8 import 'package:analysis_server/src/services/completion/imported_computer.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 assertNotSuggested('_T4'); | 66 assertNotSuggested('_T4'); |
| 67 // LocalComputer provides local suggestions | 67 // LocalComputer provides local suggestions |
| 68 assertNotSuggested('C'); | 68 assertNotSuggested('C'); |
| 69 assertNotSuggested('foo'); | 69 assertNotSuggested('foo'); |
| 70 }); | 70 }); |
| 71 } | 71 } |
| 72 | 72 |
| 73 test_ExpressionStatement_class() { | 73 test_ExpressionStatement_class() { |
| 74 // SimpleIdentifier ExpressionStatement Block | 74 // SimpleIdentifier ExpressionStatement Block |
| 75 addSource('/testA.dart', ''' | 75 addSource('/testA.dart', ''' |
| 76 _B F1() { } |
| 76 class A {int x;} | 77 class A {int x;} |
| 77 class _B { }'''); | 78 class _B { }'''); |
| 78 addTestSource(''' | 79 addTestSource(''' |
| 79 import "/testA.dart"; | 80 import "/testA.dart"; |
| 80 class C {foo(){O^}}'''); | 81 class C {foo(){O^}}'''); |
| 81 return computeFull().then((_) { | 82 return computeFull().then((_) { |
| 82 assertSuggestClass('A'); | 83 assertSuggestClass('A'); |
| 84 assertSuggestFunction('F1', '_B', false); |
| 83 assertNotSuggested('x'); | 85 assertNotSuggested('x'); |
| 84 assertNotSuggested('_B'); | 86 assertNotSuggested('_B'); |
| 85 // Should not suggest compilation unit elements | 87 // Should not suggest compilation unit elements |
| 86 // which are returned by the LocalComputer | 88 // which are returned by the LocalComputer |
| 87 assertNotSuggested('C'); | 89 assertNotSuggested('C'); |
| 88 }); | 90 }); |
| 89 } | 91 } |
| 90 | 92 |
| 91 test_ExpressionStatement_name() { | 93 test_ExpressionStatement_name() { |
| 92 // ExpressionStatement Block BlockFunctionBody MethodDeclaration | 94 // ExpressionStatement Block BlockFunctionBody MethodDeclaration |
| (...skipping 25 matching lines...) Expand all Loading... |
| 118 // FieldDeclaration | 120 // FieldDeclaration |
| 119 addSource('/testA.dart', 'class A { }'); | 121 addSource('/testA.dart', 'class A { }'); |
| 120 addTestSource(''' | 122 addTestSource(''' |
| 121 import "/testA.dart"; | 123 import "/testA.dart"; |
| 122 class C {var ^}'''); | 124 class C {var ^}'''); |
| 123 return computeFull().then((_) { | 125 return computeFull().then((_) { |
| 124 assertNotSuggested('A'); | 126 assertNotSuggested('A'); |
| 125 }); | 127 }); |
| 126 } | 128 } |
| 127 | 129 |
| 128 test_HideCombinator_class() { | |
| 129 // SimpleIdentifier HideCombinator ImportDirective | |
| 130 addSource('/testAB.dart', ''' | |
| 131 library libAB; | |
| 132 part '/partAB.dart'; | |
| 133 class A { } | |
| 134 class B { }'''); | |
| 135 addSource('/partAB.dart', ''' | |
| 136 part of libAB; | |
| 137 class PB { }'''); | |
| 138 addSource('/testCD.dart', ''' | |
| 139 class C { } | |
| 140 class D { }'''); | |
| 141 addTestSource(''' | |
| 142 import "/testAB.dart" hide ^; | |
| 143 import "/testCD.dart"; | |
| 144 class X {}'''); | |
| 145 return computeFull().then((_) { | |
| 146 assertSuggestClass('A'); | |
| 147 assertSuggestClass('B'); | |
| 148 assertSuggestClass('PB'); | |
| 149 assertNotSuggested('C'); | |
| 150 assertNotSuggested('D'); | |
| 151 assertNotSuggested('Object'); | |
| 152 }); | |
| 153 } | |
| 154 | |
| 155 test_ImportDirective_dart() { | 130 test_ImportDirective_dart() { |
| 156 // SimpleStringLiteral ImportDirective | 131 // SimpleStringLiteral ImportDirective |
| 157 addTestSource(''' | 132 addTestSource(''' |
| 158 import "dart^"; | 133 import "dart^"; |
| 159 main() {}'''); | 134 main() {}'''); |
| 160 return computeFull().then((_) { | 135 return computeFull().then((_) { |
| 161 assertNotSuggested('Object'); | 136 assertNotSuggested('Object'); |
| 162 }); | 137 }); |
| 163 } | 138 } |
| 164 | |
| 165 test_ShowCombinator_class() { | |
| 166 // SimpleIdentifier ShowCombinator ImportDirective | |
| 167 addSource('/testAB.dart', ''' | |
| 168 class A { } | |
| 169 class B { }'''); | |
| 170 addSource('/testCD.dart', ''' | |
| 171 class C { } | |
| 172 class D { }'''); | |
| 173 addTestSource(''' | |
| 174 import "/testAB.dart" show ^; | |
| 175 import "/testCD.dart"; | |
| 176 class X {}'''); | |
| 177 return computeFull().then((_) { | |
| 178 assertSuggestClass('A'); | |
| 179 assertSuggestClass('B'); | |
| 180 assertNotSuggested('C'); | |
| 181 assertNotSuggested('D'); | |
| 182 assertNotSuggested('Object'); | |
| 183 }); | |
| 184 } | |
| 185 } | 139 } |
| OLD | NEW |