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

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

Issue 1402193003: Pad line number appropriately when generating script insets. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 } 817 }
818 818
819 Element linesTable() { 819 Element linesTable() {
820 var table = new DivElement(); 820 var table = new DivElement();
821 table.classes.add("sourceTable"); 821 table.classes.add("sourceTable");
822 822
823 if (_startLine == null || _endLine == null) { 823 if (_startLine == null || _endLine == null) {
824 return table; 824 return table;
825 } 825 }
826 826
827 var endLine = (endPos != null
828 ? script.tokenToLine(endPos)
829 : script.lines.length + script.lineOffset);
830 var lineNumPad = endLine.toString().length;
831
827 annotationsCursor = 0; 832 annotationsCursor = 0;
828 833
829 int blankLineCount = 0; 834 int blankLineCount = 0;
830 for (int i = _startLine; i <= _endLine; i++) { 835 for (int i = _startLine; i <= _endLine; i++) {
831 var line = script.getLine(i); 836 var line = script.getLine(i);
832 if (line.isBlank) { 837 if (line.isBlank) {
833 // Try to introduce elipses if there are 4 or more contiguous 838 // Try to introduce elipses if there are 4 or more contiguous
834 // blank lines. 839 // blank lines.
835 blankLineCount++; 840 blankLineCount++;
836 } else { 841 } else {
837 if (blankLineCount > 0) { 842 if (blankLineCount > 0) {
838 int firstBlank = i - blankLineCount; 843 int firstBlank = i - blankLineCount;
839 int lastBlank = i - 1; 844 int lastBlank = i - 1;
840 if (blankLineCount < 4) { 845 if (blankLineCount < 4) {
841 // Too few blank lines for an elipsis. 846 // Too few blank lines for an elipsis.
842 for (int j = firstBlank; j <= lastBlank; j++) { 847 for (int j = firstBlank; j <= lastBlank; j++) {
843 table.append(lineElement(script.getLine(j))); 848 table.append(lineElement(script.getLine(j), lineNumPad));
844 } 849 }
845 } else { 850 } else {
846 // Add an elipsis for the skipped region. 851 // Add an elipsis for the skipped region.
847 table.append(lineElement(script.getLine(firstBlank))); 852 table.append(lineElement(script.getLine(firstBlank), lineNumPad));
848 table.append(lineElement(null)); 853 table.append(lineElement(null, lineNumPad));
849 table.append(lineElement(script.getLine(lastBlank))); 854 table.append(lineElement(script.getLine(lastBlank), lineNumPad));
850 } 855 }
851 blankLineCount = 0; 856 blankLineCount = 0;
852 } 857 }
853 table.append(lineElement(line)); 858 table.append(lineElement(line, lineNumPad));
854 } 859 }
855 } 860 }
856 861
857 return table; 862 return table;
858 } 863 }
859 864
860 // Assumes annotations are sorted. 865 // Assumes annotations are sorted.
861 Annotation nextAnnotationOnLine(int line) { 866 Annotation nextAnnotationOnLine(int line) {
862 if (annotationsCursor >= annotations.length) return null; 867 if (annotationsCursor >= annotations.length) return null;
863 var annotation = annotations[annotationsCursor]; 868 var annotation = annotations[annotationsCursor];
864 869
865 // Fast-forward past any annotations before the first line that 870 // Fast-forward past any annotations before the first line that
866 // we are displaying. 871 // we are displaying.
867 while (annotation.line < line) { 872 while (annotation.line < line) {
868 annotationsCursor++; 873 annotationsCursor++;
869 if (annotationsCursor >= annotations.length) return null; 874 if (annotationsCursor >= annotations.length) return null;
870 annotation = annotations[annotationsCursor]; 875 annotation = annotations[annotationsCursor];
871 } 876 }
872 877
873 // Next annotation is for a later line, don't advance past it. 878 // Next annotation is for a later line, don't advance past it.
874 if (annotation.line != line) return null; 879 if (annotation.line != line) return null;
875 annotationsCursor++; 880 annotationsCursor++;
876 return annotation; 881 return annotation;
877 } 882 }
878 883
879 Element lineElement(ScriptLine line) { 884 Element lineElement(ScriptLine line, int lineNumPad) {
880 var e = new DivElement(); 885 var e = new DivElement();
881 e.classes.add("sourceRow"); 886 e.classes.add("sourceRow");
882 e.append(lineBreakpointElement(line)); 887 e.append(lineBreakpointElement(line));
883 e.append(lineNumberElement(line)); 888 e.append(lineNumberElement(line, lineNumPad));
884 e.append(lineSourceElement(line)); 889 e.append(lineSourceElement(line));
885 return e; 890 return e;
886 } 891 }
887 892
888 Element lineBreakpointElement(ScriptLine line) { 893 Element lineBreakpointElement(ScriptLine line) {
889 var e = new DivElement(); 894 var e = new DivElement();
890 var busy = false; 895 var busy = false;
891 if (line == null || !line.possibleBpt) { 896 if (line == null || !line.possibleBpt) {
892 e.classes.add("emptyBreakpoint"); 897 e.classes.add("emptyBreakpoint");
893 e.classes.add('noCopy'); 898 e.classes.add('noCopy');
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 busy = false; 950 busy = false;
946 update(); 951 update();
947 }); 952 });
948 } 953 }
949 update(); 954 update();
950 }); 955 });
951 update(); 956 update();
952 return e; 957 return e;
953 } 958 }
954 959
955 Element lineNumberElement(ScriptLine line) { 960 Element lineNumberElement(ScriptLine line, int lineNumPad) {
956 var lineNumber = line == null ? "..." : line.line; 961 var lineNumber = line == null ? "..." : line.line;
957 var e = span("$nbsp$lineNumber$nbsp"); 962 var e = span("$nbsp${lineNumber.toString().padLeft(lineNumPad,nbsp)}$nbsp");
Cutch 2015/10/14 19:12:41 if (lineNumPad == null) { lineNumPad = 0; }
turnidge 2015/10/14 19:23:13 Resolved offline.
958 e.classes.add('noCopy'); 963 e.classes.add('noCopy');
959 964
960 if (lineNumber == _currentLine) { 965 if (lineNumber == _currentLine) {
961 hitsCurrent(e); 966 hitsCurrent(e);
962 } else if ((line == null) || (line.hits == null)) { 967 } else if ((line == null) || (line.hits == null)) {
963 hitsUnknown(e); 968 hitsUnknown(e);
964 } else if (line.hits == 0) { 969 } else if (line.hits == 0) {
965 hitsNotExecuted(e); 970 hitsNotExecuted(e);
966 } else { 971 } else {
967 hitsExecuted(e); 972 hitsExecuted(e);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 @CustomTag('source-inset') 1027 @CustomTag('source-inset')
1023 class SourceInsetElement extends PolymerElement { 1028 class SourceInsetElement extends PolymerElement {
1024 SourceInsetElement.created() : super.created(); 1029 SourceInsetElement.created() : super.created();
1025 1030
1026 @published SourceLocation location; 1031 @published SourceLocation location;
1027 @published String height = null; 1032 @published String height = null;
1028 @published int currentPos; 1033 @published int currentPos;
1029 @published bool inDebuggerContext = false; 1034 @published bool inDebuggerContext = false;
1030 @published ObservableList variables; 1035 @published ObservableList variables;
1031 } 1036 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698