Chromium Code Reviews| 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.computer.element; | 5 library test.computer.element; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/element.dart' as engine; | 9 import 'package:analyzer/src/generated/element.dart' as engine; |
| 10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 expect(location.offset, 32); | 276 expect(location.offset, 32); |
| 277 expect(location.length, 'myGetter'.length); | 277 expect(location.length, 'myGetter'.length); |
| 278 expect(location.startLine, 2); | 278 expect(location.startLine, 2); |
| 279 expect(location.startColumn, 23); | 279 expect(location.startColumn, 23); |
| 280 } | 280 } |
| 281 expect(element.parameters, '(int a, {String b})'); | 281 expect(element.parameters, '(int a, {String b})'); |
| 282 expect(element.returnType, 'List<String>'); | 282 expect(element.returnType, 'List<String>'); |
| 283 expect(element.flags, Element.FLAG_STATIC); | 283 expect(element.flags, Element.FLAG_STATIC); |
| 284 } | 284 } |
| 285 | 285 |
| 286 void test_fromElement_SETTER() { | |
| 287 Source source = addSource('/test.dart', ''' | |
| 288 class A { | |
| 289 set mySetter(String x) {} | |
| 290 }'''); | |
| 291 CompilationUnit unit = resolveLibraryUnit(source); | |
| 292 engine.FieldElement engineFieldElement = | |
| 293 findElementInUnit(unit, 'mySetter', engine.ElementKind.FIELD); | |
|
Brian Wilkerson
2014/09/16 22:47:46
The "engine.ElementKind.FIELD" argument looks stra
danrubel
2014/09/16 23:12:30
I was surprised as well, but my current understand
| |
| 294 engine.PropertyAccessorElement engineElement = engineFieldElement.setter; | |
| 295 // create notification Element | |
| 296 Element element = new Element.fromEngine(engineElement); | |
| 297 expect(element.kind, ElementKind.SETTER); | |
| 298 expect(element.name, 'mySetter'); | |
| 299 { | |
| 300 Location location = element.location; | |
| 301 expect(location.file, '/test.dart'); | |
| 302 expect(location.offset, 16); | |
| 303 expect(location.length, 'mySetter'.length); | |
| 304 expect(location.startLine, 2); | |
| 305 expect(location.startColumn, 7); | |
| 306 } | |
| 307 expect(element.parameters, '(String x)'); | |
| 308 expect(element.returnType, isNull); | |
| 309 expect(element.flags, 0); | |
| 310 } | |
| 311 | |
| 286 void test_fromElement_dynamic() { | 312 void test_fromElement_dynamic() { |
| 287 var engineElement = engine.DynamicElementImpl.instance; | 313 var engineElement = engine.DynamicElementImpl.instance; |
| 288 // create notification Element | 314 // create notification Element |
| 289 Element element = new Element.fromEngine(engineElement); | 315 Element element = new Element.fromEngine(engineElement); |
| 290 expect(element.kind, ElementKind.UNKNOWN); | 316 expect(element.kind, ElementKind.UNKNOWN); |
| 291 expect(element.name, 'dynamic'); | 317 expect(element.name, 'dynamic'); |
| 292 expect(element.location, isNull); | 318 expect(element.location, isNull); |
| 293 expect(element.parameters, isNull); | 319 expect(element.parameters, isNull); |
| 294 expect(element.returnType, isNull); | 320 expect(element.returnType, isNull); |
| 295 expect(element.flags, 0); | 321 expect(element.flags, 0); |
| 296 } | 322 } |
| 297 } | 323 } |
| OLD | NEW |