| 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/src/protocol.dart' as protocol show Element, | 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, |
| 10 ElementKind; | 10 ElementKind; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 (CompletionSuggestion cs) => cs.completion == completion, | 91 (CompletionSuggestion cs) => cs.completion == completion, |
| 92 orElse: () => null); | 92 orElse: () => null); |
| 93 if (suggestion != null) { | 93 if (suggestion != null) { |
| 94 failedCompletion('did not expect completion: $completion\n $suggestion'); | 94 failedCompletion('did not expect completion: $completion\n $suggestion'); |
| 95 } | 95 } |
| 96 return null; | 96 return null; |
| 97 } | 97 } |
| 98 | 98 |
| 99 CompletionSuggestion assertSuggest(String completion, | 99 CompletionSuggestion assertSuggest(String completion, |
| 100 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION, | 100 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION, |
| 101 int relevance: COMPLETION_RELEVANCE_DEFAULT, | 101 int relevance: COMPLETION_RELEVANCE_DEFAULT, protocol.ElementKind elemKind
: |
| 102 protocol.ElementKind elemKind: null, bool isDeprecated: false, bool isPote
ntial: | 102 null, bool isDeprecated: false, bool isPotential: false}) { |
| 103 false}) { | |
| 104 CompletionSuggestion cs = | 103 CompletionSuggestion cs = |
| 105 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind); | 104 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind); |
| 106 if (cs == null) { | 105 if (cs == null) { |
| 107 failedCompletion('expected $completion $csKind', request.suggestions); | 106 failedCompletion('expected $completion $csKind', request.suggestions); |
| 108 } | 107 } |
| 109 expect(cs.kind, equals(csKind)); | 108 expect(cs.kind, equals(csKind)); |
| 110 if (isDeprecated) { | 109 if (isDeprecated) { |
| 111 expect(cs.relevance, equals(COMPLETION_RELEVANCE_LOW)); | 110 expect(cs.relevance, equals(COMPLETION_RELEVANCE_LOW)); |
| 112 } else { | 111 } else { |
| 113 expect(cs.relevance, equals(relevance)); | 112 expect(cs.relevance, equals(relevance)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 154 } |
| 156 StringBuffer msg = new StringBuffer(); | 155 StringBuffer msg = new StringBuffer(); |
| 157 msg.writeln('Argument list not the same'); | 156 msg.writeln('Argument list not the same'); |
| 158 msg.writeln(' Expected names: $expectedNames'); | 157 msg.writeln(' Expected names: $expectedNames'); |
| 159 msg.writeln(' found: $actualNames'); | 158 msg.writeln(' found: $actualNames'); |
| 160 msg.writeln(' Expected types: $expectedTypes'); | 159 msg.writeln(' Expected types: $expectedTypes'); |
| 161 msg.writeln(' found: $actualTypes'); | 160 msg.writeln(' found: $actualTypes'); |
| 162 fail(msg.toString()); | 161 fail(msg.toString()); |
| 163 } | 162 } |
| 164 | 163 |
| 165 CompletionSuggestion assertSuggestClass(String name, | 164 CompletionSuggestion assertSuggestClass(String name, [int relevance = |
| 166 [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 165 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 167 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 166 CompletionSuggestionKind.INVOCATION]) { |
| 168 CompletionSuggestion cs = | 167 CompletionSuggestion cs = |
| 169 assertSuggest(name, csKind: kind, relevance: relevance); | 168 assertSuggest(name, csKind: kind, relevance: relevance); |
| 170 protocol.Element element = cs.element; | 169 protocol.Element element = cs.element; |
| 171 expect(element, isNotNull); | 170 expect(element, isNotNull); |
| 172 expect(element.kind, equals(protocol.ElementKind.CLASS)); | 171 expect(element.kind, equals(protocol.ElementKind.CLASS)); |
| 173 expect(element.name, equals(name)); | 172 expect(element.name, equals(name)); |
| 174 expect(element.parameters, isNull); | 173 expect(element.parameters, isNull); |
| 175 expect(element.returnType, isNull); | 174 expect(element.returnType, isNull); |
| 176 return cs; | 175 return cs; |
| 177 } | 176 } |
| 178 | 177 |
| 179 CompletionSuggestion assertSuggestClassTypeAlias(String name, | 178 CompletionSuggestion assertSuggestClassTypeAlias(String name, [int relevance = |
| 180 [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 179 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 181 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 180 CompletionSuggestionKind.INVOCATION]) { |
| 182 CompletionSuggestion cs = | 181 CompletionSuggestion cs = |
| 183 assertSuggest(name, csKind: kind, relevance: relevance); | 182 assertSuggest(name, csKind: kind, relevance: relevance); |
| 184 protocol.Element element = cs.element; | 183 protocol.Element element = cs.element; |
| 185 expect(element, isNotNull); | 184 expect(element, isNotNull); |
| 186 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS)); | 185 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS)); |
| 187 expect(element.name, equals(name)); | 186 expect(element.name, equals(name)); |
| 188 expect(element.parameters, isNull); | 187 expect(element.parameters, isNull); |
| 189 expect(element.returnType, isNull); | 188 expect(element.returnType, isNull); |
| 190 return cs; | 189 return cs; |
| 191 } | 190 } |
| 192 | 191 |
| 193 CompletionSuggestion assertSuggestField(String name, | 192 CompletionSuggestion assertSuggestField(String name, {int relevance: |
| 194 {int relevance: COMPLETION_RELEVANCE_DEFAULT, | 193 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind: |
| 195 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | 194 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) { |
| 196 bool isDeprecated: false}) { | |
| 197 CompletionSuggestion cs = assertSuggest( | 195 CompletionSuggestion cs = assertSuggest( |
| 198 name, | 196 name, |
| 199 csKind: kind, | 197 csKind: kind, |
| 200 relevance: relevance, | 198 relevance: relevance, |
| 201 elemKind: protocol.ElementKind.FIELD, | 199 elemKind: protocol.ElementKind.FIELD, |
| 202 isDeprecated: isDeprecated); | 200 isDeprecated: isDeprecated); |
| 203 expect(cs.returnType, isNull); | 201 expect(cs.returnType, isNull); |
| 204 protocol.Element element = cs.element; | 202 protocol.Element element = cs.element; |
| 205 expect(element, isNotNull); | 203 expect(element, isNotNull); |
| 206 expect(element.kind, equals(protocol.ElementKind.FIELD)); | 204 expect(element.kind, equals(protocol.ElementKind.FIELD)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // expect(param[0], equals('(')); | 257 // expect(param[0], equals('(')); |
| 260 // expect(param[param.length - 1], equals(')')); | 258 // expect(param[param.length - 1], equals(')')); |
| 261 // TODO (danrubel) Determine why return type is null | 259 // TODO (danrubel) Determine why return type is null |
| 262 // expect( | 260 // expect( |
| 263 // element.returnType, | 261 // element.returnType, |
| 264 // equals(returnType != null ? returnType : 'dynamic')); | 262 // equals(returnType != null ? returnType : 'dynamic')); |
| 265 return cs; | 263 return cs; |
| 266 } | 264 } |
| 267 | 265 |
| 268 CompletionSuggestion assertSuggestGetter(String name, String returnType, | 266 CompletionSuggestion assertSuggestGetter(String name, String returnType, |
| 269 {int relevance: COMPLETION_RELEVANCE_DEFAULT, | 267 {int relevance: COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kin
d: |
| 270 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | 268 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) { |
| 271 bool isDeprecated: false}) { | |
| 272 CompletionSuggestion cs = assertSuggest( | 269 CompletionSuggestion cs = assertSuggest( |
| 273 name, | 270 name, |
| 274 csKind: kind, | 271 csKind: kind, |
| 275 relevance: relevance, | 272 relevance: relevance, |
| 276 elemKind: protocol.ElementKind.GETTER, | 273 elemKind: protocol.ElementKind.GETTER, |
| 277 isDeprecated: isDeprecated); | 274 isDeprecated: isDeprecated); |
| 278 expect(cs.returnType, equals(returnType)); | 275 expect(cs.returnType, equals(returnType)); |
| 279 protocol.Element element = cs.element; | 276 protocol.Element element = cs.element; |
| 280 expect(element, isNotNull); | 277 expect(element, isNotNull); |
| 281 expect(element.kind, equals(protocol.ElementKind.GETTER)); | 278 expect(element.kind, equals(protocol.ElementKind.GETTER)); |
| 282 expect(element.name, equals(name)); | 279 expect(element.name, equals(name)); |
| 283 //TODO (danrubel) getter should have parameters | 280 //TODO (danrubel) getter should have parameters |
| 284 // but not used in code completion | 281 // but not used in code completion |
| 285 //expect(element.parameters, '()'); | 282 //expect(element.parameters, '()'); |
| 286 expect( | 283 expect( |
| 287 element.returnType, | 284 element.returnType, |
| 288 equals(returnType != null ? returnType : 'dynamic')); | 285 equals(returnType != null ? returnType : 'dynamic')); |
| 289 return cs; | 286 return cs; |
| 290 } | 287 } |
| 291 | 288 |
| 292 CompletionSuggestion assertSuggestLibraryPrefix(String prefix, | 289 CompletionSuggestion assertSuggestLabel(String name, [int relevance = |
| 293 [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 290 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 294 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 291 CompletionSuggestionKind.IDENTIFIER]) { |
| 292 CompletionSuggestion cs = |
| 293 assertSuggest(name, csKind: kind, relevance: relevance); |
| 294 expect(cs.returnType, isNull); |
| 295 protocol.Element element = cs.element; |
| 296 expect(element, isNotNull); |
| 297 expect(element.flags, 0); |
| 298 expect(element.kind, equals(protocol.ElementKind.LABEL)); |
| 299 expect(element.name, equals(name)); |
| 300 expect(element.parameters, isNull); |
| 301 expect(element.returnType, isNull); |
| 302 return cs; |
| 303 } |
| 304 |
| 305 CompletionSuggestion assertSuggestLibraryPrefix(String prefix, [int relevance |
| 306 = COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 307 CompletionSuggestionKind.INVOCATION]) { |
| 295 // Library prefix should only be suggested by ImportedComputer | 308 // Library prefix should only be suggested by ImportedComputer |
| 296 if (computer is ImportedComputer) { | 309 if (computer is ImportedComputer) { |
| 297 CompletionSuggestion cs = | 310 CompletionSuggestion cs = |
| 298 assertSuggest(prefix, csKind: kind, relevance: relevance); | 311 assertSuggest(prefix, csKind: kind, relevance: relevance); |
| 299 protocol.Element element = cs.element; | 312 protocol.Element element = cs.element; |
| 300 expect(element, isNotNull); | 313 expect(element, isNotNull); |
| 301 expect(element.kind, equals(protocol.ElementKind.LIBRARY)); | 314 expect(element.kind, equals(protocol.ElementKind.LIBRARY)); |
| 302 expect(element.parameters, isNull); | 315 expect(element.parameters, isNull); |
| 303 expect(element.returnType, isNull); | 316 expect(element.returnType, isNull); |
| 304 return cs; | 317 return cs; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 expect(param[0], equals('(')); | 378 expect(param[0], equals('(')); |
| 366 expect(param[param.length - 1], equals(')')); | 379 expect(param[param.length - 1], equals(')')); |
| 367 expect(element.returnType, equals(returnType)); | 380 expect(element.returnType, equals(returnType)); |
| 368 return cs; | 381 return cs; |
| 369 } else { | 382 } else { |
| 370 return assertNotSuggested(name); | 383 return assertNotSuggested(name); |
| 371 } | 384 } |
| 372 } | 385 } |
| 373 | 386 |
| 374 CompletionSuggestion assertSuggestParameter(String name, String returnType, | 387 CompletionSuggestion assertSuggestParameter(String name, String returnType, |
| 375 [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 388 [int relevance = COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind ki
nd = |
| 376 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 389 CompletionSuggestionKind.INVOCATION]) { |
| 377 // Parameters should only be suggested by LocalComputer | 390 // Parameters should only be suggested by LocalComputer |
| 378 if (computer is LocalComputer) { | 391 if (computer is LocalComputer) { |
| 379 CompletionSuggestion cs = | 392 CompletionSuggestion cs = |
| 380 assertSuggest(name, csKind: kind, relevance: relevance); | 393 assertSuggest(name, csKind: kind, relevance: relevance); |
| 381 expect(cs.returnType, equals(returnType)); | 394 expect(cs.returnType, equals(returnType)); |
| 382 protocol.Element element = cs.element; | 395 protocol.Element element = cs.element; |
| 383 expect(element, isNotNull); | 396 expect(element, isNotNull); |
| 384 expect(element.kind, equals(protocol.ElementKind.PARAMETER)); | 397 expect(element.kind, equals(protocol.ElementKind.PARAMETER)); |
| 385 expect(element.name, equals(name)); | 398 expect(element.name, equals(name)); |
| 386 expect(element.parameters, isNull); | 399 expect(element.parameters, isNull); |
| 387 expect( | 400 expect( |
| 388 element.returnType, | 401 element.returnType, |
| 389 equals(returnType != null ? returnType : 'dynamic')); | 402 equals(returnType != null ? returnType : 'dynamic')); |
| 390 return cs; | 403 return cs; |
| 391 } else { | 404 } else { |
| 392 return assertNotSuggested(name); | 405 return assertNotSuggested(name); |
| 393 } | 406 } |
| 394 } | 407 } |
| 395 | 408 |
| 396 CompletionSuggestion assertSuggestSetter(String name, | 409 CompletionSuggestion assertSuggestSetter(String name, [int relevance = |
| 397 [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 410 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 398 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 411 CompletionSuggestionKind.INVOCATION]) { |
| 399 CompletionSuggestion cs = assertSuggest( | 412 CompletionSuggestion cs = assertSuggest( |
| 400 name, | 413 name, |
| 401 csKind: kind, | 414 csKind: kind, |
| 402 relevance: relevance, | 415 relevance: relevance, |
| 403 elemKind: protocol.ElementKind.SETTER); | 416 elemKind: protocol.ElementKind.SETTER); |
| 404 protocol.Element element = cs.element; | 417 protocol.Element element = cs.element; |
| 405 expect(element, isNotNull); | 418 expect(element, isNotNull); |
| 406 expect(element.kind, equals(protocol.ElementKind.SETTER)); | 419 expect(element.kind, equals(protocol.ElementKind.SETTER)); |
| 407 expect(element.name, equals(name)); | 420 expect(element.name, equals(name)); |
| 408 // TODO (danrubel) assert setter param | 421 // TODO (danrubel) assert setter param |
| 409 //expect(element.parameters, isNull); | 422 //expect(element.parameters, isNull); |
| 410 // TODO (danrubel) it would be better if this was always null | 423 // TODO (danrubel) it would be better if this was always null |
| 411 if (element.returnType != null) { | 424 if (element.returnType != null) { |
| 412 expect(element.returnType, 'dynamic'); | 425 expect(element.returnType, 'dynamic'); |
| 413 } | 426 } |
| 414 return cs; | 427 return cs; |
| 415 } | 428 } |
| 416 | 429 |
| 417 CompletionSuggestion assertSuggestTopLevelVar(String name, String returnType, | 430 CompletionSuggestion assertSuggestTopLevelVar(String name, String returnType, |
| 418 [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 431 [int relevance = COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind ki
nd = |
| 419 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 432 CompletionSuggestionKind.INVOCATION]) { |
| 420 CompletionSuggestion cs = | 433 CompletionSuggestion cs = |
| 421 assertSuggest(name, csKind: kind, relevance: relevance); | 434 assertSuggest(name, csKind: kind, relevance: relevance); |
| 422 expect(cs.returnType, equals(returnType)); | 435 expect(cs.returnType, equals(returnType)); |
| 423 protocol.Element element = cs.element; | 436 protocol.Element element = cs.element; |
| 424 expect(element, isNotNull); | 437 expect(element, isNotNull); |
| 425 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE)); | 438 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE)); |
| 426 expect(element.name, equals(name)); | 439 expect(element.name, equals(name)); |
| 427 expect(element.parameters, isNull); | 440 expect(element.parameters, isNull); |
| 428 //TODO (danrubel) return type level variable 'type' but not as 'returnType' | 441 //TODO (danrubel) return type level variable 'type' but not as 'returnType' |
| 429 // expect( | 442 // expect( |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 CompletionSuggestion assertLocalSuggestMethod(String name, | 606 CompletionSuggestion assertLocalSuggestMethod(String name, |
| 594 String declaringType, String returnType, [int relevance = | 607 String declaringType, String returnType, [int relevance = |
| 595 COMPLETION_RELEVANCE_DEFAULT]) { | 608 COMPLETION_RELEVANCE_DEFAULT]) { |
| 596 if (computer is LocalComputer) { | 609 if (computer is LocalComputer) { |
| 597 return assertSuggestMethod(name, declaringType, returnType, relevance); | 610 return assertSuggestMethod(name, declaringType, returnType, relevance); |
| 598 } else { | 611 } else { |
| 599 return assertNotSuggested(name); | 612 return assertNotSuggested(name); |
| 600 } | 613 } |
| 601 } | 614 } |
| 602 | 615 |
| 603 CompletionSuggestion assertSuggestImportedClass(String name, | 616 CompletionSuggestion assertSuggestImportedClass(String name, [int relevance = |
| 604 [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 617 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 605 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 618 CompletionSuggestionKind.INVOCATION]) { |
| 606 if (computer is ImportedComputer) { | 619 if (computer is ImportedComputer) { |
| 607 return assertSuggestClass(name, relevance, kind); | 620 return assertSuggestClass(name, relevance, kind); |
| 608 } else { | 621 } else { |
| 609 return assertNotSuggested(name); | 622 return assertNotSuggested(name); |
| 610 } | 623 } |
| 611 } | 624 } |
| 612 | 625 |
| 613 CompletionSuggestion assertSuggestImportedField(String name, | 626 CompletionSuggestion assertSuggestImportedField(String name, [int relevance = |
| 614 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 627 COMPLETION_RELEVANCE_DEFAULT]) { |
| 615 if (computer is ImportedComputer) { | 628 if (computer is ImportedComputer) { |
| 616 return assertSuggestField(name, relevance: relevance); | 629 return assertSuggestField(name, relevance: relevance); |
| 617 } else { | 630 } else { |
| 618 return assertNotSuggested(name); | 631 return assertNotSuggested(name); |
| 619 } | 632 } |
| 620 } | 633 } |
| 621 | 634 |
| 622 CompletionSuggestion assertSuggestImportedFunction(String name, | 635 CompletionSuggestion assertSuggestImportedFunction(String name, |
| 623 String returnType, [bool isDeprecated = false, int relevance = | 636 String returnType, [bool isDeprecated = false, int relevance = |
| 624 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = | 637 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 645 returnType, | 658 returnType, |
| 646 isDeprecated, | 659 isDeprecated, |
| 647 relevance, | 660 relevance, |
| 648 kind); | 661 kind); |
| 649 } else { | 662 } else { |
| 650 return assertNotSuggested(name); | 663 return assertNotSuggested(name); |
| 651 } | 664 } |
| 652 } | 665 } |
| 653 | 666 |
| 654 CompletionSuggestion assertSuggestImportedGetter(String name, | 667 CompletionSuggestion assertSuggestImportedGetter(String name, |
| 655 String returnType, [int relevance = | 668 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { |
| 656 COMPLETION_RELEVANCE_DEFAULT]) { | |
| 657 if (computer is ImportedComputer) { | 669 if (computer is ImportedComputer) { |
| 658 return assertSuggestGetter(name, returnType, relevance: relevance); | 670 return assertSuggestGetter(name, returnType, relevance: relevance); |
| 659 } else { | 671 } else { |
| 660 return assertNotSuggested(name); | 672 return assertNotSuggested(name); |
| 661 } | 673 } |
| 662 } | 674 } |
| 663 | 675 |
| 664 CompletionSuggestion assertSuggestImportedMethod(String name, | 676 CompletionSuggestion assertSuggestImportedMethod(String name, |
| 665 String declaringType, String returnType, [int relevance = | 677 String declaringType, String returnType, [int relevance = |
| 666 COMPLETION_RELEVANCE_DEFAULT]) { | 678 COMPLETION_RELEVANCE_DEFAULT]) { |
| 667 if (computer is ImportedComputer) { | 679 if (computer is ImportedComputer) { |
| 668 return assertSuggestMethod(name, declaringType, returnType, relevance); | 680 return assertSuggestMethod(name, declaringType, returnType, relevance); |
| 669 } else { | 681 } else { |
| 670 return assertNotSuggested(name); | 682 return assertNotSuggested(name); |
| 671 } | 683 } |
| 672 } | 684 } |
| 673 | 685 |
| 674 CompletionSuggestion assertSuggestImportedSetter(String name, | 686 CompletionSuggestion assertSuggestImportedSetter(String name, [int relevance = |
| 675 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 687 COMPLETION_RELEVANCE_DEFAULT]) { |
| 676 if (computer is ImportedComputer) { | 688 if (computer is ImportedComputer) { |
| 677 return assertSuggestSetter(name, relevance); | 689 return assertSuggestSetter(name, relevance); |
| 678 } else { | 690 } else { |
| 679 return assertNotSuggested(name); | 691 return assertNotSuggested(name); |
| 680 } | 692 } |
| 681 } | 693 } |
| 682 | 694 |
| 683 CompletionSuggestion assertSuggestImportedTopLevelVar(String name, | 695 CompletionSuggestion assertSuggestImportedTopLevelVar(String name, |
| 684 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 696 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, |
| 685 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 697 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { |
| 686 if (computer is ImportedComputer) { | 698 if (computer is ImportedComputer) { |
| 687 return assertSuggestTopLevelVar(name, returnType, relevance, kind); | 699 return assertSuggestTopLevelVar(name, returnType, relevance, kind); |
| 688 } else { | 700 } else { |
| 689 return assertNotSuggested(name); | 701 return assertNotSuggested(name); |
| 690 } | 702 } |
| 691 } | 703 } |
| 692 | 704 |
| 693 CompletionSuggestion assertSuggestInvocationClass(String name, | 705 CompletionSuggestion assertSuggestInvocationClass(String name, [int relevance |
| 694 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 706 = COMPLETION_RELEVANCE_DEFAULT]) { |
| 695 if (computer is InvocationComputer) { | 707 if (computer is InvocationComputer) { |
| 696 return assertSuggestClass(name, relevance); | 708 return assertSuggestClass(name, relevance); |
| 697 } else { | 709 } else { |
| 698 return assertNotSuggested(name); | 710 return assertNotSuggested(name); |
| 699 } | 711 } |
| 700 } | 712 } |
| 701 | 713 |
| 702 CompletionSuggestion assertSuggestInvocationGetter(String name, | 714 CompletionSuggestion assertSuggestInvocationGetter(String name, |
| 703 String returnType, {int relevance: COMPLETION_RELEVANCE_DEFAULT, | 715 String returnType, {int relevance: COMPLETION_RELEVANCE_DEFAULT, |
| 704 bool isDeprecated: false}) { | 716 bool isDeprecated: false}) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 716 CompletionSuggestion assertSuggestInvocationMethod(String name, | 728 CompletionSuggestion assertSuggestInvocationMethod(String name, |
| 717 String declaringType, String returnType, [int relevance = | 729 String declaringType, String returnType, [int relevance = |
| 718 COMPLETION_RELEVANCE_DEFAULT]) { | 730 COMPLETION_RELEVANCE_DEFAULT]) { |
| 719 if (computer is InvocationComputer) { | 731 if (computer is InvocationComputer) { |
| 720 return assertSuggestMethod(name, declaringType, returnType, relevance); | 732 return assertSuggestMethod(name, declaringType, returnType, relevance); |
| 721 } else { | 733 } else { |
| 722 return assertNotSuggested(name); | 734 return assertNotSuggested(name); |
| 723 } | 735 } |
| 724 } | 736 } |
| 725 | 737 |
| 726 CompletionSuggestion assertSuggestInvocationSetter(String name, | 738 CompletionSuggestion assertSuggestInvocationSetter(String name, [int relevance |
| 727 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 739 = COMPLETION_RELEVANCE_DEFAULT]) { |
| 728 if (computer is InvocationComputer) { | 740 if (computer is InvocationComputer) { |
| 729 return assertSuggestSetter(name); | 741 return assertSuggestSetter(name); |
| 730 } else { | 742 } else { |
| 731 return assertNotSuggested(name); | 743 return assertNotSuggested(name); |
| 732 } | 744 } |
| 733 } | 745 } |
| 734 | 746 |
| 735 CompletionSuggestion assertSuggestInvocationTopLevelVar(String name, | 747 CompletionSuggestion assertSuggestInvocationTopLevelVar(String name, |
| 736 String returnType, [int relevance = | 748 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { |
| 737 COMPLETION_RELEVANCE_DEFAULT]) { | |
| 738 if (computer is InvocationComputer) { | 749 if (computer is InvocationComputer) { |
| 739 return assertSuggestTopLevelVar(name, returnType, relevance); | 750 return assertSuggestTopLevelVar(name, returnType, relevance); |
| 740 } else { | 751 } else { |
| 741 return assertNotSuggested(name); | 752 return assertNotSuggested(name); |
| 742 } | 753 } |
| 743 } | 754 } |
| 744 | 755 |
| 745 CompletionSuggestion assertSuggestLocalClass(String name, | 756 CompletionSuggestion assertSuggestLocalClass(String name, [int relevance = |
| 746 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 757 COMPLETION_RELEVANCE_DEFAULT]) { |
| 747 if (computer is LocalComputer) { | 758 if (computer is LocalComputer) { |
| 748 return assertSuggestClass(name, relevance); | 759 return assertSuggestClass(name, relevance); |
| 749 } else { | 760 } else { |
| 750 return assertNotSuggested(name); | 761 return assertNotSuggested(name); |
| 751 } | 762 } |
| 752 } | 763 } |
| 753 | 764 |
| 754 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, | 765 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, |
| 755 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 766 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { |
| 756 if (computer is LocalComputer) { | 767 if (computer is LocalComputer) { |
| 757 return assertSuggestClassTypeAlias(name, relevance); | 768 return assertSuggestClassTypeAlias(name, relevance); |
| 758 } else { | 769 } else { |
| 759 return assertNotSuggested(name); | 770 return assertNotSuggested(name); |
| 760 } | 771 } |
| 761 } | 772 } |
| 762 | 773 |
| 763 CompletionSuggestion assertSuggestLocalField(String name, | 774 CompletionSuggestion assertSuggestLocalField(String name, [int relevance = |
| 764 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 775 COMPLETION_RELEVANCE_DEFAULT]) { |
| 765 if (computer is LocalComputer) { | 776 if (computer is LocalComputer) { |
| 766 return assertSuggestField(name, relevance: relevance); | 777 return assertSuggestField(name, relevance: relevance); |
| 767 } else { | 778 } else { |
| 768 return assertNotSuggested(name); | 779 return assertNotSuggested(name); |
| 769 } | 780 } |
| 770 } | 781 } |
| 771 | 782 |
| 772 CompletionSuggestion assertSuggestLocalFunction(String name, | 783 CompletionSuggestion assertSuggestLocalFunction(String name, |
| 773 String returnType, [bool isDeprecated = false, int relevance = | 784 String returnType, [bool isDeprecated = false, int relevance = |
| 774 COMPLETION_RELEVANCE_DEFAULT]) { | 785 COMPLETION_RELEVANCE_DEFAULT]) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 805 CompletionSuggestion assertSuggestLocalMethod(String name, | 816 CompletionSuggestion assertSuggestLocalMethod(String name, |
| 806 String declaringType, String returnType, [int relevance = | 817 String declaringType, String returnType, [int relevance = |
| 807 COMPLETION_RELEVANCE_DEFAULT]) { | 818 COMPLETION_RELEVANCE_DEFAULT]) { |
| 808 if (computer is LocalComputer) { | 819 if (computer is LocalComputer) { |
| 809 return assertSuggestMethod(name, declaringType, returnType, relevance); | 820 return assertSuggestMethod(name, declaringType, returnType, relevance); |
| 810 } else { | 821 } else { |
| 811 return assertNotSuggested(name); | 822 return assertNotSuggested(name); |
| 812 } | 823 } |
| 813 } | 824 } |
| 814 | 825 |
| 815 CompletionSuggestion assertSuggestLocalSetter(String name, | 826 CompletionSuggestion assertSuggestLocalSetter(String name, [int relevance = |
| 816 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 827 COMPLETION_RELEVANCE_DEFAULT]) { |
| 817 if (computer is LocalComputer) { | 828 if (computer is LocalComputer) { |
| 818 return assertSuggestSetter(name, relevance); | 829 return assertSuggestSetter(name, relevance); |
| 819 } else { | 830 } else { |
| 820 return assertNotSuggested(name); | 831 return assertNotSuggested(name); |
| 821 } | 832 } |
| 822 } | 833 } |
| 823 | 834 |
| 824 CompletionSuggestion assertSuggestLocalTopLevelVar(String name, | 835 CompletionSuggestion assertSuggestLocalTopLevelVar(String name, |
| 825 String returnType, [int relevance = | 836 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { |
| 826 COMPLETION_RELEVANCE_DEFAULT]) { | |
| 827 if (computer is LocalComputer) { | 837 if (computer is LocalComputer) { |
| 828 return assertSuggestTopLevelVar(name, returnType, relevance); | 838 return assertSuggestTopLevelVar(name, returnType, relevance); |
| 829 } else { | 839 } else { |
| 830 return assertNotSuggested(name); | 840 return assertNotSuggested(name); |
| 831 } | 841 } |
| 832 } | 842 } |
| 833 | 843 |
| 834 CompletionSuggestion assertSuggestNonLocalClass(String name, | 844 CompletionSuggestion assertSuggestNonLocalClass(String name, [int relevance = |
| 835 [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 845 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 836 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 846 CompletionSuggestionKind.INVOCATION]) { |
| 837 return assertSuggestImportedClass(name, relevance, kind); | 847 return assertSuggestImportedClass(name, relevance, kind); |
| 838 } | 848 } |
| 839 | 849 |
| 840 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { | 850 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { |
| 841 return super.computeFull( | 851 return super.computeFull( |
| 842 assertFunction, | 852 assertFunction, |
| 843 fullAnalysis: fullAnalysis).then(assertCachedCompute); | 853 fullAnalysis: fullAnalysis).then(assertCachedCompute); |
| 844 } | 854 } |
| 845 | 855 |
| 846 test_ArgumentList() { | 856 test_ArgumentList() { |
| (...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2571 assertNotSuggested('bar2'); | 2581 assertNotSuggested('bar2'); |
| 2572 assertNotSuggested('_B'); | 2582 assertNotSuggested('_B'); |
| 2573 assertSuggestLocalClass('Y'); | 2583 assertSuggestLocalClass('Y'); |
| 2574 assertSuggestLocalClass('C'); | 2584 assertSuggestLocalClass('C'); |
| 2575 assertSuggestLocalVariable('f', null); | 2585 assertSuggestLocalVariable('f', null); |
| 2576 assertNotSuggested('x'); | 2586 assertNotSuggested('x'); |
| 2577 assertNotSuggested('e'); | 2587 assertNotSuggested('e'); |
| 2578 }); | 2588 }); |
| 2579 } | 2589 } |
| 2580 } | 2590 } |
| OLD | NEW |