Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2581)

Unified Diff: lib/src/utils.dart

Issue 1145833004: fixes #173, ability to use native JS indexers (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/src/utils.dart
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 4c7339520c673f724b77c967c1d74164a4615bbe..d89e05ac18e48ee26b658c12761ebe32aae836b8 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -349,7 +349,7 @@ String resourceOutputPath(Uri resourceUri, Uri entryUri) {
///
/// (v) => v.type.name == 'Deprecated' && v.type.element.library.isDartCore
///
-DartObjectImpl getAnnotationValue(
+DartObjectImpl findNodeAnnotation(
AnnotatedNode node, bool test(DartObjectImpl value)) {
vsm 2015/05/20 19:15:29 Could this just call findElementAnnotation(node.el
Jennifer Messerly 2015/05/20 19:25:32 you'd think so, but AnnotatedNode doesn't have .el
vsm 2015/05/20 19:39:50 sgtm
for (var metadata in node.metadata) {
ElementAnnotationImpl element = metadata.elementAnnotation;
@@ -364,6 +364,19 @@ DartObjectImpl getAnnotationValue(
return null;
}
+/// Similar to [findNodeAnnotation] but starts from any element.
+DartObjectImpl findElementAnnotation(
+ Element element, bool test(DartObjectImpl value)) {
+ for (var metadata in element.metadata) {
+ var evalResult = metadata.evaluationResult;
+ if (evalResult == null) continue;
+
+ var value = evalResult.value;
+ if (value != null && test(value)) return value;
+ }
+ return null;
+}
+
/// Given a constant [value], a [fieldName], and an [expectedType], returns the
/// value of that field.
///

Powered by Google App Engine
This is Rietveld 408576698