Chromium Code Reviews| Index: pkg/analysis_server/test/services/completion/completion_test_util.dart |
| diff --git a/pkg/analysis_server/test/services/completion/completion_test_util.dart b/pkg/analysis_server/test/services/completion/completion_test_util.dart |
| index 9ea63a8bb1ee5ff0c086b0df291c637e42542a9c..9515138d6193d51bdfa1764644964cf4188d9e7d 100644 |
| --- a/pkg/analysis_server/test/services/completion/completion_test_util.dart |
| +++ b/pkg/analysis_server/test/services/completion/completion_test_util.dart |
| @@ -6,7 +6,8 @@ library test.services.completion.util; |
| import 'dart:async'; |
| -import 'package:analysis_server/src/protocol.dart' as protocol show Element, ElementKind; |
| +import 'package:analysis_server/src/protocol.dart' as protocol show Element, |
| + ElementKind; |
| import 'package:analysis_server/src/protocol.dart' hide Element; |
| import 'package:analysis_server/src/services/completion/dart_completion_manager.dart'; |
| import 'package:analysis_server/src/services/index/index.dart'; |
| @@ -51,7 +52,7 @@ class AbstractCompletionTest extends AbstractContextTest { |
| void assertNotSuggested(String completion) { |
| if (request.suggestions.any((cs) => cs.completion == completion)) { |
| - fail('did not expect completion: $completion'); |
| + _failWithNodeInfo('did not expect completion: $completion'); |
| } |
| } |
| @@ -64,17 +65,17 @@ class AbstractCompletionTest extends AbstractContextTest { |
| if (cs == null) { |
| cs = s; |
| } else { |
| - List<CompletionSuggestion> matchSuggestions = |
| + List<CompletionSuggestion> completions = |
| request.suggestions.where((s) => s.completion == completion).toList(); |
| - fail( |
| - 'expected exactly one $completion but found > 1\n $matchSuggestions'); |
| + _failWithNodeInfo( |
| + 'expected exactly one $completion but found > 1\n$completions'); |
| } |
| } |
| }); |
| if (cs == null) { |
| List<CompletionSuggestion> completions = |
| request.suggestions.map((s) => s.completion).toList(); |
| - fail('expected "$completion" but found\n $completions'); |
| + _failWithNodeInfo('expected "$completion" but found\n $completions'); |
| } |
| expect(cs.kind, equals(kind)); |
| expect(cs.relevance, equals(relevance)); |
| @@ -284,4 +285,20 @@ class AbstractCompletionTest extends AbstractContextTest { |
| index = createLocalMemoryIndex(); |
| searchEngine = new SearchEngineImpl(index); |
| } |
| + |
| + void _failWithNodeInfo(String message) { |
| + StringBuffer sb = new StringBuffer(message); |
| + CompilationUnit unit = context.parseCompilationUnit(testSource); |
| + if (unit != null) { |
| + AstNode node = new NodeLocator.con1(completionOffset).searchWithin(unit); |
|
scheglov
2014/10/02 02:28:08
We could remember the node in "computeFull".
danrubel
2014/10/02 16:27:17
Good suggestion. Done.
|
| + if (node != null) { |
| + sb.write('\n in'); |
| + while (node != null) { |
| + sb.write('\n ${node.runtimeType}'); |
| + node = node.parent; |
| + } |
| + } |
| + } |
| + fail(sb.toString()); |
| + } |
| } |