mirror of
https://github.com/dart-lang/sdk
synced 2024-09-23 18:14:24 +00:00
Rename regexp methods to getters.
Review URL: https://codereview.chromium.org//11266050 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14094 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
2e778387b3
commit
9cc9214b58
|
@ -54,7 +54,7 @@ void parseCommandLine(List<OptionHandler> handlers, List<String> argv) {
|
|||
var pattern = new RegExp('^(${Strings.join(patterns, ")\$|(")})\$');
|
||||
OUTER: for (String argument in argv) {
|
||||
Match match = pattern.firstMatch(argument);
|
||||
assert(match.groupCount() == handlers.length);
|
||||
assert(match.groupCount == handlers.length);
|
||||
for (int i = 0; i < handlers.length; i++) {
|
||||
if (match[i + 1] != null) {
|
||||
handlers[i].handle(argument);
|
||||
|
|
|
@ -132,22 +132,20 @@ patch class JSSyntaxRegExp {
|
|||
class _MatchImplementation implements Match {
|
||||
final String pattern;
|
||||
final String str;
|
||||
final int _start;
|
||||
final int _end;
|
||||
final int start;
|
||||
final int end;
|
||||
final List<String> _groups;
|
||||
|
||||
const _MatchImplementation(
|
||||
String this.pattern,
|
||||
String this.str,
|
||||
int this._start,
|
||||
int this._end,
|
||||
int this.start,
|
||||
int this.end,
|
||||
List<String> this._groups);
|
||||
|
||||
int start() => _start;
|
||||
int end() => _end;
|
||||
String group(int index) => _groups[index];
|
||||
String operator [](int index) => group(index);
|
||||
int groupCount() => _groups.length - 1;
|
||||
int get groupCount => _groups.length - 1;
|
||||
|
||||
List<String> groups(List<int> groups) {
|
||||
List<String> out = [];
|
||||
|
|
|
@ -3,14 +3,13 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
class StringMatch implements Match {
|
||||
const StringMatch(int this._start,
|
||||
const StringMatch(int this.start,
|
||||
String this.str,
|
||||
String this.pattern);
|
||||
|
||||
int start() => _start;
|
||||
int end() => _start + pattern.length;
|
||||
int get end => start + pattern.length;
|
||||
String operator[](int g) => group(g);
|
||||
int groupCount() => 0;
|
||||
int get groupCount => 0;
|
||||
|
||||
String group(int group_) {
|
||||
if (group_ != 0) {
|
||||
|
@ -27,7 +26,7 @@ class StringMatch implements Match {
|
|||
return result;
|
||||
}
|
||||
|
||||
final int _start;
|
||||
final int start;
|
||||
final String str;
|
||||
final String pattern;
|
||||
}
|
||||
|
|
|
@ -28,13 +28,13 @@ abstract class Match {
|
|||
/**
|
||||
* Returns the index in the string where the match starts.
|
||||
*/
|
||||
int start();
|
||||
int get start;
|
||||
|
||||
/**
|
||||
* Returns the index in the string after the last character of the
|
||||
* match.
|
||||
*/
|
||||
int end();
|
||||
int get end;
|
||||
|
||||
/**
|
||||
* Returns the string matched by the given [group]. If [group] is 0,
|
||||
|
@ -52,7 +52,7 @@ abstract class Match {
|
|||
/**
|
||||
* Returns the number of groups in the regular expression.
|
||||
*/
|
||||
int groupCount();
|
||||
int get groupCount;
|
||||
|
||||
/**
|
||||
* The string on which this matcher was computed.
|
||||
|
|
|
@ -481,8 +481,8 @@ abstract class Location {
|
|||
|
||||
/**
|
||||
* Returns the [Source] in which this [Location] indexes.
|
||||
* If [:loc:] is a location, [:loc.source().text()[loc.start()] is where it
|
||||
* starts, and [:loc.source().text()[loc.end()] is where it ends.
|
||||
* If [:loc:] is a location, [:loc.source().text()[loc.start]:] is where it
|
||||
* starts, and [:loc.source().text()[loc.end]:] is where it ends.
|
||||
*/
|
||||
Source get source;
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ class InlineSyntax {
|
|||
|
||||
bool tryMatch(InlineParser parser) {
|
||||
final startMatch = pattern.firstMatch(parser.currentSource);
|
||||
if ((startMatch != null) && (startMatch.start() == 0)) {
|
||||
if ((startMatch != null) && (startMatch.start == 0)) {
|
||||
// Write any existing plain text up to this point.
|
||||
parser.writeText();
|
||||
|
||||
|
@ -354,7 +354,7 @@ class TagState {
|
|||
/// pattern.
|
||||
bool tryMatch(InlineParser parser) {
|
||||
Match endMatch = syntax.endPattern.firstMatch(parser.currentSource);
|
||||
if ((endMatch != null) && (endMatch.start() == 0)) {
|
||||
if ((endMatch != null) && (endMatch.start == 0)) {
|
||||
// Close the tag.
|
||||
close(parser, endMatch);
|
||||
return true;
|
||||
|
|
|
@ -243,8 +243,8 @@ class Bidi {
|
|||
Match match = const RegExp('<\\w+').firstMatch(html);
|
||||
if (match != null) {
|
||||
buffer.add(html.substring(
|
||||
startIndex, match.end())).add(' dir=$direction');
|
||||
startIndex = match.end();
|
||||
startIndex, match.end)).add(' dir=$direction');
|
||||
startIndex = match.end;
|
||||
}
|
||||
return buffer.add(html.substring(startIndex)).toString();
|
||||
}
|
||||
|
@ -296,9 +296,9 @@ class Bidi {
|
|||
var startIndex = 0;
|
||||
Iterable matches = regexp.allMatches(str);
|
||||
for (Match match in matches) {
|
||||
buffer.add(str.substring(startIndex, match.start())).add(before);
|
||||
buffer.add(str.substring(match.start(), match.end())).add(after);
|
||||
startIndex = match.end();
|
||||
buffer.add(str.substring(startIndex, match.start)).add(before);
|
||||
buffer.add(str.substring(match.start, match.end)).add(after);
|
||||
startIndex = match.end;
|
||||
}
|
||||
return buffer.add(str.substring(startIndex)).toString();
|
||||
}
|
||||
|
|
|
@ -5,13 +5,8 @@
|
|||
class _JSRegExpMatch implements Match {
|
||||
_JSRegExpMatch(this.regexp, this.str, this._match);
|
||||
|
||||
int start() {
|
||||
return _start(0);
|
||||
}
|
||||
|
||||
int end() {
|
||||
return _end(0);
|
||||
}
|
||||
int get start => _start(0);
|
||||
int get end => _end(0);
|
||||
|
||||
int _start(int groupIdx) {
|
||||
return _match[(groupIdx * MATCH_PAIR)];
|
||||
|
@ -46,9 +41,7 @@ class _JSRegExpMatch implements Match {
|
|||
return groupsList;
|
||||
}
|
||||
|
||||
int groupCount() {
|
||||
return regexp._groupCount;
|
||||
}
|
||||
int get groupCount => regexp._groupCount;
|
||||
|
||||
String get pattern => regexp.pattern;
|
||||
|
||||
|
|
|
@ -204,8 +204,8 @@ class _StringBase {
|
|||
Iterator iterator = pattern.allMatches(this).iterator();
|
||||
if (iterator.hasNext) {
|
||||
Match match = iterator.next();
|
||||
buffer.add(this.substring(startIndex, match.start())).add(replacement);
|
||||
startIndex = match.end();
|
||||
buffer.add(this.substring(startIndex, match.start)).add(replacement);
|
||||
startIndex = match.end;
|
||||
}
|
||||
return buffer.add(this.substring(startIndex)).toString();
|
||||
}
|
||||
|
@ -220,8 +220,8 @@ class _StringBase {
|
|||
StringBuffer buffer = new StringBuffer();
|
||||
int startIndex = 0;
|
||||
for (Match match in pattern.allMatches(this)) {
|
||||
buffer.add(this.substring(startIndex, match.start())).add(replacement);
|
||||
startIndex = match.end();
|
||||
buffer.add(this.substring(startIndex, match.start)).add(replacement);
|
||||
startIndex = match.end;
|
||||
}
|
||||
return buffer.add(this.substring(startIndex)).toString();
|
||||
}
|
||||
|
@ -278,16 +278,16 @@ class _StringBase {
|
|||
break;
|
||||
}
|
||||
Match match = iterator.next();
|
||||
if (match.start() == length) {
|
||||
if (match.start == length) {
|
||||
result.add(this.substring(previousIndex, length));
|
||||
break;
|
||||
}
|
||||
int endIndex = match.end();
|
||||
int endIndex = match.end;
|
||||
if (startIndex == endIndex && endIndex == previousIndex) {
|
||||
++startIndex; // empty match, advance and restart
|
||||
continue;
|
||||
}
|
||||
result.add(this.substring(previousIndex, match.start()));
|
||||
result.add(this.substring(previousIndex, match.start));
|
||||
startIndex = previousIndex = endIndex;
|
||||
}
|
||||
return result;
|
||||
|
@ -458,14 +458,13 @@ class _ExternalFourByteString extends _StringBase implements String {
|
|||
|
||||
|
||||
class _StringMatch implements Match {
|
||||
const _StringMatch(int this._start,
|
||||
const _StringMatch(int this.start,
|
||||
String this.str,
|
||||
String this.pattern);
|
||||
|
||||
int start() => _start;
|
||||
int end() => _start + pattern.length;
|
||||
int get end => start + pattern.length;
|
||||
String operator[](int g) => group(g);
|
||||
int groupCount() => 0;
|
||||
int get groupCount => 0;
|
||||
|
||||
String group(int group) {
|
||||
if (group != 0) {
|
||||
|
@ -482,7 +481,7 @@ class _StringMatch implements Match {
|
|||
return result;
|
||||
}
|
||||
|
||||
final int _start;
|
||||
final int start;
|
||||
final String str;
|
||||
final String pattern;
|
||||
}
|
||||
|
|
|
@ -95,6 +95,37 @@ LibTest/core/Map/getKeys_A01_t02: Fail, OK # co19 issue 293
|
|||
LibTest/core/Map/getValues_A01_t02: Fail, OK # co19 issue 293
|
||||
LibTest/core/Map/getValues_A01_t01: Fail, OK # co19 issue 293
|
||||
|
||||
LibTest/core/Match/end_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/Match/group_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/Match/groupCount_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/Match/operator_subscript_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/Match/start_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/allMatches_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/firstMatch_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Assertion_A03_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Assertion_A04_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Assertion_A05_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A02_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A03_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A03_t02: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A03_t03: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A04_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A05_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A06_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_AtomEscape_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Disjunction_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A02_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A03_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A04_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A05_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A06_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Term_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Term_A02_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Term_A03_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Term_A04_t01: Fail, OK # co19 issue 294
|
||||
|
||||
Language/10_Expressions/07_Maps_A07_t03: Fail, OK # co19 issue 287
|
||||
Language/10_Expressions/07_Maps_A04_t02: Fail, OK # co19 issue 287
|
||||
Language/10_Expressions/06_Lists_A05_t02: Fail, OK # co19 issue 287
|
||||
|
|
|
@ -346,6 +346,37 @@ LibTest/core/Map/getKeys_A01_t02: Fail, OK # co19 issue 293
|
|||
LibTest/core/Map/getValues_A01_t02: Fail, OK # co19 issue 293
|
||||
LibTest/core/Map/getValues_A01_t01: Fail, OK # co19 issue 293
|
||||
|
||||
LibTest/core/Match/end_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/Match/group_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/Match/groupCount_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/Match/operator_subscript_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/Match/start_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/allMatches_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/firstMatch_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Assertion_A03_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Assertion_A04_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Assertion_A05_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A02_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A03_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A03_t02: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A03_t03: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A04_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A05_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A06_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_AtomEscape_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Disjunction_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A02_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A03_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A04_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A05_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A06_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Term_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Term_A02_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Term_A03_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Term_A04_t01: Fail, OK # co19 issue 294
|
||||
|
||||
LibTest/core/Queue/filter_A01_t04: Fail, OK # co19 issue 291
|
||||
LibTest/core/Queue/first_A01_t01: Fail, OK # co19 issue 291
|
||||
LibTest/core/Queue/removeFirst_A01_t01: Fail, OK # co19 issue 291
|
||||
|
|
|
@ -368,6 +368,37 @@ LibTest/core/Map/getKeys_A01_t02: Fail, OK # co19 issue 293
|
|||
LibTest/core/Map/getValues_A01_t02: Fail, OK # co19 issue 293
|
||||
LibTest/core/Map/getValues_A01_t01: Fail, OK # co19 issue 293
|
||||
|
||||
LibTest/core/Match/end_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/Match/group_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/Match/groupCount_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/Match/operator_subscript_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/Match/start_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/allMatches_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/firstMatch_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Assertion_A03_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Assertion_A04_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Assertion_A05_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A02_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A03_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A03_t02: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A03_t03: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A04_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A05_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Atom_A06_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_AtomEscape_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Disjunction_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A02_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A03_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A04_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A05_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Quantifier_A06_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Term_A01_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Term_A02_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Term_A03_t01: Fail, OK # co19 issue 294
|
||||
LibTest/core/RegExp/Pattern_semantics/firstMatch_Term_A04_t01: Fail, OK # co19 issue 294
|
||||
|
||||
LibTest/core/Queue/filter_A01_t04: Fail, OK # co19 issue 291
|
||||
LibTest/core/Queue/first_A01_t01: Fail, OK # co19 issue 291
|
||||
LibTest/core/Queue/removeFirst_A01_t01: Fail, OK # co19 issue 291
|
||||
|
|
|
@ -10,8 +10,8 @@ main() {
|
|||
int end = 5;
|
||||
while (it.hasNext) {
|
||||
Match match = it.next();
|
||||
Expect.equals(start, match.start());
|
||||
Expect.equals(end, match.end());
|
||||
Expect.equals(start, match.start);
|
||||
Expect.equals(end, match.end);
|
||||
start += 6;
|
||||
end += 6;
|
||||
}
|
||||
|
|
|
@ -27,12 +27,12 @@ testOneMatch() {
|
|||
var iterator = matches.iterator();
|
||||
Match match = iterator.next();
|
||||
Expect.isFalse(iterator.hasNext);
|
||||
Expect.equals(str.indexOf('with', 0), match.start());
|
||||
Expect.equals(str.indexOf('with', 0) + helloPattern.length, match.end());
|
||||
Expect.equals(str.indexOf('with', 0), match.start);
|
||||
Expect.equals(str.indexOf('with', 0) + helloPattern.length, match.end);
|
||||
Expect.equals(helloPattern, match.pattern);
|
||||
Expect.equals(str, match.str);
|
||||
Expect.equals(helloPattern, match[0]);
|
||||
Expect.equals(0, match.groupCount());
|
||||
Expect.equals(0, match.groupCount);
|
||||
}
|
||||
|
||||
testTwoMatches() {
|
||||
|
@ -43,14 +43,14 @@ testTwoMatches() {
|
|||
int start = 0;
|
||||
for (var match in matches) {
|
||||
count++;
|
||||
Expect.equals(str.indexOf('hello', start), match.start());
|
||||
Expect.equals(str.indexOf('hello', start), match.start);
|
||||
Expect.equals(
|
||||
str.indexOf('hello', start) + helloPattern.length, match.end());
|
||||
str.indexOf('hello', start) + helloPattern.length, match.end);
|
||||
Expect.equals(helloPattern, match.pattern);
|
||||
Expect.equals(str, match.str);
|
||||
Expect.equals(helloPattern, match[0]);
|
||||
Expect.equals(0, match.groupCount());
|
||||
start = match.end();
|
||||
Expect.equals(0, match.groupCount);
|
||||
start = match.end;
|
||||
}
|
||||
Expect.equals(2, count);
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ class RegEx2Test {
|
|||
Match match = helloPattern.firstMatch(s);
|
||||
if (match != null) {
|
||||
print("got match");
|
||||
int groupCount = match.groupCount();
|
||||
int groupCount = match.groupCount;
|
||||
print("groupCount is $groupCount");
|
||||
print("group 0 is ${match.group(0)}");
|
||||
print("group 1 is ${match.group(1)}");
|
||||
|
|
|
@ -97,8 +97,8 @@ String replace(String source, Pattern matcher, String fn(Match)) {
|
|||
var buffer = new StringBuffer();
|
||||
var start = 0;
|
||||
for (var match in matcher.allMatches(source)) {
|
||||
buffer.add(source.substring(start, match.start()));
|
||||
start = match.end();
|
||||
buffer.add(source.substring(start, match.start));
|
||||
start = match.end;
|
||||
buffer.add(fn(match));
|
||||
}
|
||||
buffer.add(source.substring(start));
|
||||
|
@ -110,7 +110,7 @@ String replace(String source, Pattern matcher, String fn(Match)) {
|
|||
*/
|
||||
bool endsWithPattern(String str, Pattern matcher) {
|
||||
for (var match in matcher.allMatches(str)) {
|
||||
if (match.end() == str.length) return true;
|
||||
if (match.end == str.length) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -751,25 +751,25 @@ Nested #each or #with must have a localName;
|
|||
|
||||
int lastIdx = 0;
|
||||
for (Match m in matches) {
|
||||
if (m.start() > lastIdx) {
|
||||
newExpr.add(expr.substring(lastIdx, m.start()));
|
||||
if (m.start > lastIdx) {
|
||||
newExpr.add(expr.substring(lastIdx, m.start));
|
||||
}
|
||||
|
||||
bool identifier = true;
|
||||
if (m.start() > 0) {
|
||||
int charCode = expr.charCodeAt(m.start() - 1);
|
||||
if (m.start > 0) {
|
||||
int charCode = expr.charCodeAt(m.start - 1);
|
||||
// Starts with ' or " then it's not an identifier.
|
||||
identifier = charCode != 34 /* " */ && charCode != 39 /* ' */;
|
||||
}
|
||||
|
||||
String strMatch = expr.substring(m.start(), m.end());
|
||||
String strMatch = expr.substring(m.start, m.end);
|
||||
if (identifier) {
|
||||
newExpr.add("${prefixPart}.${strMatch}");
|
||||
} else {
|
||||
// Quoted string don't touch.
|
||||
newExpr.add("${strMatch}");
|
||||
}
|
||||
lastIdx = m.end();
|
||||
lastIdx = m.end;
|
||||
}
|
||||
|
||||
if (expr.length > lastIdx) {
|
||||
|
|
Loading…
Reference in a new issue