mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 14:24:38 +00:00
Throw ArgumentError if packageRoot is null.
R=johnniwinther@google.com Review URL: https://codereview.chromium.org//838773002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42677 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
8609239930
commit
cf8292288f
|
@ -91,11 +91,17 @@ class Compiler extends leg.Compiler {
|
|||
userHandlerTask = new leg.GenericTask('Diagnostic handler', this),
|
||||
userProviderTask = new leg.GenericTask('Input provider', this),
|
||||
]);
|
||||
if (!libraryRoot.path.endsWith("/")) {
|
||||
throw new ArgumentError("libraryRoot must end with a /");
|
||||
if (libraryRoot == null) {
|
||||
throw new ArgumentError("[libraryRoot] is null.");
|
||||
}
|
||||
if (packageRoot != null && !packageRoot.path.endsWith("/")) {
|
||||
throw new ArgumentError("packageRoot must end with a /");
|
||||
if (!libraryRoot.path.endsWith("/")) {
|
||||
throw new ArgumentError("[libraryRoot] must end with a /.");
|
||||
}
|
||||
if (packageRoot == null) {
|
||||
throw new ArgumentError("[packageRoot] is null.");
|
||||
}
|
||||
if (!packageRoot.path.endsWith("/")) {
|
||||
throw new ArgumentError("[packageRoot] must end with a /.");
|
||||
}
|
||||
if (!analyzeOnly) {
|
||||
if (enableAsyncAwait) {
|
||||
|
@ -309,10 +315,6 @@ class Compiler extends leg.Compiler {
|
|||
}
|
||||
|
||||
Uri translatePackageUri(leg.Spannable node, Uri uri) {
|
||||
if (packageRoot == null) {
|
||||
reportFatalError(
|
||||
node, leg.MessageKind.PACKAGE_ROOT_NOT_SET, {'uri': uri});
|
||||
}
|
||||
return packageRoot.resolve(uri.path);
|
||||
}
|
||||
|
||||
|
|
|
@ -1351,9 +1351,6 @@ main() => A.A = 1;
|
|||
"The class '#{class}' overrides 'operator==', "
|
||||
"but not 'get hashCode'.");
|
||||
|
||||
static const MessageKind PACKAGE_ROOT_NOT_SET = const MessageKind(
|
||||
"Cannot resolve '#{uri}'. Package root has not been set.");
|
||||
|
||||
static const MessageKind INTERNAL_LIBRARY_FROM = const MessageKind(
|
||||
"Internal library '#{resolvedUri}' is not accessible from "
|
||||
"'#{importingUri}'.");
|
||||
|
|
|
@ -46,7 +46,12 @@ main(List<String> arguments) {
|
|||
Uri myLocation =
|
||||
handler.provider.cwd.resolveUri(Platform.script);
|
||||
|
||||
sdkRoot = myLocation.resolve(SDK_ROOT).resolve('../');
|
||||
Uri packageRoot =
|
||||
handler.provider.cwd.resolve(Platform.packageRoot);
|
||||
|
||||
Uri libraryRoot = myLocation.resolve(SDK_ROOT);
|
||||
|
||||
sdkRoot = libraryRoot.resolve('../');
|
||||
|
||||
// Get the names of public dart2js libraries.
|
||||
Iterable<String> names = LIBRARIES.keys.where(isPublicDart2jsLibrary);
|
||||
|
@ -54,7 +59,7 @@ main(List<String> arguments) {
|
|||
// Turn the names into uris by prepending dart: to them.
|
||||
List<Uri> uris = names.map((String name) => Uri.parse('dart:$name')).toList();
|
||||
|
||||
analyze(uris, myLocation.resolve(SDK_ROOT), null, handler.provider, handler)
|
||||
analyze(uris, libraryRoot, packageRoot, handler.provider, handler)
|
||||
.then(jsonify);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,13 +43,14 @@ DeclarationMirror findMirror(Iterable<DeclarationMirror> list, Symbol name) {
|
|||
|
||||
main() {
|
||||
Uri scriptUri = currentDirectory.resolveUri(Platform.script);
|
||||
Uri packageRoot = scriptUri.resolve('./packages/');
|
||||
Uri libUri = scriptUri.resolve('../../../sdk/');
|
||||
Uri inputUri = scriptUri.resolve('mirrors_helper.dart');
|
||||
var provider = new CompilerSourceFileProvider();
|
||||
var diagnosticHandler =
|
||||
new FormattingDiagnosticHandler(provider).diagnosticHandler;
|
||||
asyncStart();
|
||||
var result = analyze([inputUri], libUri, null,
|
||||
var result = analyze([inputUri], libUri, packageRoot,
|
||||
provider.readStringFromUri, diagnosticHandler,
|
||||
<String>['--preserve-comments']);
|
||||
result.then((MirrorSystem mirrors) {
|
||||
|
|
|
@ -30,6 +30,7 @@ main() {}
|
|||
void runCompiler(Uri main, String expectedMessage) {
|
||||
Uri script = currentDirectory.resolveUri(Platform.script);
|
||||
Uri libraryRoot = script.resolve('../../../sdk/');
|
||||
Uri packageRoot = script.resolve('./packages/');
|
||||
|
||||
var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
|
||||
var handler = new FormattingDiagnosticHandler(provider);
|
||||
|
@ -53,7 +54,7 @@ void runCompiler(Uri main, String expectedMessage) {
|
|||
outputProvider,
|
||||
diagnosticHandler,
|
||||
libraryRoot,
|
||||
null,
|
||||
packageRoot,
|
||||
[],
|
||||
{});
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ main() {}
|
|||
void runCompiler(Uri main) {
|
||||
Uri script = currentDirectory.resolveUri(Platform.script);
|
||||
Uri libraryRoot = script.resolve('../../../sdk/');
|
||||
Uri packageRoot = script.resolve('./packages/');
|
||||
|
||||
var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES);
|
||||
var handler = new FormattingDiagnosticHandler(provider);
|
||||
|
@ -53,15 +54,15 @@ void runCompiler(Uri main) {
|
|||
outputProvider,
|
||||
diagnosticHandler,
|
||||
libraryRoot,
|
||||
null,
|
||||
packageRoot,
|
||||
[],
|
||||
{});
|
||||
|
||||
asyncTest(() => compiler.run(main).then((_) {
|
||||
Expect.equals(1, errors.length);
|
||||
Expect.equals("Cannot resolve 'package:foo/foo.dart'. "
|
||||
"Package root has not been set.",
|
||||
errors[0]);
|
||||
Expect.isTrue(
|
||||
errors[0].startsWith(
|
||||
"Can't read 'package:foo/foo.dart' (Error reading "));
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue