| 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/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 expect(hover.dartdoc, '''doc aaa\ndoc bbb'''); | 231 expect(hover.dartdoc, '''doc aaa\ndoc bbb'''); |
| 232 expect(hover.elementDescription, 'mmm(int a, String b) → List<String>'); | 232 expect(hover.elementDescription, 'mmm(int a, String b) → List<String>'); |
| 233 expect(hover.elementKind, 'method'); | 233 expect(hover.elementKind, 'method'); |
| 234 // types | 234 // types |
| 235 expect(hover.staticType, isNull); | 235 expect(hover.staticType, isNull); |
| 236 expect(hover.propagatedType, isNull); | 236 expect(hover.propagatedType, isNull); |
| 237 // no parameter | 237 // no parameter |
| 238 expect(hover.parameter, isNull); | 238 expect(hover.parameter, isNull); |
| 239 } | 239 } |
| 240 | 240 |
| 241 test_expression_method_deprecated() async { |
| 242 addTestFile(''' |
| 243 class A { |
| 244 @deprecated |
| 245 static void test() {} |
| 246 } |
| 247 main() { |
| 248 A.test(); |
| 249 } |
| 250 '''); |
| 251 HoverInformation hover = await prepareHover('test();'); |
| 252 // element |
| 253 expect(hover.containingLibraryPath, testFile); |
| 254 expect(hover.elementDescription, 'test() → void'); |
| 255 expect(hover.elementKind, 'method'); |
| 256 expect(hover.isDeprecated, isTrue); |
| 257 } |
| 258 |
| 241 test_expression_method_invocation() async { | 259 test_expression_method_invocation() async { |
| 242 addTestFile(''' | 260 addTestFile(''' |
| 243 library my.library; | 261 library my.library; |
| 244 class A { | 262 class A { |
| 245 List<String> mmm(int a, String b) { | 263 List<String> mmm(int a, String b) { |
| 246 } | 264 } |
| 247 } | 265 } |
| 248 main(A a) { | 266 main(A a) { |
| 249 a.mmm(42, 'foo'); | 267 a.mmm(42, 'foo'); |
| 250 } | 268 } |
| 251 '''); | 269 '''); |
| 252 HoverInformation hover = await prepareHover('mm(42, '); | 270 HoverInformation hover = await prepareHover('mm(42, '); |
| 253 // range | 271 // range |
| 254 expect(hover.offset, findOffset('mmm(42, ')); | 272 expect(hover.offset, findOffset('mmm(42, ')); |
| 255 expect(hover.length, 'mmm'.length); | 273 expect(hover.length, 'mmm'.length); |
| 256 // element | 274 // element |
| 257 expect(hover.containingLibraryName, 'my.library'); | 275 expect(hover.containingLibraryName, 'my.library'); |
| 258 expect(hover.containingLibraryPath, testFile); | 276 expect(hover.containingLibraryPath, testFile); |
| 259 expect(hover.elementDescription, 'mmm(int a, String b) → List<String>'); | 277 expect(hover.elementDescription, 'mmm(int a, String b) → List<String>'); |
| 260 expect(hover.elementKind, 'method'); | 278 expect(hover.elementKind, 'method'); |
| 279 expect(hover.isDeprecated, isFalse); |
| 261 // types | 280 // types |
| 262 expect(hover.staticType, '(int, String) → List<String>'); | 281 expect(hover.staticType, '(int, String) → List<String>'); |
| 263 expect(hover.propagatedType, isNull); | 282 expect(hover.propagatedType, isNull); |
| 264 // no parameter | 283 // no parameter |
| 265 expect(hover.parameter, isNull); | 284 expect(hover.parameter, isNull); |
| 266 } | 285 } |
| 267 | 286 |
| 268 test_expression_parameter() async { | 287 test_expression_parameter() async { |
| 269 addTestFile(''' | 288 addTestFile(''' |
| 270 library my.library; | 289 library my.library; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 expect(hover.containingLibraryPath, testFile); | 421 expect(hover.containingLibraryPath, testFile); |
| 403 expect(hover.dartdoc, isNull); | 422 expect(hover.dartdoc, isNull); |
| 404 expect(hover.elementDescription, 'A() → A<String>'); | 423 expect(hover.elementDescription, 'A() → A<String>'); |
| 405 expect(hover.elementKind, 'constructor'); | 424 expect(hover.elementKind, 'constructor'); |
| 406 // types | 425 // types |
| 407 expect(hover.staticType, isNull); | 426 expect(hover.staticType, isNull); |
| 408 expect(hover.propagatedType, isNull); | 427 expect(hover.propagatedType, isNull); |
| 409 // no parameter | 428 // no parameter |
| 410 expect(hover.parameter, isNull); | 429 expect(hover.parameter, isNull); |
| 411 } | 430 } |
| 431 |
| 412 { | 432 { |
| 413 HoverInformation hover = await prepareHover('new A'); | 433 HoverInformation hover = await prepareHover('new A'); |
| 414 onConstructor(hover); | 434 onConstructor(hover); |
| 415 } | 435 } |
| 416 { | 436 { |
| 417 HoverInformation hover = await prepareHover('A<String>()'); | 437 HoverInformation hover = await prepareHover('A<String>()'); |
| 418 onConstructor(hover); | 438 onConstructor(hover); |
| 419 } | 439 } |
| 420 { | 440 { |
| 421 HoverInformation hover = await prepareHover('String>'); | 441 HoverInformation hover = await prepareHover('String>'); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 438 '''); | 458 '''); |
| 439 void onConstructor(HoverInformation hover) { | 459 void onConstructor(HoverInformation hover) { |
| 440 // range | 460 // range |
| 441 expect(hover.offset, findOffset('new A')); | 461 expect(hover.offset, findOffset('new A')); |
| 442 expect(hover.length, 'new A.named()'.length); | 462 expect(hover.length, 'new A.named()'.length); |
| 443 // element | 463 // element |
| 444 expect(hover.dartdoc, 'my doc'); | 464 expect(hover.dartdoc, 'my doc'); |
| 445 expect(hover.elementDescription, 'A.named() → A'); | 465 expect(hover.elementDescription, 'A.named() → A'); |
| 446 expect(hover.elementKind, 'constructor'); | 466 expect(hover.elementKind, 'constructor'); |
| 447 } | 467 } |
| 468 |
| 448 { | 469 { |
| 449 HoverInformation hover = await prepareHover('new A'); | 470 HoverInformation hover = await prepareHover('new A'); |
| 450 onConstructor(hover); | 471 onConstructor(hover); |
| 451 } | 472 } |
| 452 { | 473 { |
| 453 HoverInformation hover = await prepareHover('named();'); | 474 HoverInformation hover = await prepareHover('named();'); |
| 454 onConstructor(hover); | 475 onConstructor(hover); |
| 455 } | 476 } |
| 456 } | 477 } |
| 457 | 478 |
| 458 test_noHoverInfo() async { | 479 test_noHoverInfo() async { |
| 459 addTestFile(''' | 480 addTestFile(''' |
| 460 library my.library; | 481 library my.library; |
| 461 main() { | 482 main() { |
| 462 // nothing | 483 // nothing |
| 463 } | 484 } |
| 464 '''); | 485 '''); |
| 465 HoverInformation hover = await prepareHover('nothing'); | 486 HoverInformation hover = await prepareHover('nothing'); |
| 466 expect(hover, isNull); | 487 expect(hover, isNull); |
| 467 } | 488 } |
| 468 } | 489 } |
| OLD | NEW |