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

Unified Diff: dart/site/try/poi/poi.dart

Issue 397843008: Add type information. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | dart/tests/try/poi/serialize_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/site/try/poi/poi.dart
diff --git a/dart/site/try/poi/poi.dart b/dart/site/try/poi/poi.dart
index e5ca439346d288179be31e5c0ce86da664eef7ad..af038c0442c8ab6f2aa2aa988338ece64da61029 100644
--- a/dart/site/try/poi/poi.dart
+++ b/dart/site/try/poi/poi.dart
@@ -44,9 +44,13 @@ import 'package:compiler/implementation/elements/elements.dart' show
ClassElement,
CompilationUnitElement,
Element,
+ ElementCategory,
LibraryElement,
ScopeContainerElement;
+import 'package:compiler/implementation/dart_types.dart' show
+ DartType;
+
import 'package:compiler/implementation/scanner/scannerlib.dart' show
EOF_TOKEN,
IDENTIFIER_TOKEN,
@@ -367,6 +371,13 @@ class ScopeInformationVisitor extends ElementVisitor/* <void> */ {
{bool omitEnclosing: true,
void serializeMembers(),
String name}) {
+ DartType type;
+ int category = element.kind.category;
+ if (category == ElementCategory.FUNCTION ||
+ category == ElementCategory.VARIABLE ||
+ element.isConstructor) {
+ type = element.computeType(cachedCompiler);
+ }
if (name == null) {
name = element.name;
}
@@ -380,7 +391,13 @@ class ScopeInformationVisitor extends ElementVisitor/* <void> */ {
..write('"kind": "')
..write(element.kind)
..write('"');
- // TODO(ahe): Add a type/signature field.
+ if (type != null) {
+ buffer.write(',\n');
+ indented
+ ..write('"type": "')
+ ..write(type)
+ ..write('"');
+ }
if (serializeMembers != null) {
buffer.write(',\n');
indented.write('"members": [');
« no previous file with comments | « no previous file | dart/tests/try/poi/serialize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698