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

Side by Side Diff: pkg/front_end/lib/src/incremental_resolved_ast_generator_impl.dart

Issue 2643033003: Clean up hacky handling of "dart:" URIs in incremental resolved AST generator. (Closed)
Patch Set: Created 3 years, 11 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) 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 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/file_system/file_system.dart'; 8 import 'package:analyzer/file_system/file_system.dart';
9 import 'package:analyzer/src/context/context.dart'; 9 import 'package:analyzer/src/context/context.dart';
10 import 'package:analyzer/src/dart/analysis/byte_store.dart'; 10 import 'package:analyzer/src/dart/analysis/byte_store.dart';
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // should be eliminated ASAP. 67 // should be eliminated ASAP.
68 var graph = 68 var graph =
69 await graphForProgram([_source], _options, fileReader: _fileReader); 69 await graphForProgram([_source], _options, fileReader: _fileReader);
70 // TODO(paulberry): collect no-longer-referenced files from _fileState and 70 // TODO(paulberry): collect no-longer-referenced files from _fileState and
71 // _fileRepository. 71 // _fileRepository.
72 var libraries = <Uri, ResolvedLibrary>{}; 72 var libraries = <Uri, ResolvedLibrary>{};
73 if (!_schedulerStarted) { 73 if (!_schedulerStarted) {
74 _scheduler.start(); 74 _scheduler.start();
75 _schedulerStarted = true; 75 _schedulerStarted = true;
76 } 76 }
77 // The driver will request files from dart:, even though it actually uses
78 // the data from the summary. TODO(paulberry): fix this.
79 _fileRepository.store(Uri.parse('dart:core'), '');
80 for (var libraryCycle in graph.topologicallySortedCycles) { 77 for (var libraryCycle in graph.topologicallySortedCycles) {
81 for (var libraryUri in libraryCycle.libraries.keys) { 78 for (var libraryUri in libraryCycle.libraries.keys) {
82 var libraryNode = libraryCycle.libraries[libraryUri]; 79 var libraryNode = libraryCycle.libraries[libraryUri];
83 for (var partUri in libraryNode.parts) { 80 for (var partUri in libraryNode.parts) {
84 // TODO(paulberry): resolve the part URI. 81 // TODO(paulberry): resolve the part URI.
85 _fileReader(partUri, partUri); 82 _fileReader(partUri, partUri);
86 } 83 }
87 } 84 }
88 for (var libraryUri in libraryCycle.libraries.keys) { 85 for (var libraryUri in libraryCycle.libraries.keys) {
89 var libraryNode = libraryCycle.libraries[libraryUri]; 86 var libraryNode = libraryCycle.libraries[libraryUri];
(...skipping 25 matching lines...) Expand all
115 // TODO(paulberry): can we just use null? 112 // TODO(paulberry): can we just use null?
116 var performanceLog = new driver.PerformanceLog(new _NullStringSink()); 113 var performanceLog = new driver.PerformanceLog(new _NullStringSink());
117 _scheduler = new driver.AnalysisDriverScheduler(performanceLog); 114 _scheduler = new driver.AnalysisDriverScheduler(performanceLog);
118 _resourceProvider = new _ResourceProviderProxy(_fileRepository); 115 _resourceProvider = new _ResourceProviderProxy(_fileRepository);
119 // TODO(paulberry): MemoryByteStore leaks memory (it never discards data). 116 // TODO(paulberry): MemoryByteStore leaks memory (it never discards data).
120 // Do something better here. 117 // Do something better here.
121 var byteStore = new MemoryByteStore(); 118 var byteStore = new MemoryByteStore();
122 // TODO(paulberry): can we just use null? 119 // TODO(paulberry): can we just use null?
123 var fileContentOverlay = new FileContentOverlay(); 120 var fileContentOverlay = new FileContentOverlay();
124 var sdkContext = new AnalysisContextImpl(); 121 var sdkContext = new AnalysisContextImpl();
125 var dartSdk = new _DartSdkProxy(await _options.getSdkSummary(), sdkContext); 122 var dartSdk = new _DartSdkProxy(
123 await _options.getSdkSummary(), sdkContext, _fileRepository);
126 sdkContext.sourceFactory = 124 sdkContext.sourceFactory =
127 new SourceFactory([new DartUriResolver(dartSdk)]); 125 new SourceFactory([new DartUriResolver(dartSdk)]);
128 bool strongMode = true; // TODO(paulberry): support strong mode flag. 126 bool strongMode = true; // TODO(paulberry): support strong mode flag.
129 sdkContext.resultProvider = new SdkSummaryResultProvider( 127 sdkContext.resultProvider = new SdkSummaryResultProvider(
130 sdkContext, await _options.getSdkSummary(), strongMode); 128 sdkContext, await _options.getSdkSummary(), strongMode);
131 129
132 var sourceFactory = new _SourceFactoryProxy(dartSdk, _fileRepository); 130 var sourceFactory = new _SourceFactoryProxy(dartSdk, _fileRepository);
133 var analysisOptions = new AnalysisOptionsImpl(); 131 var analysisOptions = new AnalysisOptionsImpl();
134 _driver = new driver.AnalysisDriver( 132 _driver = new driver.AnalysisDriver(
135 _scheduler, 133 _scheduler,
(...skipping 29 matching lines...) Expand all
165 _fileRepository.store(originalUri, contents); 163 _fileRepository.store(originalUri, contents);
166 return contents; 164 return contents;
167 } 165 }
168 } 166 }
169 167
170 class _DartSdkProxy implements DartSdk { 168 class _DartSdkProxy implements DartSdk {
171 final PackageBundle summary; 169 final PackageBundle summary;
172 170
173 final AnalysisContext context; 171 final AnalysisContext context;
174 172
175 _DartSdkProxy(this.summary, this.context); 173 final FileRepository _fileRepository;
174
175 _DartSdkProxy(this.summary, this.context, this._fileRepository);
176 176
177 @override 177 @override
178 PackageBundle getLinkedBundle() => summary; 178 PackageBundle getLinkedBundle() => summary;
179 179
180 @override 180 @override
181 Source mapDartUri(String uri) { 181 Source mapDartUri(String uriString) {
182 // TODO(paulberry): this seems hacky. 182 var uri = Uri.parse(uriString);
183 return new _SourceProxy(Uri.parse(uri), '$uri.dart'); 183 return new _SourceProxy(
184 uri, _fileRepository.pathForUri(uri, allocate: true));
184 } 185 }
185 186
186 noSuchMethod(Invocation invocation) => unimplemented(); 187 noSuchMethod(Invocation invocation) => unimplemented();
187 } 188 }
188 189
189 class _FileProxy implements File { 190 class _FileProxy implements File {
190 final _SourceProxy _source; 191 final _SourceProxy _source;
191 192
192 final _ResourceProviderProxy _resourceProvider; 193 final _ResourceProviderProxy _resourceProvider;
193 194
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 class _SourceProxy extends BasicSource { 291 class _SourceProxy extends BasicSource {
291 @override 292 @override
292 final String fullName; 293 final String fullName;
293 294
294 _SourceProxy(Uri uri, this.fullName) : super(uri); 295 _SourceProxy(Uri uri, this.fullName) : super(uri);
295 296
296 int get modificationStamp => 0; 297 int get modificationStamp => 0;
297 298
298 noSuchMethod(Invocation invocation) => unimplemented(); 299 noSuchMethod(Invocation invocation) => unimplemented();
299 } 300 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/base/file_repository.dart ('k') | pkg/front_end/test/src/base/file_repository_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698