@@ -7,18 +7,20 @@ library source_gen.annotation;
77import 'dart:io' ;
88import 'dart:mirrors' ;
99
10- import 'package:analyzer/src/generated/ast.dart' ;
10+ import 'package:analyzer/dart/ast/ast.dart' ;
11+ import 'package:analyzer/dart/element/element.dart' ;
12+ import 'package:analyzer/dart/element/type.dart' ;
1113import 'package:analyzer/src/generated/constant.dart' ;
12- import 'package:analyzer/src/generated/element.dart' ;
13- import 'package:analyzer/src/generated/utilities_dart.dart' ;
14+ import 'package:analyzer/src/generated/element.dart'
15+ show ConstructorElementImpl ;
1416import 'package:analyzer/src/generated/resolver.dart' ;
17+ import 'package:analyzer/src/generated/utilities_dart.dart' ;
1518import 'package:path/path.dart' as p;
1619
17- dynamic instantiateAnnotation (ElementAnnotationImpl annotation) {
18- var annotationObjectImpl = annotation.evaluationResult.value ;
20+ dynamic instantiateAnnotation (ElementAnnotation annotation) {
21+ var annotationObject = annotation.constantValue ;
1922 try {
20- return _getValue (
21- annotationObjectImpl, annotation.element.context.typeProvider);
23+ return _getValue (annotationObject, annotation.element.context.typeProvider);
2224 } on CannotCreateFromAnnotationException catch (e) {
2325 if (e.innerException != null ) {
2426 // If there was a issue creating a nested object, there's not much we
@@ -29,20 +31,19 @@ dynamic instantiateAnnotation(ElementAnnotationImpl annotation) {
2931
3032 var element = annotation.element;
3133
32- if (element is PropertyAccessorElementImpl ) {
33- var initializer = ((element as PropertyAccessorElementImpl )
34+ if (element is PropertyAccessorElement ) {
35+ var initializer = ((element as PropertyAccessorElement )
3436 .variable
3537 .computeNode () as VariableDeclaration )
3638 .initializer as InstanceCreationExpression ;
3739 element = initializer.staticElement;
3840 }
3941
40- if (element is ConstructorElementImpl ) {
41- return _createFromConstructor (element, annotationObjectImpl );
42+ if (element is ConstructorElement ) {
43+ return _createFromConstructor (element, annotationObject );
4244 }
4345
44- var valueDeclaration =
45- _getDeclMirrorFromType (annotation.evaluationResult.value.type);
46+ var valueDeclaration = _getDeclMirrorFromType (annotation.constantValue.type);
4647
4748 throw "No clue how to create $valueDeclaration of type ${valueDeclaration .runtimeType }" ;
4849}
@@ -75,7 +76,7 @@ dynamic _getValue(DartObject object, TypeProvider typeProvider) {
7576 if (object.type == typeProvider.typeType) {
7677 var typeData = object.toTypeValue ();
7778
78- if (typeData is InterfaceTypeImpl ) {
79+ if (typeData is InterfaceType ) {
7980 var declarationMirror = _getDeclMirrorFromType (typeData) as ClassMirror ;
8081
8182 return declarationMirror.reflectedType;
@@ -140,12 +141,13 @@ dynamic _createFromConstructor(
140141 for (var p in ctorDecl.parameters.parameterElements) {
141142 var paramName = p.name;
142143 String fieldName;
143- if (p is FieldFormalParameterElementImpl ) {
144+ if (p is FieldFormalParameterElement ) {
144145 fieldName = p.name;
145146 } else {
146147 // Trying to find the relationship between the ctor argument name and the
147148 // field assigned in the object. Then we can take the field value and
148149 // set it as the argument value
150+
149151 var initializer = ctor.constantInitializers.singleWhere ((ci) {
150152 var expression = (ci as ConstructorFieldInitializer ).expression;
151153 if (expression is SimpleIdentifier ) {
@@ -203,11 +205,11 @@ DeclarationMirror _getDeclMirrorFromType(InterfaceType type) {
203205 return libMirror.declarations[typeNameSymbol];
204206}
205207
206- bool matchAnnotation (Type annotationType, ElementAnnotationImpl annotation) {
208+ bool matchAnnotation (Type annotationType, ElementAnnotation annotation) {
207209 var classMirror = reflectClass (annotationType);
208210 var classMirrorSymbol = classMirror.simpleName;
209211
210- var annotationValueType = annotation.evaluationResult.value .type;
212+ var annotationValueType = annotation.constantValue .type;
211213
212214 var annTypeName = annotationValueType.name;
213215 var annotationTypeSymbol = new Symbol (annTypeName);
0 commit comments