Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/src/annotation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a Doc comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

var classMirror = reflectClass(annotationType);
var classMirrorSymbol = classMirror.simpleName;

var annTypeName = annotationValueType.name;
var annotationTypeSymbol = new Symbol(annTypeName);
Expand Down