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

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

Issue 2864183002: Throw FileSystemException from FileSystemEntity methods. (Closed)
Patch Set: Use OS error message if available. Created 3 years, 7 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.source_loader; 5 library fasta.source_loader;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:io';
10 import 'dart:typed_data' show Uint8List; 9 import 'dart:typed_data' show Uint8List;
11 10
12 import 'package:front_end/file_system.dart'; 11 import 'package:front_end/file_system.dart';
13 import 'package:front_end/src/base/instrumentation.dart' show Instrumentation; 12 import 'package:front_end/src/base/instrumentation.dart' show Instrumentation;
14 13
15 import 'package:front_end/src/fasta/builder/ast_factory.dart' show AstFactory; 14 import 'package:front_end/src/fasta/builder/ast_factory.dart' show AstFactory;
16 15
17 import 'package:front_end/src/fasta/kernel/kernel_ast_factory.dart' 16 import 'package:front_end/src/fasta/kernel/kernel_ast_factory.dart'
18 show KernelAstFactory; 17 show KernelAstFactory;
19 18
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // Get the library text from the cache, or read from the file system. 84 // Get the library text from the cache, or read from the file system.
86 List<int> bytes = sourceBytes[uri]; 85 List<int> bytes = sourceBytes[uri];
87 if (bytes == null) { 86 if (bytes == null) {
88 try { 87 try {
89 List<int> rawBytes = await fileSystem.entityForUri(uri).readAsBytes(); 88 List<int> rawBytes = await fileSystem.entityForUri(uri).readAsBytes();
90 Uint8List zeroTerminatedBytes = new Uint8List(rawBytes.length + 1); 89 Uint8List zeroTerminatedBytes = new Uint8List(rawBytes.length + 1);
91 zeroTerminatedBytes.setRange(0, rawBytes.length, rawBytes); 90 zeroTerminatedBytes.setRange(0, rawBytes.length, rawBytes);
92 bytes = zeroTerminatedBytes; 91 bytes = zeroTerminatedBytes;
93 sourceBytes[uri] = bytes; 92 sourceBytes[uri] = bytes;
94 } on FileSystemException catch (e) { 93 } on FileSystemException catch (e) {
95 // TODO(scheglov) Throw and catch abstract file-system exceptions. 94 return inputError(uri, -1, e.message);
96 String message = e.message;
97 String osMessage = e.osError?.message;
98 if (osMessage != null && osMessage.isNotEmpty) {
99 message = osMessage;
100 }
101 return inputError(uri, -1, message);
102 } 95 }
103 } 96 }
104 97
105 byteCount += bytes.length - 1; 98 byteCount += bytes.length - 1;
106 ScannerResult result = scan(bytes); 99 ScannerResult result = scan(bytes);
107 Token token = result.tokens; 100 Token token = result.tokens;
108 if (!suppressLexicalErrors) { 101 if (!suppressLexicalErrors) {
109 List<int> source = getSource(bytes); 102 List<int> source = getSource(bytes);
110 target.addSourceInformation(library.fileUri, result.lineStarts, source); 103 target.addSourceInformation(library.fileUri, result.lineStarts, source);
111 } 104 }
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 /// Performs the second phase of top level initializer inference, which is to 413 /// Performs the second phase of top level initializer inference, which is to
421 /// visit fields and top level variables in topologically-sorted order and 414 /// visit fields and top level variables in topologically-sorted order and
422 /// assign their types. 415 /// assign their types.
423 void performInitializerInference() { 416 void performInitializerInference() {
424 typeInferenceEngine.finishTopLevel(); 417 typeInferenceEngine.finishTopLevel();
425 ticker.logMs("Performed initializer inference"); 418 ticker.logMs("Performed initializer inference");
426 } 419 }
427 420
428 List<Uri> getDependencies() => sourceBytes.keys.toList(); 421 List<Uri> getDependencies() => sourceBytes.keys.toList();
429 } 422 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/physical_file_system.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