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

Unified Diff: runtime/observatory/lib/src/elements/script_inset.dart

Issue 1133473007: Add annotations for field and class declarations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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
« no previous file with comments | « runtime/observatory/lib/src/elements/field_view.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/lib/src/elements/script_inset.dart
diff --git a/runtime/observatory/lib/src/elements/script_inset.dart b/runtime/observatory/lib/src/elements/script_inset.dart
index 164c134a0b654b689b710d3a2a2736148faec24e..25717d1c299fcf6f367f30b55a7f0000e2e4c4e4 100644
--- a/runtime/observatory/lib/src/elements/script_inset.dart
+++ b/runtime/observatory/lib/src/elements/script_inset.dart
@@ -25,6 +25,8 @@ void addInfoBox(Element content, Function infoBoxGenerator) {
infoBox.style.zIndex = '10';
infoBox.style.backgroundColor = 'white';
infoBox.style.cursor = 'auto';
+ // Don't inherit pre formating from the script lines.
+ infoBox.style.whiteSpace = 'normal';
content.append(infoBox);
}
content.onClick.listen((event) {
@@ -117,7 +119,7 @@ class CallSiteAnnotation extends Annotation {
addInfoBox(element, () {
var details = table();
if (callSite.entries.isEmpty) {
- details.append(row('Did not execute'));
+ details.append(row('Call of "${callSite.name}" did not execute'));
} else {
var r = row();
r.append(cell("Container"));
@@ -138,15 +140,12 @@ class CallSiteAnnotation extends Annotation {
}
}
-
-class FunctionDeclarationAnnotation extends Annotation {
- ServiceFunction function;
-
- FunctionDeclarationAnnotation(this.function) {
- assert(function.loaded);
- var script = function.script;
- line = script.tokenToLine(function.tokenPos);
- columnStart = script.tokenToCol(function.tokenPos);
+class DeclarationAnnotation extends Annotation {
+ DeclarationAnnotation(decl) {
+ assert(decl.loaded);
+ var script = decl.script;
+ line = script.tokenToLine(decl.tokenPos);
+ columnStart = script.tokenToCol(decl.tokenPos);
if ((line == null) || (columnStart == null)) {
line = 0;
columnStart = 0;
@@ -159,20 +158,99 @@ class FunctionDeclarationAnnotation extends Annotation {
// modifier, etc. Try to scan forward to position this annotation on the
// function's name instead.
var lineSource = script.getLine(line).text;
- var betterStart = lineSource.indexOf(function.name, columnStart);
+ var betterStart = lineSource.indexOf(decl.name, columnStart);
if (betterStart != -1) {
columnStart = betterStart;
}
- columnStop = columnStart + function.name.length;
+ columnStop = columnStart + decl.name.length;
+ }
+ }
+}
+
+class ClassDeclarationAnnotation extends DeclarationAnnotation {
+ Class klass;
+
+ ClassDeclarationAnnotation(Class cls) : klass = cls, super(cls);
+
+ void applyStyleTo(element) {
+ if (element == null) {
+ return; // TODO(rmacnak): Handling overlapping annotations.
}
+ element.style.fontWeight = "bold";
+ element.title = "class ${klass.name}";
+
+ addInfoBox(element, () {
+ var details = table();
+ var r = row();
+ r.append(cell("Class"));
+ r.append(cell(serviceRef(klass)));
+ details.append(r);
+
+ return details;
+ });
}
+}
+
+class FieldDeclarationAnnotation extends DeclarationAnnotation {
+ Field field;
+
+ FieldDeclarationAnnotation(Field fld) : field = fld, super(fld);
void applyStyleTo(element) {
if (element == null) {
return; // TODO(rmacnak): Handling overlapping annotations.
}
element.style.fontWeight = "bold";
- element.title = "Function declaration: ${function.name}";
+ element.title = "field ${field.name}";
+
+ addInfoBox(element, () {
+ var details = table();
+ var r = row();
+ r.append(cell("Field"));
+ r.append(cell(serviceRef(field)));
+ details.append(r);
+
+ if (field.isStatic) {
+ r = row();
+ r.append(cell("Value"));
+ r.append(cell(serviceRef(field.value)));
+ details.append(r);
+ } else {
+ r = row();
+ r.append(cell("Nullable"));
+ r.append(cell(field.guardNullable ? "null observed"
+ : "null not observed"));
+ details.append(r);
+
+ r = row();
+ r.append(cell("Types"));
+ if (field.guardClass == "dynamic") {
+ r.append(cell("various"));
+ } else if (field.guardClass == "unknown") {
+ r.append(cell("none"));
+ } else {
+ r.append(cell(serviceRef(field.guardClass)));
+ }
+ details.append(r);
+ }
+
+ return details;
+ });
+ }
+}
+
+class FunctionDeclarationAnnotation extends DeclarationAnnotation {
+ ServiceFunction function;
+
+ FunctionDeclarationAnnotation(ServiceFunction func)
+ : function = func, super(func);
+
+ void applyStyleTo(element) {
+ if (element == null) {
+ return; // TODO(rmacnak): Handling overlapping annotations.
+ }
+ element.style.fontWeight = "bold";
+ element.title = "method ${function.name}";
if (function.isOptimizable == false ||
function.isInlinable == false ||
@@ -318,21 +396,6 @@ class ScriptInsetElement extends ObservatoryElement {
makeCssClassUncopyable(table, "noCopy");
}
- void loadFunctionsOf(Library lib) {
- lib.load().then((lib) {
- for (var func in lib.functions) {
- func.load();
- }
- for (var cls in lib.classes) {
- cls.load().then((cls) {
- for (var func in cls.functions) {
- func.load();
- }
- });
- }
- });
- }
-
void computeAnnotations() {
_startLine = (startPos != null
? script.tokenToLine(startPos)
@@ -348,6 +411,24 @@ class ScriptInsetElement extends ObservatoryElement {
: script.lines.length + script.lineOffset);
annotations.clear();
+
+ addCurrentExecutionAnnotation();
+
+ if (!inDebuggerContext) {
+ loadDeclarationsOfLibrary(script.library);
+
+ // Add fields before functions so they beat out conflicting
+ // implicit g/setters.
+ addClassAnnotations();
+ addFieldAnnotations();
+ addFunctionAnnotations();
+ addCallSiteAnnotations();
+ }
+
+ annotations.sort();
+ }
+
+ void addCurrentExecutionAnnotation() {
if (_currentLine != null) {
var a = new CurrentExecutionAnnotation();
a.line = _currentLine;
@@ -355,29 +436,71 @@ class ScriptInsetElement extends ObservatoryElement {
a.columnStop = _currentCol + 1;
annotations.add(a);
}
+ }
- if (!inDebuggerContext) {
- loadFunctionsOf(script.library);
-
- for (var func in script.library.functions) {
- if (func.script == script) {
- annotations.add(new FunctionDeclarationAnnotation(func));
- }
+ void loadDeclarationsOfLibrary(Library lib) {
+ lib.load().then((lib) {
+ for (var func in lib.functions) {
+ func.load();
}
- for (var cls in script.library.classes) {
- for (var func in cls.functions) {
- if (func.script == script) {
- annotations.add(new FunctionDeclarationAnnotation(func));
+ for (var field in lib.variables) {
+ field.load();
+ }
+ for (var cls in lib.classes) {
+ cls.load().then((cls) {
+ for (var func in cls.functions) {
+ func.load();
+ }
+ for (var field in cls.fields) {
+ field.load();
}
+ });
+ }
+ });
+ }
+
+ void addClassAnnotations() {
+ for (var cls in script.library.classes) {
+ if (cls.script == script) {
+ annotations.add(new ClassDeclarationAnnotation(cls));
+ }
+ }
+ }
+
+ void addFieldAnnotations() {
+ for (var field in script.library.variables) {
+ if (field.script == script) {
+ annotations.add(new FieldDeclarationAnnotation(field));
+ }
+ }
+ for (var cls in script.library.classes) {
+ for (var field in cls.fields) {
+ if (field.script == script) {
+ annotations.add(new FieldDeclarationAnnotation(field));
}
}
+ }
+ }
- for (var callSite in script.callSites) {
- annotations.add(new CallSiteAnnotation(callSite));
+ void addFunctionAnnotations() {
+ for (var func in script.library.functions) {
+ if (func.script == script) {
+ annotations.add(new FunctionDeclarationAnnotation(func));
}
}
+ for (var cls in script.library.classes) {
+ for (var func in cls.functions) {
+ if (func.script == script) {
+ annotations.add(new FunctionDeclarationAnnotation(func));
+ }
+ }
+ }
+ }
- annotations.sort();
+ void addCallSiteAnnotations() {
+ for (var callSite in script.callSites) {
+ annotations.add(new CallSiteAnnotation(callSite));
+ }
}
Element linesTable() {
« no previous file with comments | « runtime/observatory/lib/src/elements/field_view.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698