| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 _failedCompletion( | 60 _failedCompletion( |
| 61 'did not expect completion: $completion\n $suggestion'); | 61 'did not expect completion: $completion\n $suggestion'); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 CompletionSuggestion assertSuggest(CompletionSuggestionKind kind, | 65 CompletionSuggestion assertSuggest(CompletionSuggestionKind kind, |
| 66 String completion, [CompletionRelevance relevance = CompletionRelevance.DE
FAULT, | 66 String completion, [CompletionRelevance relevance = CompletionRelevance.DE
FAULT, |
| 67 bool isDeprecated = false, bool isPotential = false]) { | 67 bool isDeprecated = false, bool isPotential = false]) { |
| 68 CompletionSuggestion cs; | 68 CompletionSuggestion cs; |
| 69 request.suggestions.forEach((s) { | 69 request.suggestions.forEach((s) { |
| 70 if (s.completion == completion) { | 70 if (s.completion == completion && s.kind == kind) { |
| 71 if (cs == null) { | 71 if (cs == null) { |
| 72 cs = s; | 72 cs = s; |
| 73 } else { | 73 } else { |
| 74 _failedCompletion( | 74 _failedCompletion( |
| 75 'expected exactly one $completion', | 75 'expected exactly one $completion', |
| 76 request.suggestions.where((s) => s.completion == completion)); | 76 request.suggestions.where((s) => s.completion == completion)); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 }); | 79 }); |
| 80 if (cs == null) { | 80 if (cs == null) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 expect(element, isNotNull); | 216 expect(element, isNotNull); |
| 217 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE)); | 217 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE)); |
| 218 expect(element.name, equals(name)); | 218 expect(element.name, equals(name)); |
| 219 //TODO (danrubel) return type level variable 'type' but not as 'returnType' | 219 //TODO (danrubel) return type level variable 'type' but not as 'returnType' |
| 220 // expect( | 220 // expect( |
| 221 // element.returnType, | 221 // element.returnType, |
| 222 // equals(returnType != null ? returnType : 'dynamic')); | 222 // equals(returnType != null ? returnType : 'dynamic')); |
| 223 return cs; | 223 return cs; |
| 224 } | 224 } |
| 225 | 225 |
| 226 void assertSuggestTopLevelVarGetterSetter(String name, String returnType, |
| 227 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { |
| 228 assertSuggestGetter(name, returnType); |
| 229 assertSuggestSetter(name); |
| 230 } |
| 231 |
| 226 bool computeFast() { | 232 bool computeFast() { |
| 227 _computeFastCalled = true; | 233 _computeFastCalled = true; |
| 228 testUnit = context.parseCompilationUnit(testSource); | 234 testUnit = context.parseCompilationUnit(testSource); |
| 229 completionNode = | 235 completionNode = |
| 230 new NodeLocator.con1(completionOffset).searchWithin(testUnit); | 236 new NodeLocator.con1(completionOffset).searchWithin(testUnit); |
| 231 request.unit = testUnit; | 237 request.unit = testUnit; |
| 232 request.node = completionNode; | 238 request.node = completionNode; |
| 233 return computer.computeFast(request); | 239 return computer.computeFast(request); |
| 234 } | 240 } |
| 235 | 241 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 sb.write('\n in'); | 315 sb.write('\n in'); |
| 310 AstNode node = completionNode; | 316 AstNode node = completionNode; |
| 311 while (node != null) { | 317 while (node != null) { |
| 312 sb.write('\n ${node.runtimeType}'); | 318 sb.write('\n ${node.runtimeType}'); |
| 313 node = node.parent; | 319 node = node.parent; |
| 314 } | 320 } |
| 315 } | 321 } |
| 316 fail(sb.toString()); | 322 fail(sb.toString()); |
| 317 } | 323 } |
| 318 } | 324 } |
| OLD | NEW |