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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/apiimpl.dart

Issue 21544003: Handle missing imports/exports/parts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add example to warning. Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 leg_apiimpl; 5 library leg_apiimpl;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import '../compiler.dart' as api; 9 import '../compiler.dart' as api;
10 import 'dart2jslib.dart' as leg; 10 import 'dart2jslib.dart' as leg;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 node: node); 163 node: node);
164 } 164 }
165 return fileReadingTask.measure(() { 165 return fileReadingTask.measure(() {
166 Uri resourceUri = translateUri(readableUri, node); 166 Uri resourceUri = translateUri(readableUri, node);
167 String text = ""; 167 String text = "";
168 try { 168 try {
169 // TODO(ahe): We expect the future to be complete and call value 169 // TODO(ahe): We expect the future to be complete and call value
170 // directly. In effect, we don't support truly asynchronous API. 170 // directly. In effect, we don't support truly asynchronous API.
171 text = deprecatedFutureValue(provider(resourceUri)); 171 text = deprecatedFutureValue(provider(resourceUri));
172 } catch (exception) { 172 } catch (exception) {
173 if (node != null) { 173 reportError(node,
174 cancel("$exception", node: node); 174 leg.MessageKind.READ_SCRIPT_ERROR,
175 } else { 175 {'uri': readableUri, 'exception': exception});
176 reportError( 176 return null;
177 null,
178 leg.MessageKind.GENERIC, {'text': 'Error: $exception'});
179 throw new leg.CompilerCancelledException("$exception");
180 }
181 } 177 }
182 SourceFile sourceFile = new SourceFile(resourceUri.toString(), text); 178 SourceFile sourceFile = new SourceFile(resourceUri.toString(), text);
183 // We use [readableUri] as the URI for the script since need to preserve 179 // We use [readableUri] as the URI for the script since need to preserve
184 // the scheme in the script because [Script.uri] is used for resolving 180 // the scheme in the script because [Script.uri] is used for resolving
185 // relative URIs mentioned in the script. See the comment on 181 // relative URIs mentioned in the script. See the comment on
186 // [LibraryLoader] for more details. 182 // [LibraryLoader] for more details.
187 return new leg.Script(readableUri, sourceFile); 183 return new leg.Script(readableUri, sourceFile);
188 }); 184 });
189 } 185 }
190 186
(...skipping 18 matching lines...) Expand all
209 bool allowInternalLibraryAccess = false; 205 bool allowInternalLibraryAccess = false;
210 if (importingLibrary != null) { 206 if (importingLibrary != null) {
211 if (importingLibrary.isPlatformLibrary || importingLibrary.isPatch) { 207 if (importingLibrary.isPlatformLibrary || importingLibrary.isPatch) {
212 allowInternalLibraryAccess = true; 208 allowInternalLibraryAccess = true;
213 } else if (importingLibrary.canonicalUri.path.contains( 209 } else if (importingLibrary.canonicalUri.path.contains(
214 'dart/tests/compiler/dart2js_native')) { 210 'dart/tests/compiler/dart2js_native')) {
215 allowInternalLibraryAccess = true; 211 allowInternalLibraryAccess = true;
216 } 212 }
217 } 213 }
218 if (!allowInternalLibraryAccess) { 214 if (!allowInternalLibraryAccess) {
219 if (node != null && importingLibrary != null) { 215 if (importingLibrary != null) {
220 reportError( 216 reportError(
221 node, 217 node,
222 leg.MessageKind.GENERIC, 218 leg.MessageKind.INTERNAL_LIBRARY_FROM,
223 {'text': 219 {'resolvedUri': resolvedUri,
224 'Error: Internal library $resolvedUri is not accessible from ' 220 'importingUri': importingLibrary.canonicalUri});
225 '${importingLibrary.canonicalUri}.'});
226 } else { 221 } else {
227 reportError( 222 reportError(
228 null, 223 node,
229 leg.MessageKind.GENERIC, 224 leg.MessageKind.INTERNAL_LIBRARY,
230 {'text': 225 {'resolvedUri': resolvedUri});
231 'Error: Internal library $resolvedUri is not accessible.'});
232 } 226 }
233 } 227 }
234 } 228 }
235 if (path == null) { 229 if (path == null) {
236 if (node != null) { 230 reportError(node, leg.MessageKind.LIBRARY_NOT_FOUND,
237 reportFatalError( 231 {'resolvedUri': resolvedUri});
238 node,
239 leg.MessageKind.GENERIC,
240 {'text': 'Error: Library not found ${resolvedUri}.'});
241 } else {
242 reportFatalError(
243 null,
244 leg.MessageKind.GENERIC,
245 {'text': 'Error: Library not found ${resolvedUri}.'});
246 }
247 return null; 232 return null;
248 } 233 }
249 if (resolvedUri.path == 'html' || 234 if (resolvedUri.path == 'html' ||
250 resolvedUri.path == 'io') { 235 resolvedUri.path == 'io') {
251 // TODO(ahe): Get rid of mockableLibraryUsed when test.dart 236 // TODO(ahe): Get rid of mockableLibraryUsed when test.dart
252 // supports this use case better. 237 // supports this use case better.
253 mockableLibraryUsed = true; 238 mockableLibraryUsed = true;
254 } 239 }
255 return libraryRoot.resolve(path); 240 return libraryRoot.resolve(path);
256 } 241 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 handler(translateUri(span.uri, null), span.begin, span.end, 282 handler(translateUri(span.uri, null), span.begin, span.end,
298 message, kind); 283 message, kind);
299 } 284 }
300 } 285 }
301 286
302 bool get isMockCompilation { 287 bool get isMockCompilation {
303 return mockableLibraryUsed 288 return mockableLibraryUsed
304 && (options.indexOf('--allow-mock-compilation') != -1); 289 && (options.indexOf('--allow-mock-compilation') != -1);
305 } 290 }
306 } 291 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698