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

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

Issue 2933753002: Run the sorter to reduce code churn (Closed)
Patch Set: Created 3 years, 6 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
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.scanner; 5 library analyzer.src.dart.scanner.scanner;
6 6
7 import 'package:analyzer/error/error.dart'; 7 import 'package:analyzer/error/error.dart';
8 import 'package:analyzer/error/listener.dart'; 8 import 'package:analyzer/error/listener.dart';
9 import 'package:analyzer/src/dart/error/syntactic_errors.dart'; 9 import 'package:analyzer/src/dart/error/syntactic_errors.dart';
10 import 'package:analyzer/src/dart/scanner/reader.dart'; 10 import 'package:analyzer/src/dart/scanner/reader.dart';
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 @override 103 @override
104 bool scanLazyAssignmentOperators = false; 104 bool scanLazyAssignmentOperators = false;
105 105
106 _Scanner2( 106 _Scanner2(
107 this.source, this._contents, this._readerOffset, this._errorListener) { 107 this.source, this._contents, this._readerOffset, this._errorListener) {
108 lineStarts.add(0); 108 lineStarts.add(0);
109 } 109 }
110 110
111 @override 111 @override
112 bool get hasUnmatchedGroups {
113 throw 'unsupported operation';
114 }
115
116 @override
117 set preserveComments(bool preserveComments) {
118 this._preserveComments = preserveComments;
119 }
120
121 @override
122 Token get tail {
123 throw 'unsupported operation';
124 }
125
126 @override
112 void appendToken(Token token) { 127 void appendToken(Token token) {
113 throw 'unsupported operation'; 128 throw 'unsupported operation';
114 } 129 }
115 130
116 @override 131 @override
117 int bigSwitch(int next) { 132 int bigSwitch(int next) {
118 throw 'unsupported operation'; 133 throw 'unsupported operation';
119 } 134 }
120 135
121 @override
122 bool get hasUnmatchedGroups {
123 throw 'unsupported operation';
124 }
125
126 @override 136 @override
127 void recordStartOfLine() { 137 void recordStartOfLine() {
128 throw 'unsupported operation'; 138 throw 'unsupported operation';
129 } 139 }
130 140
131 @override 141 @override
132 void reportError( 142 void reportError(
133 ScannerErrorCode errorCode, int offset, List<Object> arguments) { 143 ScannerErrorCode errorCode, int offset, List<Object> arguments) {
134 _errorListener 144 _errorListener
135 .onError(new AnalysisError(source, offset, 1, errorCode, arguments)); 145 .onError(new AnalysisError(source, offset, 1, errorCode, arguments));
136 } 146 }
137 147
138 @override 148 @override
139 void setSourceStart(int line, int column) { 149 void setSourceStart(int line, int column) {
140 int offset = _readerOffset; 150 int offset = _readerOffset;
141 if (line < 1 || column < 1 || offset < 0 || (line + column - 2) >= offset) { 151 if (line < 1 || column < 1 || offset < 0 || (line + column - 2) >= offset) {
142 return; 152 return;
143 } 153 }
144 lineStarts.removeAt(0); 154 lineStarts.removeAt(0);
145 for (int i = 2; i < line; i++) { 155 for (int i = 2; i < line; i++) {
146 lineStarts.add(1); 156 lineStarts.add(1);
147 } 157 }
148 lineStarts.add(offset - column + 1); 158 lineStarts.add(offset - column + 1);
149 } 159 }
150 160
151 @override 161 @override
152 Token get tail {
153 throw 'unsupported operation';
154 }
155
156 @override
157 Token tokenize() { 162 Token tokenize() {
158 fasta.ScannerResult result = fasta.scanString(_contents, 163 fasta.ScannerResult result = fasta.scanString(_contents,
159 includeComments: _preserveComments, 164 includeComments: _preserveComments,
160 scanGenericMethodComments: scanGenericMethodComments, 165 scanGenericMethodComments: scanGenericMethodComments,
161 scanLazyAssignmentOperators: scanLazyAssignmentOperators); 166 scanLazyAssignmentOperators: scanLazyAssignmentOperators);
162 167
163 // fasta pretends there is an additional line at EOF 168 // fasta pretends there is an additional line at EOF
164 result.lineStarts.removeLast(); 169 result.lineStarts.removeLast();
165 170
166 // for compatibility, there is already a first entry in lineStarts 171 // for compatibility, there is already a first entry in lineStarts
(...skipping 11 matching lines...) Expand all
178 // Update all token offsets based upon the reader's starting offset 183 // Update all token offsets based upon the reader's starting offset
179 if (_readerOffset != -1) { 184 if (_readerOffset != -1) {
180 final int delta = _readerOffset + 1; 185 final int delta = _readerOffset + 1;
181 do { 186 do {
182 token.offset += delta; 187 token.offset += delta;
183 token = token.next; 188 token = token.next;
184 } while (!token.isEof); 189 } while (!token.isEof);
185 } 190 }
186 return firstToken; 191 return firstToken;
187 } 192 }
188
189 @override
190 set preserveComments(bool preserveComments) {
191 this._preserveComments = preserveComments;
192 }
193 } 193 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/file_state.dart ('k') | pkg/analyzer/lib/src/generated/gn.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698