| 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.analysis.hover; | 5 library test.domain.analysis.hover; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 expect(hover.elementDescription, 'A.mmm(int a, String b) → List<String>'); | 131 expect(hover.elementDescription, 'A.mmm(int a, String b) → List<String>'); |
| 132 expect(hover.elementKind, 'method'); | 132 expect(hover.elementKind, 'method'); |
| 133 // types | 133 // types |
| 134 expect(hover.staticType, '(int, String) → List<String>'); | 134 expect(hover.staticType, '(int, String) → List<String>'); |
| 135 expect(hover.propagatedType, isNull); | 135 expect(hover.propagatedType, isNull); |
| 136 // no parameter | 136 // no parameter |
| 137 expect(hover.parameter, isNull); | 137 expect(hover.parameter, isNull); |
| 138 }); | 138 }); |
| 139 } | 139 } |
| 140 | 140 |
| 141 test_expression_method_nvocation() { | 141 test_expression_method_invocation() { |
| 142 addTestFile(''' | 142 addTestFile(''' |
| 143 library my.library; | 143 library my.library; |
| 144 class A { | 144 class A { |
| 145 List<String> mmm(int a, String b) { | 145 List<String> mmm(int a, String b) { |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 main(A a) { | 148 main(A a) { |
| 149 a.mmm(42, 'foo'); | 149 a.mmm(42, 'foo'); |
| 150 } | 150 } |
| 151 '''); | 151 '''); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 expect(hover.containingLibraryPath, testFile); | 205 expect(hover.containingLibraryPath, testFile); |
| 206 expect(hover.dartdoc, isNull); | 206 expect(hover.dartdoc, isNull); |
| 207 expect(hover.elementDescription, 'dynamic vvv'); | 207 expect(hover.elementDescription, 'dynamic vvv'); |
| 208 expect(hover.elementKind, 'local variable'); | 208 expect(hover.elementKind, 'local variable'); |
| 209 // types | 209 // types |
| 210 expect(hover.staticType, 'dynamic'); | 210 expect(hover.staticType, 'dynamic'); |
| 211 expect(hover.propagatedType, 'int'); | 211 expect(hover.propagatedType, 'int'); |
| 212 }); | 212 }); |
| 213 } | 213 } |
| 214 | 214 |
| 215 test_instanceCreation_implicit() { |
| 216 addTestFile(''' |
| 217 library my.library; |
| 218 class A { |
| 219 } |
| 220 main() { |
| 221 new A(); |
| 222 } |
| 223 '''); |
| 224 return prepareHover('new A').then((HoverInformation hover) { |
| 225 // range |
| 226 expect(hover.offset, findOffset('new A')); |
| 227 expect(hover.length, 'new A()'.length); |
| 228 // element |
| 229 expect(hover.containingLibraryName, 'my.library'); |
| 230 expect(hover.containingLibraryPath, testFile); |
| 231 expect(hover.dartdoc, isNull); |
| 232 expect(hover.elementDescription, 'A() → A'); |
| 233 expect(hover.elementKind, 'constructor'); |
| 234 // types |
| 235 expect(hover.staticType, 'A'); |
| 236 expect(hover.propagatedType, isNull); |
| 237 // no parameter |
| 238 expect(hover.parameter, isNull); |
| 239 }); |
| 240 } |
| 241 |
| 242 test_instanceCreation_implicit_withTypeArgument() { |
| 243 addTestFile(''' |
| 244 library my.library; |
| 245 class A<T> {} |
| 246 main() { |
| 247 new A<String>(); |
| 248 } |
| 249 '''); |
| 250 Function onConstructor = (HoverInformation hover) { |
| 251 // range |
| 252 expect(hover.offset, findOffset('new A<String>')); |
| 253 expect(hover.length, 'new A<String>()'.length); |
| 254 // element |
| 255 expect(hover.containingLibraryName, 'my.library'); |
| 256 expect(hover.containingLibraryPath, testFile); |
| 257 expect(hover.dartdoc, isNull); |
| 258 expect(hover.elementDescription, 'A() → A<String>'); |
| 259 expect(hover.elementKind, 'constructor'); |
| 260 // types |
| 261 expect(hover.staticType, 'A<String>'); |
| 262 expect(hover.propagatedType, isNull); |
| 263 // no parameter |
| 264 expect(hover.parameter, isNull); |
| 265 }; |
| 266 var futureNewA = prepareHover('new A').then(onConstructor); |
| 267 var futureA = prepareHover('A<String>()').then(onConstructor); |
| 268 var futureString = prepareHover('String>').then((HoverInformation hover) { |
| 269 expect(hover.offset, findOffset('String>')); |
| 270 expect(hover.length, 'String'.length); |
| 271 expect(hover.elementKind, 'class'); |
| 272 }); |
| 273 return Future.wait([futureNewA, futureA, futureString]); |
| 274 } |
| 275 |
| 276 test_instanceCreation_named() { |
| 277 addTestFile(''' |
| 278 library my.library; |
| 279 class A { |
| 280 /// my doc |
| 281 A.named() {} |
| 282 } |
| 283 main() { |
| 284 new A.named(); |
| 285 } |
| 286 '''); |
| 287 var onConstructor = (HoverInformation hover) { |
| 288 // range |
| 289 expect(hover.offset, findOffset('new A')); |
| 290 expect(hover.length, 'new A.named()'.length); |
| 291 // element |
| 292 expect(hover.dartdoc, 'my doc'); |
| 293 expect(hover.elementDescription, 'A.named() → A'); |
| 294 expect(hover.elementKind, 'constructor'); |
| 295 }; |
| 296 var futureCreation = prepareHover('new A').then(onConstructor); |
| 297 var futureName = prepareHover('named();').then(onConstructor); |
| 298 return Future.wait([futureCreation, futureName]); |
| 299 } |
| 300 |
| 215 test_noHoverInfo() { | 301 test_noHoverInfo() { |
| 216 addTestFile(''' | 302 addTestFile(''' |
| 217 library my.library; | 303 library my.library; |
| 218 main() { | 304 main() { |
| 219 // nothing | 305 // nothing |
| 220 } | 306 } |
| 221 '''); | 307 '''); |
| 222 return prepareHover('nothing').then((HoverInformation hover) { | 308 return prepareHover('nothing').then((HoverInformation hover) { |
| 223 expect(hover, isNull); | 309 expect(hover, isNull); |
| 224 }); | 310 }); |
| 225 } | 311 } |
| 226 } | 312 } |
| OLD | NEW |