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

Unified Diff: runtime/vm/debugger_api_impl.cc

Issue 23526056: Make Dart_ScriptGetTokenInfo account for line_offset() and col_offset() (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comment Created 7 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
« no previous file with comments | « runtime/include/dart_debugger_api.h ('k') | tools/coverage.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/debugger_api_impl.cc
diff --git a/runtime/vm/debugger_api_impl.cc b/runtime/vm/debugger_api_impl.cc
index 09e24c011dc8a8f9ab9d73cbe0c8d499366bdc30..65eedb662e82f845398c9f7b57d6849eef1865a1 100644
--- a/runtime/vm/debugger_api_impl.cc
+++ b/runtime/vm/debugger_api_impl.cc
@@ -690,6 +690,7 @@ DART_EXPORT Dart_Handle Dart_ScriptGetTokenInfo(
const String& key = Symbols::Empty();
const Object& line_separator = Object::Handle();
const TokenStream& tkns = TokenStream::Handle(script.tokens());
+ int line_offset = script.line_offset();
ASSERT(!tkns.IsNull());
TokenStream::Iterator tkit(tkns, 0);
int current_line = -1;
@@ -702,14 +703,19 @@ DART_EXPORT Dart_Handle Dart_ScriptGetTokenInfo(
if (token_line != current_line) {
// emit line
info.Add(line_separator);
- info.Add(Smi::Handle(Smi::New(token_line)));
+ info.Add(Smi::Handle(Smi::New(token_line + line_offset)));
current_line = token_line;
}
// TODO(hausner): Could optimize here by not reporting tokens
// that will never be a location used by the debugger, e.g.
// braces, semicolons, most keywords etc.
info.Add(Smi::Handle(Smi::New(tkit.CurrentPosition())));
- info.Add(Smi::Handle(Smi::New(s.current_token().offset)));
+ int column = s.current_token().position.column;
+ // On the first line of the script we must add the column offset.
+ if (token_line == 1) {
+ column += script.col_offset();
+ }
+ info.Add(Smi::Handle(Smi::New(column)));
s.Scan();
tkit.Advance();
}
« no previous file with comments | « runtime/include/dart_debugger_api.h ('k') | tools/coverage.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698