d6e272b8e1
http://code.google.com/p/dart/issues/detail?id=1548 This is also specified in JavaDoc for this method. R=danrubel@google.com BUG= TEST= Review URL: https://chromiumcodereview.appspot.com//9420011 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@4341 260f80e4-7a28-3924-810f-c04153c831b5
63 lines
1.7 KiB
Java
63 lines
1.7 KiB
Java
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
package com.google.dart.runner;
|
|
|
|
import com.google.dart.compiler.DartSource;
|
|
import com.google.dart.compiler.LibrarySource;
|
|
import com.google.dart.compiler.UrlDartSource;
|
|
import com.google.dart.compiler.UrlSource;
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
class BundleLibrarySource extends UrlSource implements LibrarySource {
|
|
|
|
private final class BundleDartSource extends UrlDartSource {
|
|
private BundleDartSource(ClassLoader loader, String basePath, String filename)
|
|
throws URISyntaxException {
|
|
super(loader.getResource(basePath + filename).toURI(), filename, BundleLibrarySource.this);
|
|
}
|
|
|
|
@Override
|
|
public String getName() {
|
|
return basePath + getRelativePath();
|
|
}
|
|
}
|
|
|
|
private final ClassLoader loader;
|
|
private final String basePath;
|
|
private final String filename;
|
|
|
|
public BundleLibrarySource(ClassLoader loader, String basePath, String filename)
|
|
throws URISyntaxException {
|
|
super(loader.getResource(basePath + filename).toURI());
|
|
this.loader = loader;
|
|
this.basePath = basePath;
|
|
this.filename = filename;
|
|
}
|
|
|
|
@Override
|
|
public LibrarySource getImportFor(String relPath) {
|
|
try {
|
|
return new BundleLibrarySource(loader, basePath, relPath);
|
|
} catch (URISyntaxException e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public DartSource getSourceFor(String relPath) {
|
|
try {
|
|
return new BundleDartSource(loader, basePath, relPath);
|
|
} catch (URISyntaxException e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getName() {
|
|
return basePath + filename;
|
|
}
|
|
}
|