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

Unified Diff: runtime/observatory/lib/src/service/object.dart

Issue 2419013004: Add local variable declaration token position to service protocol (Closed)
Patch Set: test closure variables Created 4 years, 2 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: runtime/observatory/lib/src/service/object.dart
diff --git a/runtime/observatory/lib/src/service/object.dart b/runtime/observatory/lib/src/service/object.dart
index 32df1b24a256163f6541d7c1700249b64fb432b9..007a825d302ce2029d1134f8133565f9f84e13f3 100644
--- a/runtime/observatory/lib/src/service/object.dart
+++ b/runtime/observatory/lib/src/service/object.dart
@@ -3327,7 +3327,7 @@ class Script extends HeapObject implements M.Script {
static bool _isIdentifierChar(int c) {
if (_isInitialIdentifierChar(c)) return true;
- return c >= 48 && c <= 75; // Digit
+ return c >= 48 && c <= 57; // Digit
}
void _update(Map map, bool mapIsRef) {
@@ -3408,6 +3408,28 @@ class Script extends HeapObject implements M.Script {
}
}
+ // Note, this may return source beyond the token length if [guessTokenLength]
+ // fails.
+ String getToken(int tokenPos) {
+ final int line = tokenToLine(tokenPos);
+ int column = tokenToCol(tokenPos);
+ if ((line == null) || (column == null)) {
+ return null;
+ }
+ // Line and column numbers are
rmacnak 2016/10/14 23:10:38 ...are 1-origin in the VM.
Cutch 2016/10/17 18:17:27 Done.
+ column -= 1;
+ String sourceLine = getLine(line).text;
+ if (sourceLine == null) {
+ return null;
+ }
+ final int length = guessTokenLength(line, column);
+ if (length == null) {
+ return sourceLine.substring(column);
+ } else {
+ return sourceLine.substring(column, column + length);
+ }
+ }
+
void _addBreakpoint(Breakpoint bpt) {
var line;
if (bpt.location.tokenPos != null) {
@@ -3610,13 +3632,20 @@ class LocalVarDescriptor implements M.LocalVarDescriptorsRef {
final String id;
final String name;
final int index;
+ final int declarationPos;
final int beginPos;
final int endPos;
final int scopeId;
final String kind;
- LocalVarDescriptor(this.id, this.name, this.index, this.beginPos, this.endPos,
- this.scopeId, this.kind);
+ LocalVarDescriptor(this.id,
+ this.name,
+ this.index,
+ this.declarationPos,
+ this.beginPos,
+ this.endPos,
+ this.scopeId,
+ this.kind);
}
class LocalVarDescriptors extends ServiceObject {
@@ -3638,12 +3667,13 @@ class LocalVarDescriptors extends ServiceObject {
var id = descriptor['name'];
var name = descriptor['name'];
var index = descriptor['index'];
- var beginPos = descriptor['beginPos'];
- var endPos = descriptor['endPos'];
+ var declarationPos = descriptor['declarationTokenPos'];
+ var beginPos = descriptor['visibleStartTokenPos'];
rmacnak 2016/10/14 23:10:38 Consider scopeStart/EndTokenPos
Cutch 2016/10/17 18:17:27 Done.
+ var endPos = descriptor['visibleEndTokenPos'];
var scopeId = descriptor['scopeId'];
var kind = descriptor['kind'].trim();
descriptors.add(new LocalVarDescriptor(
- id, name, index, beginPos, endPos, scopeId, kind));
+ id, name, index, declarationPos, beginPos, endPos, scopeId, kind));
}
}
}

Powered by Google App Engine
This is Rietveld 408576698