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

Unified Diff: pkg/front_end/lib/src/fasta/source/source_loader.dart

Issue 2804843003: Fix some crashes. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/source/source_loader.dart
diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart
index 76d3f612181ea3ae3d533d89b2f86d34de124d3c..fc70b06c27d4703dcb2850fbd67a94be706a8f20 100644
--- a/pkg/front_end/lib/src/fasta/source/source_loader.dart
+++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart
@@ -6,8 +6,6 @@ library fasta.source_loader;
import 'dart:async' show Future;
-import 'dart:io' show FileSystemException;
-
import 'dart:typed_data' show Uint8List;
import 'package:kernel/ast.dart' show Program;
@@ -30,7 +28,7 @@ import '../parser/class_member_parser.dart' show ClassMemberParser;
import '../scanner.dart' show ErrorToken, ScannerResult, Token, scan;
-import '../scanner/io.dart' show readBytesFromFile;
+import '../io.dart' show readBytesFromFile;
import '../target_implementation.dart' show TargetImplementation;
@@ -60,35 +58,26 @@ class SourceLoader<L> extends Loader<L> {
if (uri == null || uri.scheme != "file") {
return inputError(library.uri, -1, "Not found: ${library.uri}.");
}
- try {
- List<int> bytes = sourceBytes[uri];
- if (bytes == null) {
- bytes = sourceBytes[uri] = await readBytesFromFile(uri);
- }
- byteCount += bytes.length - 1;
- ScannerResult result = scan(bytes);
- Token token = result.tokens;
+ List<int> bytes = sourceBytes[uri];
+ if (bytes == null) {
+ bytes = sourceBytes[uri] = await readBytesFromFile(uri);
+ }
+ byteCount += bytes.length - 1;
+ ScannerResult result = scan(bytes);
+ Token token = result.tokens;
+ if (!suppressLexicalErrors) {
+ List<int> source = getSource(bytes);
+ target.addSourceInformation(library.fileUri, result.lineStarts, source);
+ }
+ while (token is ErrorToken) {
if (!suppressLexicalErrors) {
- List<int> source = getSource(bytes);
- target.addSourceInformation(library.fileUri, result.lineStarts, source);
- }
- while (token is ErrorToken) {
- if (!suppressLexicalErrors) {
- ErrorToken error = token;
- library.addCompileTimeError(token.charOffset, error.assertionMessage,
- fileUri: uri);
- }
- token = token.next;
- }
- return token;
- } on FileSystemException catch (e) {
- String message = e.message;
- String osMessage = e.osError?.message;
- if (osMessage != null && osMessage.isNotEmpty) {
- message = osMessage;
+ ErrorToken error = token;
+ library.addCompileTimeError(token.charOffset, error.assertionMessage,
+ fileUri: uri);
}
- return inputError(uri, -1, message);
+ token = token.next;
}
+ return token;
}
List<int> getSource(List<int> bytes) {
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | pkg/front_end/lib/src/fasta/translate_uri.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698