OLD | NEW |
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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 func.load(); | 328 func.load(); |
329 } | 329 } |
330 }); | 330 }); |
331 } | 331 } |
332 }); | 332 }); |
333 } | 333 } |
334 | 334 |
335 void computeAnnotations() { | 335 void computeAnnotations() { |
336 _startLine = (startPos != null | 336 _startLine = (startPos != null |
337 ? script.tokenToLine(startPos) | 337 ? script.tokenToLine(startPos) |
338 : 1); | 338 : 1 + script.lineOffset); |
339 _currentLine = (currentPos != null | 339 _currentLine = (currentPos != null |
340 ? script.tokenToLine(currentPos) | 340 ? script.tokenToLine(currentPos) |
341 : null); | 341 : null); |
342 _currentCol = (currentPos != null | 342 _currentCol = (currentPos != null |
343 ? (script.tokenToCol(currentPos) - 1) // make this 0-based. | 343 ? (script.tokenToCol(currentPos) - 1) // make this 0-based. |
344 : null); | 344 : null); |
345 _endLine = (endPos != null | 345 _endLine = (endPos != null |
346 ? script.tokenToLine(endPos) | 346 ? script.tokenToLine(endPos) |
347 : script.lines.length); | 347 : script.lines.length + script.lineOffset); |
348 | 348 |
349 annotations.clear(); | 349 annotations.clear(); |
350 if (_currentLine != null) { | 350 if (_currentLine != null) { |
351 var a = new CurrentExecutionAnnotation(); | 351 var a = new CurrentExecutionAnnotation(); |
352 a.line = _currentLine; | 352 a.line = _currentLine; |
353 a.columnStart = _currentCol; | 353 a.columnStart = _currentCol; |
354 a.columnStop = _currentCol + 1; | 354 a.columnStop = _currentCol + 1; |
355 annotations.add(a); | 355 annotations.add(a); |
356 } | 356 } |
357 | 357 |
(...skipping 21 matching lines...) Expand all Loading... |
379 annotations.sort(); | 379 annotations.sort(); |
380 } | 380 } |
381 | 381 |
382 Element linesTable() { | 382 Element linesTable() { |
383 var table = new DivElement(); | 383 var table = new DivElement(); |
384 table.classes.add("sourceTable"); | 384 table.classes.add("sourceTable"); |
385 | 385 |
386 annotationsCursor = 0; | 386 annotationsCursor = 0; |
387 | 387 |
388 int blankLineCount = 0; | 388 int blankLineCount = 0; |
389 for (int i = (_startLine - 1); i <= (_endLine - 1); i++) { | 389 for (int i = _startLine; i <= _endLine; i++) { |
390 if (script.lines[i].isBlank) { | 390 var line = script.getLine(i); |
| 391 if (line.isBlank) { |
391 // Try to introduce elipses if there are 4 or more contiguous | 392 // Try to introduce elipses if there are 4 or more contiguous |
392 // blank lines. | 393 // blank lines. |
393 blankLineCount++; | 394 blankLineCount++; |
394 } else { | 395 } else { |
395 if (blankLineCount > 0) { | 396 if (blankLineCount > 0) { |
396 int firstBlank = i - blankLineCount; | 397 int firstBlank = i - blankLineCount; |
397 int lastBlank = i - 1; | 398 int lastBlank = i - 1; |
398 if (blankLineCount < 4) { | 399 if (blankLineCount < 4) { |
399 // Too few blank lines for an elipsis. | 400 // Too few blank lines for an elipsis. |
400 for (int j = firstBlank; j <= lastBlank; j++) { | 401 for (int j = firstBlank; j <= lastBlank; j++) { |
401 table.append(lineElement(script.lines[j])); | 402 table.append(lineElement(script.getLine(j))); |
402 } | 403 } |
403 } else { | 404 } else { |
404 // Add an elipsis for the skipped region. | 405 // Add an elipsis for the skipped region. |
405 table.append(lineElement(script.lines[firstBlank])); | 406 table.append(lineElement(script.getLine(firstBlank))); |
406 table.append(lineElement(null)); | 407 table.append(lineElement(null)); |
407 table.append(lineElement(script.lines[lastBlank])); | 408 table.append(lineElement(script.getLine(lastBlank))); |
408 } | 409 } |
409 blankLineCount = 0; | 410 blankLineCount = 0; |
410 } | 411 } |
411 table.append(lineElement(script.lines[i])); | 412 table.append(lineElement(line)); |
412 } | 413 } |
413 } | 414 } |
414 | 415 |
415 return table; | 416 return table; |
416 } | 417 } |
417 | 418 |
418 // Assumes annotations are sorted. | 419 // Assumes annotations are sorted. |
419 Annotation nextAnnotationOnLine(int line) { | 420 Annotation nextAnnotationOnLine(int line) { |
420 if (annotationsCursor >= annotations.length) return null; | 421 if (annotationsCursor >= annotations.length) return null; |
421 var annotation = annotations[annotationsCursor]; | 422 var annotation = annotations[annotationsCursor]; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 annotation.applyStyleTo(consumeUntil(annotation.columnStop)); | 551 annotation.applyStyleTo(consumeUntil(annotation.columnStop)); |
551 } | 552 } |
552 consumeUntil(line.text.length); | 553 consumeUntil(line.text.length); |
553 } | 554 } |
554 | 555 |
555 return e; | 556 return e; |
556 } | 557 } |
557 | 558 |
558 ScriptInsetElement.created() : super.created(); | 559 ScriptInsetElement.created() : super.created(); |
559 } | 560 } |
OLD | NEW |