| 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 'dart:mirrors'; | 7 import 'dart:mirrors'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 10 import 'package:analysis_server/src/protocol_server.dart'; | 10 import 'package:analysis_server/src/protocol_server.dart'; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 expect(location.offset, 25); | 301 expect(location.offset, 25); |
| 302 expect(location.length, 'myField'.length); | 302 expect(location.length, 'myField'.length); |
| 303 expect(location.startLine, 2); | 303 expect(location.startLine, 2); |
| 304 expect(location.startColumn, 16); | 304 expect(location.startColumn, 16); |
| 305 } | 305 } |
| 306 expect(element.parameters, isNull); | 306 expect(element.parameters, isNull); |
| 307 expect(element.returnType, 'dynamic'); | 307 expect(element.returnType, 'dynamic'); |
| 308 expect(element.flags, Element.FLAG_CONST | Element.FLAG_STATIC); | 308 expect(element.flags, Element.FLAG_CONST | Element.FLAG_STATIC); |
| 309 } | 309 } |
| 310 | 310 |
| 311 void test_fromElement_FUNCTION_TYPE_ALIAS() { |
| 312 engine.Source source = addSource('/test.dart', ''' |
| 313 typedef int f(String x); |
| 314 '''); |
| 315 engine.CompilationUnit unit = resolveLibraryUnit(source); |
| 316 engine.FunctionTypeAliasElement engineElement = findElementInUnit(unit, 'f')
; |
| 317 // create notification Element |
| 318 Element element = newElement_fromEngine(engineElement); |
| 319 expect(element.kind, ElementKind.FUNCTION_TYPE_ALIAS); |
| 320 expect(element.name, 'f'); |
| 321 { |
| 322 Location location = element.location; |
| 323 expect(location.file, '/test.dart'); |
| 324 expect(location.offset, 12); |
| 325 expect(location.length, 'f'.length); |
| 326 expect(location.startLine, 1); |
| 327 expect(location.startColumn, 13); |
| 328 } |
| 329 expect(element.parameters, '(String x)'); |
| 330 expect(element.returnType, 'int'); |
| 331 expect(element.flags, 0); |
| 332 } |
| 333 |
| 311 void test_fromElement_GETTER() { | 334 void test_fromElement_GETTER() { |
| 312 engine.Source source = addSource('/test.dart', ''' | 335 engine.Source source = addSource('/test.dart', ''' |
| 313 class A { | 336 class A { |
| 314 String get myGetter => 42; | 337 String get myGetter => 42; |
| 315 }'''); | 338 }'''); |
| 316 engine.CompilationUnit unit = resolveLibraryUnit(source); | 339 engine.CompilationUnit unit = resolveLibraryUnit(source); |
| 317 engine.PropertyAccessorElement engineElement = | 340 engine.PropertyAccessorElement engineElement = |
| 318 findElementInUnit(unit, 'myGetter', engine.ElementKind.GETTER); | 341 findElementInUnit(unit, 'myGetter', engine.ElementKind.GETTER); |
| 319 // create notification Element | 342 // create notification Element |
| 320 Element element = newElement_fromEngine(engineElement); | 343 Element element = newElement_fromEngine(engineElement); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 ApiEnum apiValue = convert(engineValue); | 515 ApiEnum apiValue = convert(engineValue); |
| 493 expect(apiValue, equals(expectedResult)); | 516 expect(apiValue, equals(expectedResult)); |
| 494 } | 517 } |
| 495 } else { | 518 } else { |
| 496 ApiEnum apiValue = convert(engineValue); | 519 ApiEnum apiValue = convert(engineValue); |
| 497 expect(apiValue.name, equals(enumName)); | 520 expect(apiValue.name, equals(enumName)); |
| 498 } | 521 } |
| 499 }); | 522 }); |
| 500 } | 523 } |
| 501 } | 524 } |
| OLD | NEW |