| 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 | 9 import 'package:analysis_server/src/protocol.dart' as protocol |
| 10 show Element, ElementKind; | 10 show Element, ElementKind; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } else { | 124 } else { |
| 125 expect(cs.relevance, equals(relevance)); | 125 expect(cs.relevance, equals(relevance)); |
| 126 } | 126 } |
| 127 expect(cs.selectionOffset, equals(completion.length)); | 127 expect(cs.selectionOffset, equals(completion.length)); |
| 128 expect(cs.selectionLength, equals(0)); | 128 expect(cs.selectionLength, equals(0)); |
| 129 expect(cs.isDeprecated, equals(isDeprecated)); | 129 expect(cs.isDeprecated, equals(isDeprecated)); |
| 130 expect(cs.isPotential, equals(isPotential)); | 130 expect(cs.isPotential, equals(isPotential)); |
| 131 return cs; | 131 return cs; |
| 132 } | 132 } |
| 133 | 133 |
| 134 void assertSuggestArgumentList( | |
| 135 List<String> paramNames, List<String> paramTypes) { | |
| 136 CompletionSuggestionKind csKind = CompletionSuggestionKind.ARGUMENT_LIST; | |
| 137 CompletionSuggestion cs = getSuggest(csKind: csKind); | |
| 138 if (cs == null) { | |
| 139 failedCompletion('expected completion $csKind', request.suggestions); | |
| 140 } | |
| 141 assertSuggestArgumentList_params( | |
| 142 paramNames, paramTypes, cs.parameterNames, cs.parameterTypes); | |
| 143 expect(cs.relevance, DART_RELEVANCE_HIGH); | |
| 144 } | |
| 145 | |
| 146 void assertSuggestArgumentList_params(List<String> expectedNames, | |
| 147 List<String> expectedTypes, List<String> actualNames, | |
| 148 List<String> actualTypes) { | |
| 149 if (actualNames != null && | |
| 150 actualNames.length == expectedNames.length && | |
| 151 actualTypes != null && | |
| 152 actualTypes.length == expectedTypes.length) { | |
| 153 int index = 0; | |
| 154 while (index < expectedNames.length) { | |
| 155 if (actualNames[index] != expectedNames[index] || | |
| 156 actualTypes[index] != expectedTypes[index]) { | |
| 157 break; | |
| 158 } | |
| 159 ++index; | |
| 160 } | |
| 161 if (index == expectedNames.length) { | |
| 162 return; | |
| 163 } | |
| 164 } | |
| 165 StringBuffer msg = new StringBuffer(); | |
| 166 msg.writeln('Argument list not the same'); | |
| 167 msg.writeln(' Expected names: $expectedNames'); | |
| 168 msg.writeln(' found: $actualNames'); | |
| 169 msg.writeln(' Expected types: $expectedTypes'); | |
| 170 msg.writeln(' found: $actualTypes'); | |
| 171 fail(msg.toString()); | |
| 172 } | |
| 173 | |
| 174 CompletionSuggestion assertSuggestClass(String name, | 134 CompletionSuggestion assertSuggestClass(String name, |
| 175 {int relevance: DART_RELEVANCE_DEFAULT, | 135 {int relevance: DART_RELEVANCE_DEFAULT, |
| 176 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | 136 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, |
| 177 bool isDeprecated: false}) { | 137 bool isDeprecated: false}) { |
| 178 CompletionSuggestion cs = assertSuggest(name, | 138 CompletionSuggestion cs = assertSuggest(name, |
| 179 csKind: kind, relevance: relevance, isDeprecated: isDeprecated); | 139 csKind: kind, relevance: relevance, isDeprecated: isDeprecated); |
| 180 protocol.Element element = cs.element; | 140 protocol.Element element = cs.element; |
| 181 expect(element, isNotNull); | 141 expect(element, isNotNull); |
| 182 expect(element.kind, equals(protocol.ElementKind.CLASS)); | 142 expect(element.kind, equals(protocol.ElementKind.CLASS)); |
| 183 expect(element.name, equals(name)); | 143 expect(element.name, equals(name)); |
| (...skipping 3630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3814 assertNotSuggested('bar2'); | 3774 assertNotSuggested('bar2'); |
| 3815 assertNotSuggested('_B'); | 3775 assertNotSuggested('_B'); |
| 3816 assertSuggestLocalClass('Y'); | 3776 assertSuggestLocalClass('Y'); |
| 3817 assertSuggestLocalClass('C'); | 3777 assertSuggestLocalClass('C'); |
| 3818 assertSuggestLocalVariable('f', null); | 3778 assertSuggestLocalVariable('f', null); |
| 3819 assertNotSuggested('x'); | 3779 assertNotSuggested('x'); |
| 3820 assertNotSuggested('e'); | 3780 assertNotSuggested('e'); |
| 3821 }); | 3781 }); |
| 3822 } | 3782 } |
| 3823 } | 3783 } |
| OLD | NEW |