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

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

Issue 574683002: Use ConstExp for storing constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes and further implementation. Created 6 years, 3 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: pkg/docgen/lib/src/models/model_helpers.dart
diff --git a/pkg/docgen/lib/src/models/model_helpers.dart b/pkg/docgen/lib/src/models/model_helpers.dart
index e5e55a0e95cc6b8f5d6c1ba0dd8af342aa820279..359706d61dcb8b2983ffe50caa60b2bf9f8e8dc9 100644
--- a/pkg/docgen/lib/src/models/model_helpers.dart
+++ b/pkg/docgen/lib/src/models/model_helpers.dart
@@ -42,39 +42,10 @@ Map expandMethodMap(Map<String, Method> mapToExpand) => {
String getDefaultValue(ParameterMirror mirror) {
if (!mirror.hasDefaultValue) return null;
- return getDefaultValueFromConstMirror(mirror.defaultValue);
-}
-
-String getDefaultValueFromConstMirror(
- dart2js_mirrors.Dart2JsConstantMirror valueMirror) {
-
- if (valueMirror is dart2js_mirrors.Dart2JsStringConstantMirror) {
- return '"${valueMirror.reflectee}"';
- }
-
- if (valueMirror is dart2js_mirrors.Dart2JsListConstantMirror) {
- var buffer = new StringBuffer('[');
-
- var values = new Iterable.generate(valueMirror.length,
- (i) => valueMirror.getElement(i))
- .map((e) => getDefaultValueFromConstMirror(e));
-
- buffer.writeAll(values, ', ');
-
- buffer.write(']');
- return buffer.toString();
- }
-
- if (valueMirror is dart2js_mirrors.Dart2JsMapConstantMirror) {
- // TODO(kevmoo) Handle non-empty case
- if (valueMirror.length == 0) return '{}';
- }
-
- // TODO(kevmoo) Handle consts of non-core types
-
- return '${valueMirror}';
+ return '${mirror.defaultValue}';
}
+// TODO(johnniwinther): Use the `ConstExp` classes instead of `ResolvedNode`.
/// Returns a list of meta annotations assocated with a mirror.
List<Annotation> createAnnotations(DeclarationMirror mirror,
Library owningLibrary) {
« no previous file with comments | « no previous file | pkg/docgen/test/constant_argument_test.dart » ('j') | sdk/lib/_internal/compiler/implementation/compiler.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698