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

Side by Side Diff: pkg/analyzer/lib/src/dart/scanner/reader.dart

Issue 2784363002: flag to enable fasta scanner in analyzer (Closed)
Patch Set: rebase Created 3 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/scanner/scanner.dart » ('j') | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.src.dart.scanner.reader; 5 library analyzer.src.dart.scanner.reader;
6 6
7 import 'package:front_end/src/scanner/reader.dart'; 7 import 'package:front_end/src/scanner/reader.dart';
8 8
9 export 'package:front_end/src/scanner/reader.dart' 9 export 'package:front_end/src/scanner/reader.dart'
10 show CharacterReader, CharSequenceReader, SubSequenceReader; 10 show CharacterReader, CharSequenceReader, SubSequenceReader;
11 11
12 /** 12 /**
13 * A [CharacterReader] that reads a range of characters from another character 13 * A [CharacterReader] that reads a range of characters from another character
14 * reader. 14 * reader.
15 */ 15 */
16 class CharacterRangeReader extends CharacterReader { 16 class CharacterRangeReader extends CharacterReader {
17 /** 17 /**
18 * The reader from which the characters are actually being read. 18 * The reader from which the characters are actually being read.
19 */ 19 */
20 final CharacterReader baseReader; 20 final CharacterReader baseReader;
21 21
22 /** 22 /**
23 * The first character to be read.
24 */
25 final int startIndex;
26
27 /**
23 * The last character to be read. 28 * The last character to be read.
24 */ 29 */
25 final int endIndex; 30 final int endIndex;
26 31
27 /** 32 /**
28 * Initialize a newly created reader to read the characters from the given 33 * Initialize a newly created reader to read the characters from the given
29 * [baseReader] between the [startIndex] inclusive to [endIndex] exclusive. 34 * [baseReader] between the [startIndex] inclusive to [endIndex] exclusive.
30 */ 35 */
31 CharacterRangeReader(this.baseReader, int startIndex, this.endIndex) { 36 CharacterRangeReader(this.baseReader, this.startIndex, this.endIndex) {
32 baseReader.offset = startIndex - 1; 37 baseReader.offset = startIndex - 1;
33 } 38 }
34 39
35 @override 40 @override
36 int get offset => baseReader.offset; 41 int get offset => baseReader.offset;
37 42
38 @override 43 @override
39 void set offset(int offset) { 44 void set offset(int offset) {
40 baseReader.offset = offset; 45 baseReader.offset = offset;
41 } 46 }
42 47
43 @override 48 @override
44 int advance() { 49 int advance() {
45 if (baseReader.offset + 1 >= endIndex) { 50 if (baseReader.offset + 1 >= endIndex) {
46 return -1; 51 return -1;
47 } 52 }
48 return baseReader.advance(); 53 return baseReader.advance();
49 } 54 }
50 55
51 @override 56 @override
57 String getContents() =>
58 baseReader.getContents().substring(startIndex, endIndex);
59
60 @override
52 String getString(int start, int endDelta) => 61 String getString(int start, int endDelta) =>
53 baseReader.getString(start, endDelta); 62 baseReader.getString(start, endDelta);
54 63
55 @override 64 @override
56 int peek() { 65 int peek() {
57 if (baseReader.offset + 1 >= endIndex) { 66 if (baseReader.offset + 1 >= endIndex) {
58 return -1; 67 return -1;
59 } 68 }
60 return baseReader.peek(); 69 return baseReader.peek();
61 } 70 }
62 } 71 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/scanner/scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698