| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 268 } |
| 269 | 269 |
| 270 void test_fromElement_ENUM() { | 270 void test_fromElement_ENUM() { |
| 271 engine.Source source = addSource('/test.dart', ''' | 271 engine.Source source = addSource('/test.dart', ''' |
| 272 @deprecated | 272 @deprecated |
| 273 enum _E1 { one, two } | 273 enum _E1 { one, two } |
| 274 enum E2 { three, four }'''); | 274 enum E2 { three, four }'''); |
| 275 engine.CompilationUnit unit = resolveLibraryUnit(source); | 275 engine.CompilationUnit unit = resolveLibraryUnit(source); |
| 276 { | 276 { |
| 277 engine.ClassElement engineElement = findElementInUnit(unit, '_E1'); | 277 engine.ClassElement engineElement = findElementInUnit(unit, '_E1'); |
| 278 // TODO (danrubel) determine why enum is not deprecated | 278 expect(engineElement.isDeprecated, isTrue); |
| 279 expect(engineElement.isDeprecated, isFalse); | |
| 280 // create notification Element | 279 // create notification Element |
| 281 Element element = newElement_fromEngine(engineElement); | 280 Element element = newElement_fromEngine(engineElement); |
| 282 expect(element.kind, ElementKind.ENUM); | 281 expect(element.kind, ElementKind.ENUM); |
| 283 expect(element.name, '_E1'); | 282 expect(element.name, '_E1'); |
| 284 expect(element.typeParameters, isNull); | 283 expect(element.typeParameters, isNull); |
| 285 { | 284 { |
| 286 Location location = element.location; | 285 Location location = element.location; |
| 287 expect(location.file, '/test.dart'); | 286 expect(location.file, '/test.dart'); |
| 288 expect(location.offset, 17); | 287 expect(location.offset, 17); |
| 289 expect(location.length, '_E1'.length); | 288 expect(location.length, '_E1'.length); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 Location location = element.location; | 321 Location location = element.location; |
| 323 expect(location.file, '/test.dart'); | 322 expect(location.file, '/test.dart'); |
| 324 expect(location.offset, 23); | 323 expect(location.offset, 23); |
| 325 expect(location.length, 'one'.length); | 324 expect(location.length, 'one'.length); |
| 326 expect(location.startLine, 2); | 325 expect(location.startLine, 2); |
| 327 expect(location.startColumn, 12); | 326 expect(location.startColumn, 12); |
| 328 } | 327 } |
| 329 expect(element.parameters, isNull); | 328 expect(element.parameters, isNull); |
| 330 expect(element.returnType, '_E1'); | 329 expect(element.returnType, '_E1'); |
| 331 // TODO(danrubel) determine why enum constant is not marked as deprecated | 330 // TODO(danrubel) determine why enum constant is not marked as deprecated |
| 332 engine.ClassElement classElement = engineElement.enclosingElement; | 331 //engine.ClassElement classElement = engineElement.enclosingElement; |
| 332 //expect(classElement.isDeprecated, isTrue); |
| 333 expect(element.flags, | 333 expect(element.flags, |
| 334 (classElement.isDeprecated ? Element.FLAG_DEPRECATED : 0) | | 334 // Element.FLAG_DEPRECATED | |
| 335 Element.FLAG_CONST | | 335 Element.FLAG_CONST | Element.FLAG_STATIC); |
| 336 Element.FLAG_STATIC); | |
| 337 } | 336 } |
| 338 { | 337 { |
| 339 engine.FieldElement engineElement = findElementInUnit(unit, 'three'); | 338 engine.FieldElement engineElement = findElementInUnit(unit, 'three'); |
| 340 // create notification Element | 339 // create notification Element |
| 341 Element element = newElement_fromEngine(engineElement); | 340 Element element = newElement_fromEngine(engineElement); |
| 342 expect(element.kind, ElementKind.ENUM_CONSTANT); | 341 expect(element.kind, ElementKind.ENUM_CONSTANT); |
| 343 expect(element.name, 'three'); | 342 expect(element.name, 'three'); |
| 344 { | 343 { |
| 345 Location location = element.location; | 344 Location location = element.location; |
| 346 expect(location.file, '/test.dart'); | 345 expect(location.file, '/test.dart'); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 ApiEnum apiValue = convert(engineValue); | 619 ApiEnum apiValue = convert(engineValue); |
| 621 expect(apiValue, equals(expectedResult)); | 620 expect(apiValue, equals(expectedResult)); |
| 622 } | 621 } |
| 623 } else { | 622 } else { |
| 624 ApiEnum apiValue = convert(engineValue); | 623 ApiEnum apiValue = convert(engineValue); |
| 625 expect(apiValue.name, equals(enumName)); | 624 expect(apiValue.name, equals(enumName)); |
| 626 } | 625 } |
| 627 }); | 626 }); |
| 628 } | 627 } |
| 629 } | 628 } |
| OLD | NEW |