| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:analyzer/dart/ast/ast.dart' as analyzer; | 5 import 'package:analyzer/dart/ast/ast.dart' as analyzer; |
| 6 import 'package:analyzer/dart/element/element.dart' as analyzer; | 6 import 'package:analyzer/dart/element/element.dart' as analyzer; |
| 7 import 'package:analyzer/dart/element/type.dart' as analyzer; | 7 import 'package:analyzer/dart/element/type.dart' as analyzer; |
| 8 import 'package:analyzer/error/error.dart' as analyzer; | 8 import 'package:analyzer/error/error.dart' as analyzer; |
| 9 import 'package:analyzer/exception/exception.dart' as analyzer; | 9 import 'package:analyzer/exception/exception.dart' as analyzer; |
| 10 import 'package:analyzer/source/error_processor.dart' as analyzer; | 10 import 'package:analyzer/source/error_processor.dart' as analyzer; |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 expect(location.length, 'three'.length); | 347 expect(location.length, 'three'.length); |
| 348 expect(location.startLine, 3); | 348 expect(location.startLine, 3); |
| 349 expect(location.startColumn, 11); | 349 expect(location.startColumn, 11); |
| 350 } | 350 } |
| 351 expect(element.parameters, isNull); | 351 expect(element.parameters, isNull); |
| 352 expect(element.returnType, 'E2'); | 352 expect(element.returnType, 'E2'); |
| 353 expect(element.flags, | 353 expect(element.flags, |
| 354 plugin.Element.FLAG_CONST | plugin.Element.FLAG_STATIC); | 354 plugin.Element.FLAG_CONST | plugin.Element.FLAG_STATIC); |
| 355 } | 355 } |
| 356 { | 356 { |
| 357 analyzer.FieldElement engineElement = findElementInUnit(unit, 'index'); | 357 analyzer.FieldElement engineElement = |
| 358 unit.element.enums[1].getField('index'); |
| 358 // create notification Element | 359 // create notification Element |
| 359 plugin.Element element = converter.convertElement(engineElement); | 360 plugin.Element element = converter.convertElement(engineElement); |
| 360 expect(element.kind, plugin.ElementKind.FIELD); | 361 expect(element.kind, plugin.ElementKind.FIELD); |
| 361 expect(element.name, 'index'); | 362 expect(element.name, 'index'); |
| 362 { | 363 { |
| 363 plugin.Location location = element.location; | 364 plugin.Location location = element.location; |
| 364 expect(location.file, testFile); | 365 expect(location.file, testFile); |
| 365 expect(location.offset, -1); | 366 expect(location.offset, -1); |
| 366 expect(location.length, 'index'.length); | 367 expect(location.length, 'index'.length); |
| 367 expect(location.startLine, 1); | 368 expect(location.startLine, 1); |
| 368 expect(location.startColumn, 0); | 369 expect(location.startColumn, 0); |
| 369 } | 370 } |
| 370 expect(element.parameters, isNull); | 371 expect(element.parameters, isNull); |
| 371 expect(element.returnType, 'int'); | 372 expect(element.returnType, 'int'); |
| 372 expect(element.flags, plugin.Element.FLAG_FINAL); | 373 expect(element.flags, plugin.Element.FLAG_FINAL); |
| 373 } | 374 } |
| 374 { | 375 { |
| 375 analyzer.FieldElement engineElement = findElementInUnit(unit, 'values'); | 376 analyzer.FieldElement engineElement = |
| 377 unit.element.enums[1].getField('values'); |
| 378 |
| 376 // create notification Element | 379 // create notification Element |
| 377 plugin.Element element = converter.convertElement(engineElement); | 380 plugin.Element element = converter.convertElement(engineElement); |
| 378 expect(element.kind, plugin.ElementKind.FIELD); | 381 expect(element.kind, plugin.ElementKind.FIELD); |
| 379 expect(element.name, 'values'); | 382 expect(element.name, 'values'); |
| 380 { | 383 { |
| 381 plugin.Location location = element.location; | 384 plugin.Location location = element.location; |
| 382 expect(location.file, testFile); | 385 expect(location.file, testFile); |
| 383 expect(location.offset, -1); | 386 expect(location.offset, -1); |
| 384 expect(location.length, 'values'.length); | 387 expect(location.length, 'values'.length); |
| 385 expect(location.startLine, 1); | 388 expect(location.startLine, 1); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 } | 505 } |
| 503 | 506 |
| 504 test_convertElement_setter() async { | 507 test_convertElement_setter() async { |
| 505 analyzer.Source source = addSource( | 508 analyzer.Source source = addSource( |
| 506 testFile, | 509 testFile, |
| 507 ''' | 510 ''' |
| 508 class A { | 511 class A { |
| 509 set mySetter(String x) {} | 512 set mySetter(String x) {} |
| 510 }'''); | 513 }'''); |
| 511 analyzer.CompilationUnit unit = await resolveLibraryUnit(source); | 514 analyzer.CompilationUnit unit = await resolveLibraryUnit(source); |
| 512 analyzer.FieldElement engineFieldElement = | 515 analyzer.PropertyAccessorElement engineElement = |
| 513 findElementInUnit(unit, 'mySetter', analyzer.ElementKind.FIELD); | 516 findElementInUnit(unit, 'mySetter', analyzer.ElementKind.SETTER); |
| 514 analyzer.PropertyAccessorElement engineElement = engineFieldElement.setter; | |
| 515 // create notification Element | 517 // create notification Element |
| 516 plugin.Element element = converter.convertElement(engineElement); | 518 plugin.Element element = converter.convertElement(engineElement); |
| 517 expect(element.kind, plugin.ElementKind.SETTER); | 519 expect(element.kind, plugin.ElementKind.SETTER); |
| 518 expect(element.name, 'mySetter'); | 520 expect(element.name, 'mySetter'); |
| 519 { | 521 { |
| 520 plugin.Location location = element.location; | 522 plugin.Location location = element.location; |
| 521 expect(location.file, testFile); | 523 expect(location.file, testFile); |
| 522 expect(location.offset, 16); | 524 expect(location.offset, 16); |
| 523 expect(location.length, 'mySetter'.length); | 525 expect(location.length, 'mySetter'.length); |
| 524 expect(location.startLine, 2); | 526 expect(location.startLine, 2); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 expect(location.offset, 9); | 603 expect(location.offset, 9); |
| 602 expect(location.length, 'myLabel'.length); | 604 expect(location.length, 'myLabel'.length); |
| 603 expect(location.startLine, 2); | 605 expect(location.startLine, 2); |
| 604 expect(location.startColumn, 1); | 606 expect(location.startColumn, 1); |
| 605 } | 607 } |
| 606 expect(element.parameters, isNull); | 608 expect(element.parameters, isNull); |
| 607 expect(element.returnType, isNull); | 609 expect(element.returnType, isNull); |
| 608 expect(element.flags, 0); | 610 expect(element.flags, 0); |
| 609 } | 611 } |
| 610 } | 612 } |
| OLD | NEW |