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

Side by Side Diff: pkg/front_end/lib/src/incremental/file_state.dart

Issue 2879063002: Skip native clauses when parsing directives. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | pkg/front_end/test/src/incremental/mock_sdk.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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:typed_data'; 6 import 'dart:typed_data';
7 7
8 import 'package:crypto/crypto.dart'; 8 import 'package:crypto/crypto.dart';
9 import 'package:front_end/file_system.dart'; 9 import 'package:front_end/file_system.dart';
10 import 'package:front_end/src/dependency_walker.dart' as graph; 10 import 'package:front_end/src/dependency_walker.dart' as graph;
11 import 'package:front_end/src/fasta/parser/dart_vm_native.dart';
11 import 'package:front_end/src/fasta/parser/top_level_parser.dart'; 12 import 'package:front_end/src/fasta/parser/top_level_parser.dart';
12 import 'package:front_end/src/fasta/scanner.dart'; 13 import 'package:front_end/src/fasta/scanner.dart';
13 import 'package:front_end/src/fasta/source/directive_listener.dart'; 14 import 'package:front_end/src/fasta/source/directive_listener.dart';
14 import 'package:front_end/src/fasta/translate_uri.dart'; 15 import 'package:front_end/src/fasta/translate_uri.dart';
15 import 'package:kernel/target/vm.dart'; 16 import 'package:kernel/target/vm.dart';
16 17
17 /// Information about a file being compiled, explicitly or implicitly. 18 /// Information about a file being compiled, explicitly or implicitly.
18 /// 19 ///
19 /// It provides a consistent view on its properties. 20 /// It provides a consistent view on its properties.
20 /// 21 ///
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } catch (_) { 109 } catch (_) {
109 _content = new Uint8List(0); 110 _content = new Uint8List(0);
110 _exists = false; 111 _exists = false;
111 } 112 }
112 113
113 // Compute the content hash. 114 // Compute the content hash.
114 _contentHash = md5.convert(_content).bytes; 115 _contentHash = md5.convert(_content).bytes;
115 116
116 // Parse directives. 117 // Parse directives.
117 ScannerResult scannerResults = _scan(); 118 ScannerResult scannerResults = _scan();
118 var listener = new DirectiveListener(); 119 var listener = new _DirectiveListenerWithNative();
119 new TopLevelParser(listener).parseUnit(scannerResults.tokens); 120 new TopLevelParser(listener).parseUnit(scannerResults.tokens);
120 121
121 // Build the graph. 122 // Build the graph.
122 _importedLibraries = <FileState>[]; 123 _importedLibraries = <FileState>[];
123 _exportedLibraries = <FileState>[]; 124 _exportedLibraries = <FileState>[];
124 _partFiles = <FileState>[]; 125 _partFiles = <FileState>[];
125 await _addFileForRelativeUri(_importedLibraries, 'dart:core'); 126 await _addFileForRelativeUri(_importedLibraries, 'dart:core');
126 for (String uri in listener.imports) { 127 for (String uri in listener.imports) {
127 await _addFileForRelativeUri(_importedLibraries, uri); 128 await _addFileForRelativeUri(_importedLibraries, uri);
128 } 129 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 250
250 @override 251 @override
251 String toString() { 252 String toString() {
252 if (_isForVm) { 253 if (_isForVm) {
253 return '[core + vm]'; 254 return '[core + vm]';
254 } 255 }
255 return '[' + libraries.join(', ') + ']'; 256 return '[' + libraries.join(', ') + ']';
256 } 257 }
257 } 258 }
258 259
260 /// [DirectiveListener] that skips native clauses.
261 class _DirectiveListenerWithNative extends DirectiveListener {
262 @override
263 Token handleNativeClause(Token token) => skipNativeClause(token);
264 }
265
259 /// [FileSystemState] based implementation of [FileSystem]. 266 /// [FileSystemState] based implementation of [FileSystem].
260 /// It provides a consistent view on the known file system state. 267 /// It provides a consistent view on the known file system state.
261 class _FileSystemView implements FileSystem { 268 class _FileSystemView implements FileSystem {
262 final FileSystemState fsState; 269 final FileSystemState fsState;
263 270
264 _FileSystemView(this.fsState); 271 _FileSystemView(this.fsState);
265 272
266 @override 273 @override
267 FileSystemEntity entityForUri(Uri uri) { 274 FileSystemEntity entityForUri(Uri uri) {
268 FileState file = fsState._fileUriToFile[uri]; 275 FileState file = fsState._fileUriToFile[uri];
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 node.isEvaluated = true; 346 node.isEvaluated = true;
340 cycle.libraries.add(node.file); 347 cycle.libraries.add(node.file);
341 } 348 }
342 topologicallySortedCycles.add(cycle); 349 topologicallySortedCycles.add(cycle);
343 } 350 }
344 351
345 _LibraryNode getNode(FileState file) { 352 _LibraryNode getNode(FileState file) {
346 return nodesOfFiles.putIfAbsent(file, () => new _LibraryNode(this, file)); 353 return nodesOfFiles.putIfAbsent(file, () => new _LibraryNode(this, file));
347 } 354 }
348 } 355 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/test/src/incremental/mock_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698