Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index d736ad7ab3a8567f345b4fd71b7e4779c389b9c5..d83e40d5d8664cf8b84c0b10c3e5e3b59e459d17 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -3252,6 +3252,32 @@ void Class::set_token_pos(intptr_t token_pos) const { |
} |
+intptr_t Class::ComputeEndTokenPos() const { |
+ // Return the begin token for synthetic classes. |
+ if (IsSignatureClass() || IsMixinApplication() || IsTopLevel()) { |
+ return token_pos(); |
+ } |
+ const Script& scr = Script::Handle(script()); |
+ ASSERT(!scr.IsNull()); |
+ const TokenStream& tkns = TokenStream::Handle(scr.tokens()); |
+ TokenStream::Iterator tkit( |
+ tkns, token_pos(), TokenStream::Iterator::kNoNewlines); |
+ intptr_t level = 0; |
+ while (tkit.CurrentTokenKind() != Token::kEOS) { |
+ if (tkit.CurrentTokenKind() == Token::kLBRACE) { |
+ level++; |
+ } else if (tkit.CurrentTokenKind() == Token::kRBRACE) { |
+ if (--level == 0) { |
+ return tkit.CurrentPosition(); |
+ } |
+ } |
+ tkit.Advance(); |
+ } |
+ UNREACHABLE(); |
+ return 0; |
+} |
+ |
+ |
void Class::set_is_implemented() const { |
set_state_bits(ImplementedBit::update(true, raw_ptr()->state_bits_)); |
} |
@@ -4008,6 +4034,7 @@ void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { |
if (!script.IsNull()) { |
jsobj.AddProperty("script", script); |
jsobj.AddProperty("tokenPos", token_pos()); |
+ jsobj.AddProperty("endTokenPos", ComputeEndTokenPos()); |
} |
{ |
JSONArray interfaces_array(&jsobj, "interfaces"); |