| 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.util; | 5 library test.services.completion.util; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol | 9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol |
| 10 show Element, ElementKind; | 10 show Element, ElementKind; |
| 11 import 'package:analysis_server/plugin/protocol/protocol.dart' | 11 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| 12 hide Element, ElementKind; | 12 hide Element, ElementKind; |
| 13 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; | 13 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; |
| 14 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; | 14 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; |
| 15 import 'package:analysis_server/src/services/completion/dart/common_usage_sorter
.dart'; | 15 import 'package:analysis_server/src/services/completion/dart/common_usage_sorter
.dart'; |
| 16 import 'package:analysis_server/src/services/completion/dart_completion_cache.da
rt'; | 16 import 'package:analysis_server/src/services/completion/dart_completion_cache.da
rt'; |
| 17 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 17 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 18 import 'package:analysis_server/src/services/completion/imported_reference_contr
ibutor.dart'; | 18 import 'package:analysis_server/src/services/completion/imported_reference_contr
ibutor.dart'; |
| 19 import 'package:analysis_server/src/services/index/index.dart'; | 19 import 'package:analysis_server/src/services/index/index.dart'; |
| 20 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 20 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| 21 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | 21 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; |
| 22 import 'package:analyzer/dart/element/element.dart'; |
| 22 import 'package:analyzer/src/generated/ast.dart'; | 23 import 'package:analyzer/src/generated/ast.dart'; |
| 23 import 'package:analyzer/src/generated/element.dart'; | |
| 24 import 'package:analyzer/src/generated/engine.dart'; | 24 import 'package:analyzer/src/generated/engine.dart'; |
| 25 import 'package:analyzer/src/generated/source.dart'; | 25 import 'package:analyzer/src/generated/source.dart'; |
| 26 import 'package:unittest/unittest.dart'; | 26 import 'package:unittest/unittest.dart'; |
| 27 | 27 |
| 28 import '../../abstract_context.dart'; | 28 import '../../abstract_context.dart'; |
| 29 | 29 |
| 30 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { | 30 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { |
| 31 String c1 = s1.completion.toLowerCase(); | 31 String c1 = s1.completion.toLowerCase(); |
| 32 String c2 = s2.completion.toLowerCase(); | 32 String c2 = s2.completion.toLowerCase(); |
| 33 return c1.compareTo(c2); | 33 return c1.compareTo(c2); |
| (...skipping 3266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3300 | 3300 |
| 3301 test_Literal_string() { | 3301 test_Literal_string() { |
| 3302 // SimpleStringLiteral ExpressionStatement Block | 3302 // SimpleStringLiteral ExpressionStatement Block |
| 3303 addTestSource('class A {a() {"hel^lo"}}'); | 3303 addTestSource('class A {a() {"hel^lo"}}'); |
| 3304 computeFast(); | 3304 computeFast(); |
| 3305 return computeFull((bool result) { | 3305 return computeFull((bool result) { |
| 3306 assertNoSuggestions(); | 3306 assertNoSuggestions(); |
| 3307 }); | 3307 }); |
| 3308 } | 3308 } |
| 3309 | 3309 |
| 3310 test_localVariableDeclarationName() { |
| 3311 addTestSource('main() {String m^}'); |
| 3312 return computeFull((bool result) { |
| 3313 assertNotSuggested('main'); |
| 3314 assertNotSuggested('min'); |
| 3315 }); |
| 3316 } |
| 3317 |
| 3310 test_MapLiteralEntry() { | 3318 test_MapLiteralEntry() { |
| 3311 // MapLiteralEntry MapLiteral VariableDeclaration | 3319 // MapLiteralEntry MapLiteral VariableDeclaration |
| 3312 addSource( | 3320 addSource( |
| 3313 '/testA.dart', | 3321 '/testA.dart', |
| 3314 ''' | 3322 ''' |
| 3315 int T1; | 3323 int T1; |
| 3316 F1() { } | 3324 F1() { } |
| 3317 typedef D1(); | 3325 typedef D1(); |
| 3318 class C1 {C1(this.x) { } int x;}'''); | 3326 class C1 {C1(this.x) { } int x;}'''); |
| 3319 addTestSource(''' | 3327 addTestSource(''' |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4167 | 4175 |
| 4168 test_PrefixedIdentifier_trailingStmt_param() { | 4176 test_PrefixedIdentifier_trailingStmt_param() { |
| 4169 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | 4177 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 4170 addTestSource('class A {f(String g) {g.^ int y = 0;}}'); | 4178 addTestSource('class A {f(String g) {g.^ int y = 0;}}'); |
| 4171 computeFast(); | 4179 computeFast(); |
| 4172 return computeFull((bool result) { | 4180 return computeFull((bool result) { |
| 4173 assertSuggestInvocationGetter('length', 'int'); | 4181 assertSuggestInvocationGetter('length', 'int'); |
| 4174 }); | 4182 }); |
| 4175 } | 4183 } |
| 4176 | 4184 |
| 4177 test_localVariableDeclarationName() { | |
| 4178 addTestSource('main() {String m^}'); | |
| 4179 return computeFull((bool result) { | |
| 4180 assertNotSuggested('main'); | |
| 4181 assertNotSuggested('min'); | |
| 4182 }); | |
| 4183 } | |
| 4184 | |
| 4185 test_PrefixedIdentifier_trailingStmt_param2() { | 4185 test_PrefixedIdentifier_trailingStmt_param2() { |
| 4186 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | 4186 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 4187 addTestSource('f(String g) {g.^ int y = 0;}'); | 4187 addTestSource('f(String g) {g.^ int y = 0;}'); |
| 4188 computeFast(); | 4188 computeFast(); |
| 4189 return computeFull((bool result) { | 4189 return computeFull((bool result) { |
| 4190 assertSuggestInvocationGetter('length', 'int'); | 4190 assertSuggestInvocationGetter('length', 'int'); |
| 4191 }); | 4191 }); |
| 4192 } | 4192 } |
| 4193 | 4193 |
| 4194 test_PrefixedIdentifier_trailingStmt_topLevelVar() { | 4194 test_PrefixedIdentifier_trailingStmt_topLevelVar() { |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4667 assertNotSuggested('bar2'); | 4667 assertNotSuggested('bar2'); |
| 4668 assertNotSuggested('_B'); | 4668 assertNotSuggested('_B'); |
| 4669 assertSuggestLocalClass('Y'); | 4669 assertSuggestLocalClass('Y'); |
| 4670 assertSuggestLocalClass('C'); | 4670 assertSuggestLocalClass('C'); |
| 4671 assertSuggestLocalVariable('f', null); | 4671 assertSuggestLocalVariable('f', null); |
| 4672 assertNotSuggested('x'); | 4672 assertNotSuggested('x'); |
| 4673 assertNotSuggested('e'); | 4673 assertNotSuggested('e'); |
| 4674 }); | 4674 }); |
| 4675 } | 4675 } |
| 4676 } | 4676 } |
| OLD | NEW |