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

Side by Side Diff: runtime/observatory/lib/src/elements/script_inset.dart

Issue 1150303004: Switch to using SourceLocation universally in service protocol. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: post merge Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library script_inset_element; 5 library script_inset_element;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'observatory_element.dart'; 9 import 'observatory_element.dart';
10 import 'service_ref.dart'; 10 import 'service_ref.dart';
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 } 156 }
157 return details; 157 return details;
158 }); 158 });
159 } 159 }
160 } 160 }
161 161
162 abstract class DeclarationAnnotation extends Annotation { 162 abstract class DeclarationAnnotation extends Annotation {
163 DeclarationAnnotation(decl) { 163 DeclarationAnnotation(decl) {
164 assert(decl.loaded); 164 assert(decl.loaded);
165 var script = decl.script; 165 SourceLocation location = decl.location;
166 line = script.tokenToLine(decl.tokenPos); 166 if (location == null) {
167 columnStart = script.tokenToCol(decl.tokenPos); 167 line = 0;
168 columnStart = 0;
169 columnStop = 0;
170 return;
171 }
172 Script script = location.script;
173 line = script.tokenToLine(location.tokenPos);
174 columnStart = script.tokenToCol(location.tokenPos);
168 if ((line == null) || (columnStart == null)) { 175 if ((line == null) || (columnStart == null)) {
169 line = 0; 176 line = 0;
170 columnStart = 0; 177 columnStart = 0;
171 columnStop = 0; 178 columnStop = 0;
172 } else { 179 } else {
173 columnStart--; // 1-origin -> 0-origin. 180 columnStart--; // 1-origin -> 0-origin.
174 181
175 // The method's token position is at the beginning of the method 182 // The method's token position is at the beginning of the method
176 // declaration, which may be a return type annotation, metadata, static 183 // declaration, which may be a return type annotation, metadata, static
177 // modifier, etc. Try to scan forward to position this annotation on the 184 // modifier, etc. Try to scan forward to position this annotation on the
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 309 }
303 return details; 310 return details;
304 }); 311 });
305 } 312 }
306 } 313 }
307 314
308 /// Box with script source code in it. 315 /// Box with script source code in it.
309 @CustomTag('script-inset') 316 @CustomTag('script-inset')
310 class ScriptInsetElement extends ObservatoryElement { 317 class ScriptInsetElement extends ObservatoryElement {
311 @published Script script; 318 @published Script script;
319 @published int startPos;
320 @published int endPos;
312 321
313 /// Set the height to make the script inset scroll. Otherwise it 322 /// Set the height to make the script inset scroll. Otherwise it
314 /// will show from startPos to endPos. 323 /// will show from startPos to endPos.
315 @published String height = null; 324 @published String height = null;
316 325
317 @published int currentPos; 326 @published int currentPos;
318 @published int startPos;
319 @published int endPos;
320 @published bool inDebuggerContext = false; 327 @published bool inDebuggerContext = false;
321 @published ObservableList variables; 328 @published ObservableList variables;
322 329
323 int _currentLine; 330 int _currentLine;
324 int _currentCol; 331 int _currentCol;
325 int _startLine; 332 int _startLine;
326 int _endLine; 333 int _endLine;
327 334
328 var annotations = []; 335 var annotations = [];
329 var annotationsCursor; 336 var annotationsCursor;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 for (var field in cls.fields) { 491 for (var field in cls.fields) {
485 field.load(); 492 field.load();
486 } 493 }
487 }); 494 });
488 } 495 }
489 }); 496 });
490 } 497 }
491 498
492 void addClassAnnotations() { 499 void addClassAnnotations() {
493 for (var cls in script.library.classes) { 500 for (var cls in script.library.classes) {
494 if (cls.script == script) { 501 if ((cls.location != null) && (cls.location.script == script)) {
495 annotations.add(new ClassDeclarationAnnotation(cls)); 502 annotations.add(new ClassDeclarationAnnotation(cls));
496 } 503 }
497 } 504 }
498 } 505 }
499 506
500 void addFieldAnnotations() { 507 void addFieldAnnotations() {
501 for (var field in script.library.variables) { 508 for (var field in script.library.variables) {
502 if (field.script == script) { 509 if ((field.location != null) && (field.location.script == script)) {
503 annotations.add(new FieldDeclarationAnnotation(field)); 510 annotations.add(new FieldDeclarationAnnotation(field));
504 } 511 }
505 } 512 }
506 for (var cls in script.library.classes) { 513 for (var cls in script.library.classes) {
507 for (var field in cls.fields) { 514 for (var field in cls.fields) {
508 if (field.script == script) { 515 if ((field.location != null) && (field.location.script == script)) {
509 annotations.add(new FieldDeclarationAnnotation(field)); 516 annotations.add(new FieldDeclarationAnnotation(field));
510 } 517 }
511 } 518 }
512 } 519 }
513 } 520 }
514 521
515 void addFunctionAnnotations() { 522 void addFunctionAnnotations() {
516 for (var func in script.library.functions) { 523 for (var func in script.library.functions) {
517 if (func.script == script) { 524 if ((func.location != null) && (func.location.script == script)) {
518 annotations.add(new FunctionDeclarationAnnotation(func)); 525 annotations.add(new FunctionDeclarationAnnotation(func));
519 } 526 }
520 } 527 }
521 for (var cls in script.library.classes) { 528 for (var cls in script.library.classes) {
522 for (var func in cls.functions) { 529 for (var func in cls.functions) {
523 if (func.script == script) { 530 if ((func.location != null) && (func.location.script == script)) {
524 annotations.add(new FunctionDeclarationAnnotation(func)); 531 annotations.add(new FunctionDeclarationAnnotation(func));
525 } 532 }
526 } 533 }
527 } 534 }
528 } 535 }
529 536
530 void addCallSiteAnnotations() { 537 void addCallSiteAnnotations() {
531 for (var callSite in script.callSites) { 538 for (var callSite in script.callSites) {
532 annotations.add(new CallSiteAnnotation(callSite)); 539 annotations.add(new CallSiteAnnotation(callSite));
533 } 540 }
534 } 541 }
535 542
536 void addLocalVariableAnnotations() { 543 void addLocalVariableAnnotations() {
537 // We have local variable information. 544 // We have local variable information.
538 if (variables != null) { 545 if (variables != null) {
539 // For each variable. 546 // For each variable.
540 for (var variable in variables) { 547 for (var variable in variables) {
541 // Find variable usage locations. 548 // Find variable usage locations.
542 var locations = script.scanForLocalVariableLocations( 549 var locations = script.scanForLocalVariableLocations(
543 variable['name'], variable['tokenPos'], variable['endTokenPos']); 550 variable['name'],
551 variable['_tokenPos'],
552 variable['_endTokenPos']);
544 553
545 // Annotate locations. 554 // Annotate locations.
546 for (var location in locations) { 555 for (var location in locations) {
547 annotations.add(new LocalVariableAnnotation(location, 556 annotations.add(new LocalVariableAnnotation(location,
548 variable['value'])); 557 variable['value']));
549 } 558 }
550 } 559 }
551 } 560 }
552 } 561 }
553 562
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 e.append(span('\n')); 749 e.append(span('\n'));
741 750
742 return e; 751 return e;
743 } 752 }
744 753
745 ScriptInsetElement.created() 754 ScriptInsetElement.created()
746 : super.created() { 755 : super.created() {
747 _updateTask = new Task(update); 756 _updateTask = new Task(update);
748 } 757 }
749 } 758 }
759
760 @CustomTag('source-inset')
761 class SourceInsetElement extends PolymerElement {
762 SourceInsetElement.created() : super.created();
763
764 @published SourceLocation location;
765 @published String height = null;
766 @published int currentPos;
767 @published bool inDebuggerContext = false;
768 @published ObservableList variables;
769 }
770
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/observatory_element.dart ('k') | runtime/observatory/lib/src/elements/script_inset.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698