| 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.dart.util; | 5 library test.services.completion.dart.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; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 CompletionSuggestion assertSuggest(String completion, | 107 CompletionSuggestion assertSuggest(String completion, |
| 108 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION, | 108 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION, |
| 109 int relevance: DART_RELEVANCE_DEFAULT, | 109 int relevance: DART_RELEVANCE_DEFAULT, |
| 110 String importUri, | 110 String importUri, |
| 111 protocol.ElementKind elemKind: null, | 111 protocol.ElementKind elemKind: null, |
| 112 bool isDeprecated: false, | 112 bool isDeprecated: false, |
| 113 bool isPotential: false, | 113 bool isPotential: false, |
| 114 String elemFile, | 114 String elemFile, |
| 115 int elemOffset, | 115 int elemOffset, |
| 116 String paramName, | 116 String paramName, |
| 117 String paramType}) { | 117 String paramType, |
| 118 String defaultArgListString}) { |
| 118 CompletionSuggestion cs = | 119 CompletionSuggestion cs = |
| 119 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind); | 120 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind); |
| 120 if (cs == null) { | 121 if (cs == null) { |
| 121 failedCompletion('expected $completion $csKind $elemKind', suggestions); | 122 failedCompletion('expected $completion $csKind $elemKind', suggestions); |
| 122 } | 123 } |
| 123 expect(cs.kind, equals(csKind)); | 124 expect(cs.kind, equals(csKind)); |
| 124 if (isDeprecated) { | 125 if (isDeprecated) { |
| 125 expect(cs.relevance, equals(DART_RELEVANCE_LOW)); | 126 expect(cs.relevance, equals(DART_RELEVANCE_LOW)); |
| 126 } else { | 127 } else { |
| 127 expect(cs.relevance, equals(relevance), reason: completion); | 128 expect(cs.relevance, equals(relevance), reason: completion); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 144 } | 145 } |
| 145 if (elemOffset != null) { | 146 if (elemOffset != null) { |
| 146 expect(cs.element.location.offset, elemOffset); | 147 expect(cs.element.location.offset, elemOffset); |
| 147 } | 148 } |
| 148 if (paramName != null) { | 149 if (paramName != null) { |
| 149 expect(cs.parameterName, paramName); | 150 expect(cs.parameterName, paramName); |
| 150 } | 151 } |
| 151 if (paramType != null) { | 152 if (paramType != null) { |
| 152 expect(cs.parameterType, paramType); | 153 expect(cs.parameterType, paramType); |
| 153 } | 154 } |
| 155 if (defaultArgListString != null) { |
| 156 expect(cs.defaultArgumentListString, defaultArgListString); |
| 157 } |
| 154 return cs; | 158 return cs; |
| 155 } | 159 } |
| 156 | 160 |
| 157 CompletionSuggestion assertSuggestClass(String name, | 161 CompletionSuggestion assertSuggestClass(String name, |
| 158 {int relevance: DART_RELEVANCE_DEFAULT, | 162 {int relevance: DART_RELEVANCE_DEFAULT, |
| 159 String importUri, | 163 String importUri, |
| 160 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | 164 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, |
| 161 bool isDeprecated: false, | 165 bool isDeprecated: false, |
| 162 String elemFile, | 166 String elemFile, |
| 163 String elemName, | 167 String elemName, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 // The returnType represents the type of a field | 252 // The returnType represents the type of a field |
| 249 expect(element.returnType, type != null ? type : 'dynamic'); | 253 expect(element.returnType, type != null ? type : 'dynamic'); |
| 250 assertHasNoParameterInfo(cs); | 254 assertHasNoParameterInfo(cs); |
| 251 return cs; | 255 return cs; |
| 252 } | 256 } |
| 253 | 257 |
| 254 CompletionSuggestion assertSuggestFunction(String name, String returnType, | 258 CompletionSuggestion assertSuggestFunction(String name, String returnType, |
| 255 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | 259 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, |
| 256 bool isDeprecated: false, | 260 bool isDeprecated: false, |
| 257 int relevance: DART_RELEVANCE_DEFAULT, | 261 int relevance: DART_RELEVANCE_DEFAULT, |
| 258 String importUri}) { | 262 String importUri, |
| 263 String defaultArgListString}) { |
| 259 CompletionSuggestion cs = assertSuggest(name, | 264 CompletionSuggestion cs = assertSuggest(name, |
| 260 csKind: kind, | 265 csKind: kind, |
| 261 relevance: relevance, | 266 relevance: relevance, |
| 262 importUri: importUri, | 267 importUri: importUri, |
| 263 isDeprecated: isDeprecated); | 268 isDeprecated: isDeprecated, |
| 269 defaultArgListString: defaultArgListString); |
| 264 if (returnType != null) { | 270 if (returnType != null) { |
| 265 expect(cs.returnType, returnType); | 271 expect(cs.returnType, returnType); |
| 266 } else if (isNullExpectedReturnTypeConsideredDynamic) { | 272 } else if (isNullExpectedReturnTypeConsideredDynamic) { |
| 267 expect(cs.returnType, 'dynamic'); | 273 expect(cs.returnType, 'dynamic'); |
| 268 } | 274 } |
| 269 protocol.Element element = cs.element; | 275 protocol.Element element = cs.element; |
| 270 expect(element, isNotNull); | 276 expect(element, isNotNull); |
| 271 expect(element.kind, equals(protocol.ElementKind.FUNCTION)); | 277 expect(element.kind, equals(protocol.ElementKind.FUNCTION)); |
| 272 expect(element.name, equals(name)); | 278 expect(element.name, equals(name)); |
| 273 expect(element.isDeprecated, equals(isDeprecated)); | 279 expect(element.isDeprecated, equals(isDeprecated)); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 equals(returnType != null ? returnType : 'dynamic')); | 346 equals(returnType != null ? returnType : 'dynamic')); |
| 341 assertHasNoParameterInfo(cs); | 347 assertHasNoParameterInfo(cs); |
| 342 return cs; | 348 return cs; |
| 343 } | 349 } |
| 344 | 350 |
| 345 CompletionSuggestion assertSuggestMethod( | 351 CompletionSuggestion assertSuggestMethod( |
| 346 String name, String declaringType, String returnType, | 352 String name, String declaringType, String returnType, |
| 347 {int relevance: DART_RELEVANCE_DEFAULT, | 353 {int relevance: DART_RELEVANCE_DEFAULT, |
| 348 String importUri, | 354 String importUri, |
| 349 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | 355 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, |
| 350 bool isDeprecated: false}) { | 356 bool isDeprecated: false, |
| 357 String defaultArgListString}) { |
| 351 CompletionSuggestion cs = assertSuggest(name, | 358 CompletionSuggestion cs = assertSuggest(name, |
| 352 csKind: kind, | 359 csKind: kind, |
| 353 relevance: relevance, | 360 relevance: relevance, |
| 354 importUri: importUri, | 361 importUri: importUri, |
| 355 isDeprecated: isDeprecated); | 362 isDeprecated: isDeprecated, |
| 363 defaultArgListString: defaultArgListString); |
| 356 expect(cs.declaringType, equals(declaringType)); | 364 expect(cs.declaringType, equals(declaringType)); |
| 357 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | 365 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); |
| 358 protocol.Element element = cs.element; | 366 protocol.Element element = cs.element; |
| 359 expect(element, isNotNull); | 367 expect(element, isNotNull); |
| 360 expect(element.kind, equals(protocol.ElementKind.METHOD)); | 368 expect(element.kind, equals(protocol.ElementKind.METHOD)); |
| 361 expect(element.name, equals(name)); | 369 expect(element.name, equals(name)); |
| 362 String param = element.parameters; | 370 String param = element.parameters; |
| 363 expect(param, isNotNull); | 371 expect(param, isNotNull); |
| 364 expect(param[0], equals('(')); | 372 expect(param[0], equals('(')); |
| 365 expect(param[param.length - 1], equals(')')); | 373 expect(param[param.length - 1], equals(')')); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 | 587 |
| 580 @override | 588 @override |
| 581 void setUp() { | 589 void setUp() { |
| 582 super.setUp(); | 590 super.setUp(); |
| 583 index = createMemoryIndex(); | 591 index = createMemoryIndex(); |
| 584 searchEngine = | 592 searchEngine = |
| 585 new SearchEngineImpl(index, (_) => new AstProviderForContext(context)); | 593 new SearchEngineImpl(index, (_) => new AstProviderForContext(context)); |
| 586 contributor = createContributor(); | 594 contributor = createContributor(); |
| 587 } | 595 } |
| 588 } | 596 } |
| OLD | NEW |