diff --git a/lib/src/annotation.dart b/lib/src/annotation.dart index 3e567435..4df22320 100644 --- a/lib/src/annotation.dart +++ b/lib/src/annotation.dart @@ -214,15 +214,25 @@ DeclarationMirror _getDeclarationMirrorFromType(InterfaceType type) { return libMirror.declarations[typeNameSymbol]; } +/// Checks whether the constant type of [annotation] is equivalent to +/// [annotationType]. bool matchAnnotation(Type annotationType, ElementAnnotation annotation) { - var classMirror = reflectClass(annotationType); - var classMirrorSymbol = classMirror.simpleName; - var annotationValueType = annotation.constantValue?.type; if (annotationValueType == null) { throw new ArgumentError.value(annotation, 'annotation', 'Could not determine type of annotation. Are you missing a dependency?'); } + + return matchTypes(annotationType, annotationValueType); +} + +/// Checks whether [annotationValueType] is equivalent to [annotationType]. +/// +/// Currently, this uses mirrors to compare the name and library uri of the two +/// types. +bool matchTypes(Type annotationType, ParameterizedType annotationValueType) { + var classMirror = reflectClass(annotationType); + var classMirrorSymbol = classMirror.simpleName; var annTypeName = annotationValueType.name; var annotationTypeSymbol = new Symbol(annTypeName);