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

Unified Diff: pkg/docgen/lib/src/models/annotation.dart

Issue 716913005: Replace ResolvedNode by ConstantExpression. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 1 month 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
« no previous file with comments | « pkg/compiler/lib/src/mirrors/dart2js_mirrors.dart ('k') | pkg/docgen/lib/src/models/model_helpers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/docgen/lib/src/models/annotation.dart
diff --git a/pkg/docgen/lib/src/models/annotation.dart b/pkg/docgen/lib/src/models/annotation.dart
index 5a8dd11c19fa6d9a34f052b5cf7209dfcaa6dc47..766939cc932478e5aba4ba7844f71815c375ca0a 100644
--- a/pkg/docgen/lib/src/models/annotation.dart
+++ b/pkg/docgen/lib/src/models/annotation.dart
@@ -6,37 +6,22 @@ library docgen.models.annotation;
import '../exports/source_mirrors.dart';
-import '../exports/dart2js_mirrors.dart' show ResolvedNode;
-
import '../library_helpers.dart';
import 'library.dart';
import 'mirror_based.dart';
import 'dart:mirrors';
-import 'package:compiler/src/tree/tree.dart';
/// Holds the name of the annotation, and its parameters.
class Annotation extends MirrorBased<ClassMirror> {
/// The class of this annotation.
DeclarationMirror mirror;
- Send node;
final Library owningLibrary;
List<String> parameters;
- Annotation(ResolvedNode resolvedNode, this.owningLibrary) {
- parameters = [];
- getMirrorForResolvedNode(resolvedNode, (m, n) { mirror = m; node = n;},
- (String param) => parameters.add(param));
- }
-
- String getMirrorForResolvedNode(ResolvedNode node, callbackFunc,
- paramCallbackFunc) {
- ResolvedNodeMirrorFinder finder = new ResolvedNodeMirrorFinder(node,
- callbackFunc, paramCallbackFunc);
- finder.unparse(node.node);
- return finder.result;
- }
+ Annotation(this.owningLibrary, this.mirror,
+ [List<String> this.parameters = const <String>[]]);
Map toMap() => {
'name': owningLibrary.packagePrefix +
@@ -45,70 +30,3 @@ class Annotation extends MirrorBased<ClassMirror> {
};
}
-class ResolvedNodeMirrorFinder extends Unparser {
- final ResolvedNode resolvedNode;
- final Function annotationMirrorCallback;
- final Function parameterValueCallback;
- int recursionLevel;
-
- ResolvedNodeMirrorFinder(this.resolvedNode, this.annotationMirrorCallback,
- this.parameterValueCallback) : recursionLevel = 0;
-
- visitSend(Send node) {
- if (recursionLevel == 0) {
- var m = resolvedNode.resolvedMirror(node.selector);
- annotationMirrorCallback(m, node);
- } else {
- Operator op = node.selector.asOperator();
- String opString = op != null ? op.source : null;
- bool spacesNeeded =
- identical(opString, 'is') || identical(opString, 'as');
- if (node.isPrefix) visit(node.selector);
- unparseSendReceiver(node, spacesNeeded: spacesNeeded);
- if (!node.isPrefix && !node.isIndex) visit(node.selector);
- if (spacesNeeded) sb.write(' ');
- // Also add a space for sequences like x + +1 and y - -y.
- // TODO(ahe): remove case for '+' when we drop the support for it.
- if (node.argumentsNode != null && (identical(opString, '-')
- || identical(opString, '+'))) {
- var beginToken = node.argumentsNode.getBeginToken();
- if (beginToken != null &&
- identical(beginToken.stringValue, opString)) {
- sb.write(' ');
- }
- }
- }
- recursionLevel++;
- visit(node.argumentsNode);
- recursionLevel--;
- }
-
- unparseNodeListFrom(NodeList node, var from, {bool spaces: true}) {
- if (from.isEmpty) return;
-
- visit(from.head);
-
- for (var link = from.tail; !link.isEmpty; link = link.tail) {
- if (recursionLevel >= 2) {
- parameterValueCallback(sb.toString());
- sb.clear();
- }
- visit(link.head);
- }
- if (recursionLevel >= 2) {
- parameterValueCallback(sb.toString());
- sb.clear();
- }
- }
-
- visitNodeList(NodeList node) {
- addToken(node.beginToken);
- if (recursionLevel == 1) sb.clear();
- if (node.nodes != null) {
- recursionLevel++;
- unparseNodeListFrom(node, node.nodes);
- recursionLevel--;
- }
- if (node.endToken != null) write(node.endToken.value);
- }
-}
« no previous file with comments | « pkg/compiler/lib/src/mirrors/dart2js_mirrors.dart ('k') | pkg/docgen/lib/src/models/model_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698