| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 List<String> mmm(int a, String b) { | 122 List<String> mmm(int a, String b) { |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 '''); | 125 '''); |
| 126 return prepareHover('mmm(int a').then((HoverInformation hover) { | 126 return prepareHover('mmm(int a').then((HoverInformation hover) { |
| 127 // element | 127 // element |
| 128 expect(hover.containingLibraryName, 'my.library'); | 128 expect(hover.containingLibraryName, 'my.library'); |
| 129 expect(hover.containingLibraryPath, testFile); | 129 expect(hover.containingLibraryPath, testFile); |
| 130 expect(hover.containingClassDescription, 'A'); | 130 expect(hover.containingClassDescription, 'A'); |
| 131 expect(hover.dartdoc, '''doc aaa\ndoc bbb'''); | 131 expect(hover.dartdoc, '''doc aaa\ndoc bbb'''); |
| 132 expect(hover.elementDescription, 'A.mmm(int a, String b) → List<String>'); | 132 expect(hover.elementDescription, 'mmm(int a, String b) → List<String>'); |
| 133 expect(hover.elementKind, 'method'); | 133 expect(hover.elementKind, 'method'); |
| 134 // types | 134 // types |
| 135 expect(hover.staticType, '(int, String) → List<String>'); | 135 expect(hover.staticType, '(int, String) → List<String>'); |
| 136 expect(hover.propagatedType, isNull); | 136 expect(hover.propagatedType, isNull); |
| 137 // no parameter | 137 // no parameter |
| 138 expect(hover.parameter, isNull); | 138 expect(hover.parameter, isNull); |
| 139 }); | 139 }); |
| 140 } | 140 } |
| 141 | 141 |
| 142 test_expression_method_invocation() { | 142 test_expression_method_invocation() { |
| 143 addTestFile(''' | 143 addTestFile(''' |
| 144 library my.library; | 144 library my.library; |
| 145 class A { | 145 class A { |
| 146 List<String> mmm(int a, String b) { | 146 List<String> mmm(int a, String b) { |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 main(A a) { | 149 main(A a) { |
| 150 a.mmm(42, 'foo'); | 150 a.mmm(42, 'foo'); |
| 151 } | 151 } |
| 152 '''); | 152 '''); |
| 153 return prepareHover('mm(42, ').then((HoverInformation hover) { | 153 return prepareHover('mm(42, ').then((HoverInformation hover) { |
| 154 // range | 154 // range |
| 155 expect(hover.offset, findOffset('mmm(42, ')); | 155 expect(hover.offset, findOffset('mmm(42, ')); |
| 156 expect(hover.length, 'mmm'.length); | 156 expect(hover.length, 'mmm'.length); |
| 157 // element | 157 // element |
| 158 expect(hover.containingLibraryName, 'my.library'); | 158 expect(hover.containingLibraryName, 'my.library'); |
| 159 expect(hover.containingLibraryPath, testFile); | 159 expect(hover.containingLibraryPath, testFile); |
| 160 expect(hover.elementDescription, 'A.mmm(int a, String b) → List<String>'); | 160 expect(hover.elementDescription, 'mmm(int a, String b) → List<String>'); |
| 161 expect(hover.elementKind, 'method'); | 161 expect(hover.elementKind, 'method'); |
| 162 // types | 162 // types |
| 163 expect(hover.staticType, isNull); | 163 expect(hover.staticType, isNull); |
| 164 expect(hover.propagatedType, isNull); | 164 expect(hover.propagatedType, isNull); |
| 165 // no parameter | 165 // no parameter |
| 166 expect(hover.parameter, isNull); | 166 expect(hover.parameter, isNull); |
| 167 }); | 167 }); |
| 168 } | 168 } |
| 169 | 169 |
| 170 test_expression_syntheticGetter() { | 170 test_expression_syntheticGetter() { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 196 test_expression_variable_hasPropagatedType() { | 196 test_expression_variable_hasPropagatedType() { |
| 197 addTestFile(''' | 197 addTestFile(''' |
| 198 library my.library; | 198 library my.library; |
| 199 main() { | 199 main() { |
| 200 var vvv = 123; | 200 var vvv = 123; |
| 201 print(vvv); | 201 print(vvv); |
| 202 } | 202 } |
| 203 '''); | 203 '''); |
| 204 return prepareHover('vvv);').then((HoverInformation hover) { | 204 return prepareHover('vvv);').then((HoverInformation hover) { |
| 205 // element | 205 // element |
| 206 expect(hover.containingLibraryName, 'my.library'); | 206 expect(hover.containingLibraryName, isNull); |
| 207 expect(hover.containingLibraryPath, testFile); | 207 expect(hover.containingLibraryPath, isNull); |
| 208 expect(hover.containingClassDescription, isNull); |
| 208 expect(hover.dartdoc, isNull); | 209 expect(hover.dartdoc, isNull); |
| 209 expect(hover.elementDescription, 'dynamic vvv'); | 210 expect(hover.elementDescription, 'dynamic vvv'); |
| 210 expect(hover.elementKind, 'local variable'); | 211 expect(hover.elementKind, 'local variable'); |
| 211 // types | 212 // types |
| 212 expect(hover.staticType, 'dynamic'); | 213 expect(hover.staticType, 'dynamic'); |
| 213 expect(hover.propagatedType, 'int'); | 214 expect(hover.propagatedType, 'int'); |
| 214 }); | 215 }); |
| 215 } | 216 } |
| 216 | 217 |
| 218 test_expression_variable_inMethod() { |
| 219 addTestFile(''' |
| 220 library my.library; |
| 221 class A { |
| 222 m() { |
| 223 num vvv = 42; |
| 224 } |
| 225 } |
| 226 '''); |
| 227 return prepareHover('vvv = 42').then((HoverInformation hover) { |
| 228 // element |
| 229 expect(hover.containingLibraryName, isNull); |
| 230 expect(hover.containingLibraryPath, isNull); |
| 231 expect(hover.containingClassDescription, isNull); |
| 232 expect(hover.dartdoc, isNull); |
| 233 expect(hover.elementDescription, 'num vvv'); |
| 234 expect(hover.elementKind, 'local variable'); |
| 235 // types |
| 236 expect(hover.staticType, 'num'); |
| 237 expect(hover.propagatedType, 'int'); |
| 238 // no parameter |
| 239 expect(hover.parameter, isNull); |
| 240 }); |
| 241 } |
| 242 |
| 217 test_instanceCreation_implicit() { | 243 test_instanceCreation_implicit() { |
| 218 addTestFile(''' | 244 addTestFile(''' |
| 219 library my.library; | 245 library my.library; |
| 220 class A { | 246 class A { |
| 221 } | 247 } |
| 222 main() { | 248 main() { |
| 223 new A(); | 249 new A(); |
| 224 } | 250 } |
| 225 '''); | 251 '''); |
| 226 return prepareHover('new A').then((HoverInformation hover) { | 252 return prepareHover('new A').then((HoverInformation hover) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 library my.library; | 331 library my.library; |
| 306 main() { | 332 main() { |
| 307 // nothing | 333 // nothing |
| 308 } | 334 } |
| 309 '''); | 335 '''); |
| 310 return prepareHover('nothing').then((HoverInformation hover) { | 336 return prepareHover('nothing').then((HoverInformation hover) { |
| 311 expect(hover, isNull); | 337 expect(hover, isNull); |
| 312 }); | 338 }); |
| 313 } | 339 } |
| 314 } | 340 } |
| OLD | NEW |