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

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

Issue 1079163009: Fix script-view. Hide annotations except the current position when debugging. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 class ScriptInsetElement extends ObservatoryElement { 211 class ScriptInsetElement extends ObservatoryElement {
212 @published Script script; 212 @published Script script;
213 213
214 /// Set the height to make the script inset scroll. Otherwise it 214 /// Set the height to make the script inset scroll. Otherwise it
215 /// will show from startPos to endPos. 215 /// will show from startPos to endPos.
216 @published String height = null; 216 @published String height = null;
217 217
218 @published int currentPos; 218 @published int currentPos;
219 @published int startPos; 219 @published int startPos;
220 @published int endPos; 220 @published int endPos;
221 @published bool inDebuggerContext = false;
221 222
222 @observable int currentLine; 223 int _currentLine;
223 @observable int currentCol; 224 int _currentCol;
224 @observable int startLine; 225 int _startLine;
225 @observable int endLine; 226 int _endLine;
226 227
227 var annotations = []; 228 var annotations = [];
228 var annotationsCursor; 229 var annotationsCursor;
229 230
230 StreamSubscription scriptChangeSubscription; 231 StreamSubscription scriptChangeSubscription;
231 232
232 String makeLineId(int line) { 233 String makeLineId(int line) {
233 return 'line-$line'; 234 return 'line-$line';
234 } 235 }
235 236
236 void _scrollToCurrentPos() { 237 void _scrollToCurrentPos() {
237 var line = querySelector('#${makeLineId(currentLine)}'); 238 var line = querySelector('#${makeLineId(_currentLine)}');
238 if (line != null) { 239 if (line != null) {
239 line.scrollIntoView(); 240 line.scrollIntoView();
240 } 241 }
241 } 242 }
242 243
243 void detached() { 244 void detached() {
244 if (scriptChangeSubscription != null) { 245 if (scriptChangeSubscription != null) {
245 // Don't leak. If only Dart and Javascript exposed weak references... 246 // Don't leak. If only Dart and Javascript exposed weak references...
246 scriptChangeSubscription.cancel(); 247 scriptChangeSubscription.cancel();
247 scriptChangeSubscription = null; 248 scriptChangeSubscription = null;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 cls.load().then((cls) { 326 cls.load().then((cls) {
326 for (var func in cls.functions) { 327 for (var func in cls.functions) {
327 func.load(); 328 func.load();
328 } 329 }
329 }); 330 });
330 } 331 }
331 }); 332 });
332 } 333 }
333 334
334 void computeAnnotations() { 335 void computeAnnotations() {
335 startLine = (startPos != null 336 _startLine = (startPos != null
336 ? script.tokenToLine(startPos) 337 ? script.tokenToLine(startPos)
337 : 1); 338 : 1);
338 currentLine = (currentPos != null 339 _currentLine = (currentPos != null
339 ? script.tokenToLine(currentPos) 340 ? script.tokenToLine(currentPos)
341 : null);
342 _currentCol = (currentPos != null
343 ? (script.tokenToCol(currentPos) - 1) // make this 0-based.
340 : null); 344 : null);
341 currentCol = (currentPos != null 345 _endLine = (endPos != null
342 ? (script.tokenToCol(currentPos) - 1) // make this 0-based. 346 ? script.tokenToLine(endPos)
343 : null); 347 : script.lines.length);
344 endLine = (endPos != null
345 ? script.tokenToLine(endPos)
346 : script.lines.length);
347 348
348 annotations.clear(); 349 annotations.clear();
349 if (currentLine != null) { 350 if (_currentLine != null) {
350 var a = new CurrentExecutionAnnotation(); 351 var a = new CurrentExecutionAnnotation();
351 a.line = currentLine; 352 a.line = _currentLine;
352 a.columnStart = currentCol; 353 a.columnStart = _currentCol;
353 a.columnStop = currentCol + 1; 354 a.columnStop = _currentCol + 1;
354 annotations.add(a); 355 annotations.add(a);
355 } 356 }
356 357
357 loadFunctionsOf(script.library); 358 if (!inDebuggerContext) {
359 loadFunctionsOf(script.library);
358 360
359 for (var func in script.library.functions) { 361 for (var func in script.library.functions) {
360 if (func.script == script) {
361 annotations.add(new FunctionDeclarationAnnotation(func));
362 }
363 }
364 for (var cls in script.library.classes) {
365 for (var func in cls.functions) {
366 if (func.script == script) { 362 if (func.script == script) {
367 annotations.add(new FunctionDeclarationAnnotation(func)); 363 annotations.add(new FunctionDeclarationAnnotation(func));
368 } 364 }
369 } 365 }
370 } 366 for (var cls in script.library.classes) {
367 for (var func in cls.functions) {
368 if (func.script == script) {
369 annotations.add(new FunctionDeclarationAnnotation(func));
370 }
371 }
372 }
371 373
372 for (var callSite in script.callSites) { 374 for (var callSite in script.callSites) {
373 annotations.add(new CallSiteAnnotation(callSite)); 375 annotations.add(new CallSiteAnnotation(callSite));
376 }
374 } 377 }
375 378
376 annotations.sort(); 379 annotations.sort();
377 } 380 }
378 381
379 Element linesTable() { 382 Element linesTable() {
380 var table = new DivElement(); 383 var table = new DivElement();
381 table.classes.add("sourceTable"); 384 table.classes.add("sourceTable");
382 385
383 annotationsCursor = 0; 386 annotationsCursor = 0;
384 387
385 int blankLineCount = 0; 388 int blankLineCount = 0;
386 for (int i = (startLine - 1); i <= (endLine - 1); i++) { 389 for (int i = (_startLine - 1); i <= (_endLine - 1); i++) {
387 if (script.lines[i].isBlank) { 390 if (script.lines[i].isBlank) {
388 // Try to introduce elipses if there are 4 or more contiguous 391 // Try to introduce elipses if there are 4 or more contiguous
389 // blank lines. 392 // blank lines.
390 blankLineCount++; 393 blankLineCount++;
391 } else { 394 } else {
392 if (blankLineCount > 0) { 395 if (blankLineCount > 0) {
393 int firstBlank = i - blankLineCount; 396 int firstBlank = i - blankLineCount;
394 int lastBlank = i - 1; 397 int lastBlank = i - 1;
395 if (blankLineCount < 4) { 398 if (blankLineCount < 4) {
396 // Too few blank lines for an elipsis. 399 // Too few blank lines for an elipsis.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 } 513 }
511 514
512 return e; 515 return e;
513 } 516 }
514 517
515 Element lineSourceElement(ScriptLine line) { 518 Element lineSourceElement(ScriptLine line) {
516 var e = new DivElement(); 519 var e = new DivElement();
517 e.classes.add("sourceItem"); 520 e.classes.add("sourceItem");
518 521
519 if (line != null) { 522 if (line != null) {
520 if (line.line == currentLine) { 523 if (line.line == _currentLine) {
521 e.classes.add("currentLine"); 524 e.classes.add("currentLine");
522 } 525 }
523 526
524 e.id = makeLineId(line.line); 527 e.id = makeLineId(line.line);
525 528
526 var position = 0; 529 var position = 0;
527 consumeUntil(var stop) { 530 consumeUntil(var stop) {
528 if (stop <= position) { 531 if (stop <= position) {
529 return null; // Empty gap between annotations/boundries. 532 return null; // Empty gap between annotations/boundries.
530 } 533 }
(...skipping 16 matching lines...) Expand all
547 annotation.applyStyleTo(consumeUntil(annotation.columnStop)); 550 annotation.applyStyleTo(consumeUntil(annotation.columnStop));
548 } 551 }
549 consumeUntil(line.text.length); 552 consumeUntil(line.text.length);
550 } 553 }
551 554
552 return e; 555 return e;
553 } 556 }
554 557
555 ScriptInsetElement.created() : super.created(); 558 ScriptInsetElement.created() : super.created();
556 } 559 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/debugger.html ('k') | runtime/observatory/lib/src/elements/script_view.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698