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

Unified Diff: pkg/smoke/lib/smoke.dart

Issue 173473002: Adapting observe to use smoke (this is built on top of the previous change that (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | « pkg/smoke/lib/mirrors.dart ('k') | pkg/smoke/lib/static.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/smoke/lib/smoke.dart
diff --git a/pkg/smoke/lib/smoke.dart b/pkg/smoke/lib/smoke.dart
index 4815d026a927d22475ec92f0bd88bd61065f9822..3577bf108aa82384f66330e5f1a4d41f21990304 100644
--- a/pkg/smoke/lib/smoke.dart
+++ b/pkg/smoke/lib/smoke.dart
@@ -84,7 +84,10 @@ Symbol nameToSymbol(String name) =>
/// hierarchy. For now only public instance symbols can be queried (no private,
/// no static).
class QueryOptions {
- /// Whether to include fields, getters, and setters.
+ /// Whether to include fields (default is true).
+ final bool includeFields;
+
+ /// Whether to include getters and setters (default is true).
final bool includeProperties;
/// Whether to include symbols from the given type and its superclasses
@@ -103,8 +106,12 @@ class QueryOptions {
/// included.
final List withAnnotations;
- const QueryOptions({this.includeProperties: true, this.includeInherited: true,
- this.excludeFinal: false, this.includeMethods: false,
+ const QueryOptions({
+ this.includeFields: true,
+ this.includeProperties: true,
+ this.includeInherited: true,
+ this.excludeFinal: false,
+ this.includeMethods: false,
this.withAnnotations: null});
}
@@ -114,11 +121,17 @@ class Declaration {
/// Name of the property or method
final Symbol name;
- /// Whether the symbol is a property (either this or [isMethod] is true).
- bool get isProperty => !isMethod;
+ /// Kind of declaration (field, property, or method).
+ final DeclarationKind _kind;
+
+ /// Whether the symbol is a field.
+ bool get isField => _kind == FIELD;
- /// Whether the symbol is a method (either this or [isProperty] is true)
- final bool isMethod;
+ /// Whether the symbol is a getter/setter and not a field.
Siggi Cherem (dart-lang) 2014/02/21 18:02:58 I was thinking more about it this morning, and I'm
Jennifer Messerly 2014/02/21 23:29:11 Tricky. What you have right now is fairly consiste
Siggi Cherem (dart-lang) 2014/02/22 01:13:28 ok, thanks - I went with keeping them separate and
+ bool get isProperty => _kind == PROPERTY;
+
+ /// Whether the symbol is a method.
+ bool get isMethod => _kind == METHOD;
/// If this is a property, whether it's read only (final fields or properties
/// with no setter).
@@ -134,8 +147,9 @@ class Declaration {
/// List of annotations in this declaration.
final List annotations;
- const Declaration(this.name, this.type, {this.isMethod:false,
- this.isFinal: false, this.isStatic: false, this.annotations: const []});
+ const Declaration(this.name, this.type, {DeclarationKind kind: FIELD,
+ this.isFinal: false, this.isStatic: false, this.annotations: const []})
+ : _kind = kind;
String toString() {
return (new StringBuffer()
@@ -149,6 +163,21 @@ class Declaration {
}
}
+/// Enumeration for declaration kinds (field, property, or method)
+class DeclarationKind {
Jennifer Messerly 2014/02/21 23:29:11 if _kind is private, then DeclarationKind should b
Siggi Cherem (dart-lang) 2014/02/22 01:13:28 yeah, I was ambivalent about it. I decided to expo
+ final int kind;
+ const DeclarationKind(this.kind);
+}
+
+/// Declaration kind used to denote a raw field.
+const FIELD = const DeclarationKind(0);
+
+/// Declaration kind used to denote a getter/setter.
+const PROPERTY = const DeclarationKind(1);
+
+/// Declaration kind used to denote a method.
+const METHOD = const DeclarationKind(2);
+
/// A service that provides a way to implement simple operations on objects like
/// read, write, and invoke.
« no previous file with comments | « pkg/smoke/lib/mirrors.dart ('k') | pkg/smoke/lib/static.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698