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

Side by Side Diff: pkg/front_end/lib/src/fasta/loader.dart

Issue 2965393002: Use FastaMessage instead of String. Part 1. (Closed)
Patch Set: Add type variable to Code. Created 3 years, 5 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 fasta.loader; 5 library fasta.loader;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:collection' show Queue; 9 import 'dart:collection' show Queue;
10 10
11 import 'builder/builder.dart' show Builder, LibraryBuilder; 11 import 'builder/builder.dart' show Builder, LibraryBuilder;
12 12
13 import 'deprecated_problems.dart' 13 import 'deprecated_problems.dart'
14 show deprecated_InputError, firstSourceUri, deprecated_printUnexpected; 14 show firstSourceUri, deprecated_printUnexpected;
15
16 import 'messages.dart' show LocatedMessage, Message, templateUnspecified;
15 17
16 import 'target_implementation.dart' show TargetImplementation; 18 import 'target_implementation.dart' show TargetImplementation;
17 19
18 import 'ticker.dart' show Ticker; 20 import 'ticker.dart' show Ticker;
19 21
20 abstract class Loader<L> { 22 abstract class Loader<L> {
21 final Map<Uri, LibraryBuilder> builders = <Uri, LibraryBuilder>{}; 23 final Map<Uri, LibraryBuilder> builders = <Uri, LibraryBuilder>{};
22 24
23 final Queue<LibraryBuilder> unparsedLibraries = new Queue<LibraryBuilder>(); 25 final Queue<LibraryBuilder> unparsedLibraries = new Queue<LibraryBuilder>();
24 26
25 final List<L> libraries = <L>[]; 27 final List<L> libraries = <L>[];
26 28
27 final TargetImplementation target; 29 final TargetImplementation target;
28 30
29 /// List of all handled compile-time errors seen so far by libraries loaded 31 /// List of all handled compile-time errors seen so far by libraries loaded
30 /// by this loader. 32 /// by this loader.
31 /// 33 ///
32 /// A handled error is an error that has been added to the generated AST 34 /// A handled error is an error that has been added to the generated AST
33 /// already, for example, as a throw expression. 35 /// already, for example, as a throw expression.
34 final List<deprecated_InputError> handledErrors = <deprecated_InputError>[]; 36 final List<LocatedMessage> handledErrors = <LocatedMessage>[];
35 37
36 /// List of all unhandled compile-time errors seen so far by libraries loaded 38 /// List of all unhandled compile-time errors seen so far by libraries loaded
37 /// by this loader. 39 /// by this loader.
38 /// 40 ///
39 /// An unhandled error is an error that hasn't been handled, see 41 /// An unhandled error is an error that hasn't been handled, see
40 /// [handledErrors]. 42 /// [handledErrors].
41 final List<deprecated_InputError> unhandledErrors = <deprecated_InputError>[]; 43 final List<LocatedMessage> unhandledErrors = <LocatedMessage>[];
42 44
43 LibraryBuilder coreLibrary; 45 LibraryBuilder coreLibrary;
44 46
45 LibraryBuilder first; 47 LibraryBuilder first;
46 48
47 int byteCount = 0; 49 int byteCount = 0;
48 50
49 Uri currentUriForCrashReporting; 51 Uri currentUriForCrashReporting;
50 52
51 Loader(this.target); 53 Loader(this.target);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 /// Builds all the method bodies found in the given [library]. 160 /// Builds all the method bodies found in the given [library].
159 Future<Null> buildBody(covariant LibraryBuilder library); 161 Future<Null> buildBody(covariant LibraryBuilder library);
160 162
161 /// Register [message] as a compile-time error. 163 /// Register [message] as a compile-time error.
162 /// 164 ///
163 /// If [silent] is true, no error is printed as it is assumed the error has 165 /// If [silent] is true, no error is printed as it is assumed the error has
164 /// been previously reported. 166 /// been previously reported.
165 /// 167 ///
166 /// If [wasHandled] is true, this error is added to [handledErrors], 168 /// If [wasHandled] is true, this error is added to [handledErrors],
167 /// otherwise it is added to [unhandledErrors]. 169 /// otherwise it is added to [unhandledErrors].
170 void addCompileTimeError(Message message, int charOffset, Uri fileUri,
171 {bool silent: false, bool wasHandled: false}) {
172 if (!silent) {
173 deprecated_printUnexpected(fileUri, charOffset, message.message);
174 }
175 (wasHandled ? handledErrors : unhandledErrors)
176 .add(message.withLocation(fileUri, charOffset));
177 }
178
168 void deprecated_addCompileTimeError( 179 void deprecated_addCompileTimeError(
169 Uri fileUri, int charOffset, Object message, 180 Uri fileUri, int charOffset, String message,
170 {bool silent: false, bool wasHandled: false}) { 181 {bool silent: false, bool wasHandled: false}) {
171 if (!silent) { 182 if (!silent) {
172 deprecated_printUnexpected(fileUri, charOffset, message); 183 deprecated_printUnexpected(fileUri, charOffset, message);
173 } 184 }
174 (wasHandled ? handledErrors : unhandledErrors) 185 (wasHandled ? handledErrors : unhandledErrors).add(templateUnspecified
175 .add(new deprecated_InputError(fileUri, charOffset, message)); 186 .withArguments(message)
187 .withLocation(fileUri, charOffset));
176 } 188 }
177 189
178 Builder getAbstractClassInstantiationError() { 190 Builder getAbstractClassInstantiationError() {
179 return target.getAbstractClassInstantiationError(this); 191 return target.getAbstractClassInstantiationError(this);
180 } 192 }
181 193
182 Builder getCompileTimeError() => target.getCompileTimeError(this); 194 Builder getCompileTimeError() => target.getCompileTimeError(this);
183 195
184 Builder getDuplicatedFieldInitializerError() { 196 Builder getDuplicatedFieldInitializerError() {
185 return target.getDuplicatedFieldInitializerError(this); 197 return target.getDuplicatedFieldInitializerError(this);
186 } 198 }
187 199
188 Builder getNativeAnnotation() => target.getNativeAnnotation(this); 200 Builder getNativeAnnotation() => target.getNativeAnnotation(this);
189 } 201 }
190 202
191 String format(double d, int fractionDigits, int width) { 203 String format(double d, int fractionDigits, int width) {
192 return d.toStringAsFixed(fractionDigits).padLeft(width); 204 return d.toStringAsFixed(fractionDigits).padLeft(width);
193 } 205 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_target.dart ('k') | pkg/front_end/lib/src/fasta/messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698