| 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.domain.completion; | 5 library test.domain.completion; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 10 import 'package:analysis_server/src/domain_completion.dart'; | 10 import 'package:analysis_server/src/domain_completion.dart'; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 '''); | 132 '''); |
| 133 return getSuggestions().then((_) { | 133 return getSuggestions().then((_) { |
| 134 expect(replacementOffset, equals(completionOffset)); | 134 expect(replacementOffset, equals(completionOffset)); |
| 135 expect(replacementLength, equals(0)); | 135 expect(replacementLength, equals(0)); |
| 136 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); | 136 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); |
| 137 assertHasResult(CompletionSuggestionKind.CLASS, 'HtmlElement'); | 137 assertHasResult(CompletionSuggestionKind.CLASS, 'HtmlElement'); |
| 138 assertNoResult('test'); | 138 assertNoResult('test'); |
| 139 }); | 139 }); |
| 140 } | 140 } |
| 141 | 141 |
| 142 test_imports_prefixed() { |
| 143 addTestFile(''' |
| 144 import 'dart:html' as foo; |
| 145 main() {^} |
| 146 '''); |
| 147 return getSuggestions().then((_) { |
| 148 expect(replacementOffset, equals(completionOffset)); |
| 149 expect(replacementLength, equals(0)); |
| 150 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); |
| 151 assertHasResult(CompletionSuggestionKind.LIBRARY_PREFIX, 'foo'); |
| 152 assertNoResult('HtmlElement'); |
| 153 assertNoResult('test'); |
| 154 }); |
| 155 } |
| 156 |
| 142 test_locals() { | 157 test_locals() { |
| 143 addTestFile('class A {var a; x() {var b;^}}'); | 158 addTestFile('class A {var a; x() {var b;^}}'); |
| 144 return getSuggestions().then((_) { | 159 return getSuggestions().then((_) { |
| 145 expect(replacementOffset, equals(completionOffset)); | 160 expect(replacementOffset, equals(completionOffset)); |
| 146 expect(replacementLength, equals(0)); | 161 expect(replacementLength, equals(0)); |
| 147 assertHasResult(CompletionSuggestionKind.CLASS, 'A'); | 162 assertHasResult(CompletionSuggestionKind.CLASS, 'A'); |
| 148 assertHasResult(CompletionSuggestionKind.FIELD, 'a'); | 163 assertHasResult(CompletionSuggestionKind.FIELD, 'a'); |
| 149 assertHasResult(CompletionSuggestionKind.VARIABLE, 'b'); | 164 assertHasResult(CompletionSuggestionKind.VARIABLE, 'b'); |
| 150 assertHasResult(CompletionSuggestionKind.METHOD_NAME, 'x'); | 165 assertHasResult(CompletionSuggestionKind.METHOD_NAME, 'x'); |
| 151 }); | 166 }); |
| 152 } | 167 } |
| 153 | 168 |
| 154 test_topLevel() { | 169 test_topLevel() { |
| 155 addTestFile(''' | 170 addTestFile(''' |
| 156 typedef foo(); | 171 typedef foo(); |
| 157 var test = ''; | 172 var test = ''; |
| 158 main() {tes^t} | 173 main() {tes^t} |
| 159 '''); | 174 '''); |
| 160 return getSuggestions().then((_) { | 175 return getSuggestions().then((_) { |
| 161 // expect(replacementOffset, equals(completionOffset - 3)); | 176 // expect(replacementOffset, equals(completionOffset - 3)); |
| 162 // expect(replacementLength, equals(4)); | 177 // expect(replacementLength, equals(4)); |
| 163 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); | 178 assertHasResult(CompletionSuggestionKind.CLASS, 'Object'); |
| 164 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'test'); | 179 assertHasResult(CompletionSuggestionKind.TOP_LEVEL_VARIABLE, 'test'); |
| 165 assertNoResult('HtmlElement'); | 180 assertNoResult('HtmlElement'); |
| 166 }); | 181 }); |
| 167 } | 182 } |
| 168 } | 183 } |
| OLD | NEW |