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

Side by Side Diff: pkg/dartdoc/lib/src/markdown/inline_parser.dart

Issue 11273041: Make first and last getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /// Maintains the internal state needed to parse inline span elements in 5 /// Maintains the internal state needed to parse inline span elements in
6 /// markdown. 6 /// markdown.
7 class InlineParser { 7 class InlineParser {
8 static List<InlineSyntax> get syntaxes { 8 static List<InlineSyntax> get syntaxes {
9 // Lazy initialize. 9 // Lazy initialize.
10 if (_syntaxes == null) { 10 if (_syntaxes == null) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 109
110 writeText() { 110 writeText() {
111 writeTextRange(start, pos); 111 writeTextRange(start, pos);
112 start = pos; 112 start = pos;
113 } 113 }
114 114
115 writeTextRange(int start, int end) { 115 writeTextRange(int start, int end) {
116 if (end > start) { 116 if (end > start) {
117 final text = source.substring(start, end); 117 final text = source.substring(start, end);
118 final nodes = _stack.last().children; 118 final nodes = _stack.last.children;
119 119
120 // If the previous node is text too, just append. 120 // If the previous node is text too, just append.
121 if ((nodes.length > 0) && (nodes.last() is Text)) { 121 if ((nodes.length > 0) && (nodes.last is Text)) {
122 final newNode = new Text('${nodes.last().text}$text'); 122 final newNode = new Text('${nodes.last.text}$text');
123 nodes[nodes.length - 1] = newNode; 123 nodes[nodes.length - 1] = newNode;
124 } else { 124 } else {
125 nodes.add(new Text(text)); 125 nodes.add(new Text(text));
126 } 126 }
127 } 127 }
128 } 128 }
129 129
130 addNode(Node node) { 130 addNode(Node node) {
131 _stack.last().children.add(node); 131 _stack.last.children.add(node);
132 } 132 }
133 133
134 // TODO(rnystrom): Only need this because RegExp doesn't let you start 134 // TODO(rnystrom): Only need this because RegExp doesn't let you start
135 // searching from a given offset. 135 // searching from a given offset.
136 String get currentSource => source.substring(pos, source.length); 136 String get currentSource => source.substring(pos, source.length);
137 137
138 bool get isDone => pos == source.length; 138 bool get isDone => pos == source.length;
139 139
140 void advanceBy(int length) { 140 void advanceBy(int length) {
141 pos += length; 141 pos += length;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 parser.consume(endMatch[0].length); 399 parser.consume(endMatch[0].length);
400 } else { 400 } else {
401 // Didn't close correctly so revert to text. 401 // Didn't close correctly so revert to text.
402 parser.start = startPos; 402 parser.start = startPos;
403 parser.advanceBy(endMatch[0].length); 403 parser.advanceBy(endMatch[0].length);
404 } 404 }
405 405
406 return null; 406 return null;
407 } 407 }
408 } 408 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698