mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Replace Uri.scheme ==
with Uri.isScheme
Use `hasScheme` in place of comparing against the empty string, and `isScheme` to compare against all other schemes. TEST=No behavior changes. Change-Id: Ifc9fd13c6cf37933ebd4a754c4b500dedbcb291b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231185 Reviewed-by: Kevin Moore <kevmoo@google.com> Commit-Queue: Nate Bosch <nbosch@google.com>
This commit is contained in:
parent
7282a40c49
commit
33e174084a
|
@ -238,7 +238,7 @@ class LibrariesSpecification {
|
|||
_reportError(messageIncludePathIsNotAString(targetName, specUri));
|
||||
}
|
||||
Uri uri = Uri.parse(path);
|
||||
if (uri.scheme != '' && uri.scheme != 'file') {
|
||||
if (uri.hasScheme && !uri.isScheme('file')) {
|
||||
return _reportError(messageUnsupportedUriScheme(path, specUri));
|
||||
}
|
||||
LibrariesSpecification specification =
|
||||
|
@ -269,7 +269,7 @@ class LibrariesSpecification {
|
|||
uriString, libraryName, targetName, specUri));
|
||||
}
|
||||
Uri uri = Uri.parse(uriString);
|
||||
if (uri.scheme != '' && uri.scheme != 'file') {
|
||||
if (uri.hasScheme && !uri.isScheme('file')) {
|
||||
return _reportError(
|
||||
messageUnsupportedUriScheme(uriString, specUri));
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ Uri resolveInputUri(String path) {
|
|||
|
||||
Uri parseUri(String path) {
|
||||
if (path.startsWith("file:")) {
|
||||
if (Uri.base.scheme == "file") {
|
||||
if (Uri.base.isScheme("file")) {
|
||||
// The Uri class doesn't handle relative file URIs correctly, the
|
||||
// following works around that issue.
|
||||
return new Uri(path: Uri.parse("x-$path").path);
|
||||
|
|
|
@ -362,7 +362,7 @@ class JsInteropChecks extends RecursiveVisitor {
|
|||
/// or a from environment constructor.
|
||||
bool _isAllowedExternalUsage(Member member) {
|
||||
Uri uri = member.enclosingLibrary.importUri;
|
||||
return uri.scheme == 'dart' &&
|
||||
return uri.isScheme('dart') &&
|
||||
_pathsWithAllowedDartExternalUsage.contains(uri.path) ||
|
||||
_allowedNativeTestPatterns.any((pattern) => uri.path.contains(pattern));
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class DartUnitHoverComputer {
|
|||
if (library != null) {
|
||||
var uri = library.source.uri;
|
||||
var analysisSession = _unit.declaredElement?.session;
|
||||
if (uri.scheme == 'file' && analysisSession != null) {
|
||||
if (uri.isScheme('file') && analysisSession != null) {
|
||||
// for 'file:' URIs, use the path after the project root
|
||||
var context = analysisSession.resourceProvider.pathContext;
|
||||
var projectRootDir =
|
||||
|
|
|
@ -173,7 +173,7 @@ protocol.ElementKind protocolElementKind(DeclarationKind kind) {
|
|||
|
||||
/// Computes the best URI to import [what] into the [unit] library.
|
||||
String? _getRelativeFileUri(DartCompletionRequest request, Uri what) {
|
||||
if (what.scheme == 'file') {
|
||||
if (what.isScheme('file')) {
|
||||
var pathContext = request.analysisSession.resourceProvider.pathContext;
|
||||
|
||||
var libraryPath = request.libraryElement.source.fullName;
|
||||
|
|
|
@ -43,14 +43,14 @@ class ConvertToPackageImport extends CorrectionProducer {
|
|||
}
|
||||
|
||||
var importUri = uriSource.uri;
|
||||
if (importUri.scheme != 'package') {
|
||||
if (!importUri.isScheme('package')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't offer to convert a 'package:' URI to itself.
|
||||
try {
|
||||
var uriContent = importDirective.uriContent;
|
||||
if (uriContent == null || Uri.parse(uriContent).scheme == 'package') {
|
||||
if (uriContent == null || Uri.parse(uriContent).isScheme('package')) {
|
||||
return;
|
||||
}
|
||||
} on FormatException {
|
||||
|
|
|
@ -45,7 +45,7 @@ class ConvertToRelativeImport extends CorrectionProducer {
|
|||
|
||||
// Ignore if the uri is not a package: uri.
|
||||
var sourceUri = resolvedResult.uri;
|
||||
if (sourceUri.scheme != 'package') {
|
||||
if (!sourceUri.isScheme('package')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class ConvertToRelativeImport extends CorrectionProducer {
|
|||
}
|
||||
|
||||
// Ignore if import uri is not a package: uri.
|
||||
if (importUri.scheme != 'package') {
|
||||
if (!importUri.isScheme('package')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -322,7 +322,7 @@ Map<String, Element> getImportNamespace(ImportElement imp) {
|
|||
/// Computes the best URI to import [what] into [from].
|
||||
String getLibrarySourceUri(
|
||||
path.Context pathContext, LibraryElement from, Uri what) {
|
||||
if (what.scheme == 'file') {
|
||||
if (what.isScheme('file')) {
|
||||
var fromFolder = pathContext.dirname(from.source.fullName);
|
||||
var relativeFile = pathContext.relative(what.path, from: fromFolder);
|
||||
return pathContext.split(relativeFile).join('/');
|
||||
|
|
|
@ -37,5 +37,5 @@ class ResourceUriResolver extends UriResolver {
|
|||
Uri restoreAbsolute(Source source) => pathToUri(source.fullName);
|
||||
|
||||
/// Return `true` if the given [uri] is a `file` URI.
|
||||
static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
|
||||
static bool isFileUri(Uri uri) => uri.isScheme(FILE_SCHEME);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ abstract class BasicSource extends Source {
|
|||
|
||||
@Deprecated('Use uri.isScheme("dart") instead')
|
||||
@override
|
||||
bool get isInSystemLibrary => uri.scheme == 'dart';
|
||||
bool get isInSystemLibrary => uri.isScheme('dart');
|
||||
|
||||
@override
|
||||
String get shortName => pathos.basename(fullName);
|
||||
|
|
|
@ -79,6 +79,6 @@ class PackageMapUriResolver extends UriResolver {
|
|||
|
||||
/// Returns `true` if [uri] is a `package` URI.
|
||||
static bool isPackageUri(Uri uri) {
|
||||
return uri.scheme == PACKAGE_SCHEME;
|
||||
return uri.isScheme(PACKAGE_SCHEME);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ class FileSource extends Source {
|
|||
|
||||
@Deprecated('Use uri.isScheme("dart") instead')
|
||||
@override
|
||||
bool get isInSystemLibrary => uri.scheme == DartUriResolver.DART_SCHEME;
|
||||
bool get isInSystemLibrary => uri.isScheme(DartUriResolver.DART_SCHEME);
|
||||
|
||||
@Deprecated('Not used anymore')
|
||||
@override
|
||||
|
|
|
@ -83,7 +83,7 @@ class BazelPackageUriResolver extends UriResolver {
|
|||
}
|
||||
|
||||
Source? _resolveAbsolute(Uri uri) {
|
||||
if (uri.scheme == 'file') {
|
||||
if (uri.isScheme('file')) {
|
||||
var path = fileUriToNormalizedPath(_context, uri);
|
||||
var pathRelativeToRoot = _workspace._relativeToRoot(path);
|
||||
if (pathRelativeToRoot == null) return null;
|
||||
|
@ -91,7 +91,7 @@ class BazelPackageUriResolver extends UriResolver {
|
|||
var file = _workspace.findFile(fullFilePath);
|
||||
return file?.createSource(uri);
|
||||
}
|
||||
if (uri.scheme != 'package') {
|
||||
if (!uri.isScheme('package')) {
|
||||
return null;
|
||||
}
|
||||
String uriPath = Uri.decodeComponent(uri.path);
|
||||
|
|
|
@ -73,7 +73,7 @@ class PackageBuildPackageUriResolver extends UriResolver {
|
|||
|
||||
@override
|
||||
Source? resolveAbsolute(Uri uri) {
|
||||
if (uri.scheme != 'package') {
|
||||
if (!uri.isScheme('package')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ abstract class WorkspacePackage {
|
|||
/// example, the case of a [InSummarySource]). In this case, use
|
||||
/// [workspace]'s package URI resolver to fetch the file path.
|
||||
String? filePathFromSource(Source source) {
|
||||
if (source.uri.scheme == 'package') {
|
||||
if (source.uri.isScheme('package')) {
|
||||
return workspace.packageUriResolver.resolveAbsolute(source.uri)?.fullName;
|
||||
} else {
|
||||
return source.fullName;
|
||||
|
|
|
@ -530,9 +530,9 @@ class TestSourceWithUri extends TestSource {
|
|||
@Deprecated('Use Source.uri instead')
|
||||
@override
|
||||
UriKind get uriKind {
|
||||
if (uri.scheme == 'dart') {
|
||||
if (uri.isScheme('dart')) {
|
||||
return UriKind.DART_URI;
|
||||
} else if (uri.scheme == 'package') {
|
||||
} else if (uri.isScheme('package')) {
|
||||
return UriKind.PACKAGE_URI;
|
||||
}
|
||||
return UriKind.FILE_URI;
|
||||
|
|
|
@ -783,7 +783,7 @@ part of 'a.dart';
|
|||
if (file is LibraryCycle) {
|
||||
return !file.libraries.any((file) => file.uri.isScheme('dart'));
|
||||
} else if (file is FileState) {
|
||||
return file.uri.scheme != 'dart';
|
||||
return !file.uri.isScheme('dart');
|
||||
} else if (file == null) {
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -127,7 +127,7 @@ class AnalyzerImpl {
|
|||
files.clear();
|
||||
errorsResults.clear();
|
||||
var libraryUri = libraryFile.uri;
|
||||
if (libraryUri.scheme == 'package' && libraryUri.pathSegments.isNotEmpty) {
|
||||
if (libraryUri.isScheme('package') && libraryUri.pathSegments.isNotEmpty) {
|
||||
_selfPackageName = libraryUri.pathSegments[0];
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ class AnalyzerImpl {
|
|||
|
||||
/// Determine whether the given URI refers to a package being analyzed.
|
||||
bool _isAnalyzedPackage(Uri uri) {
|
||||
if (uri.scheme != 'package' || uri.pathSegments.isEmpty) {
|
||||
if (!uri.isScheme('package') || uri.pathSegments.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
var packageName = uri.pathSegments.first;
|
||||
|
|
|
@ -52,7 +52,7 @@ class MultiRootFileSystemEntity implements FileSystemEntity {
|
|||
_delegate ??= await _resolveEntity();
|
||||
|
||||
Future<FileSystemEntity> _resolveEntity() async {
|
||||
if (uri.scheme == multiRootFileSystem.markerScheme) {
|
||||
if (uri.isScheme(multiRootFileSystem.markerScheme)) {
|
||||
if (!uri.isAbsolute) {
|
||||
throw new FileSystemException(
|
||||
uri, "This MultiRootFileSystem only handles absolutes URIs: $uri");
|
||||
|
|
|
@ -33,7 +33,7 @@ class SingleRootFileSystem implements FileSystem {
|
|||
|
||||
@override
|
||||
FileSystemEntity entityForUri(Uri uri) {
|
||||
if (uri.scheme != markerScheme) {
|
||||
if (!uri.isScheme(markerScheme)) {
|
||||
throw new FileSystemException(
|
||||
uri,
|
||||
"This SingleRootFileSystem only handles URIs with the '$markerScheme'"
|
||||
|
|
|
@ -726,7 +726,7 @@ abstract class Compiler {
|
|||
Uri getCanonicalUri(Entity element) {
|
||||
Uri libraryUri = _uriFromElement(element);
|
||||
if (libraryUri == null) return null;
|
||||
if (libraryUri.scheme == 'package') {
|
||||
if (libraryUri.isScheme('package')) {
|
||||
int slashPos = libraryUri.path.indexOf('/');
|
||||
if (slashPos != -1) {
|
||||
String packageName = libraryUri.path.substring(0, slashPos);
|
||||
|
|
|
@ -1102,7 +1102,7 @@ class AbortLeg {
|
|||
|
||||
void writeString(Uri uri, String text) {
|
||||
if (!enableWriteString) return;
|
||||
if (uri.scheme != 'file') {
|
||||
if (!uri.isScheme('file')) {
|
||||
fail('Unhandled scheme ${uri.scheme}.');
|
||||
}
|
||||
var file = (File(uri.toFilePath())..createSync(recursive: true))
|
||||
|
|
|
@ -18,7 +18,7 @@ abstract class CodeLocation {
|
|||
String relativize(Uri baseUri);
|
||||
|
||||
factory CodeLocation(Uri uri) {
|
||||
if (uri.scheme == 'package') {
|
||||
if (uri.isScheme('package')) {
|
||||
int slashPos = uri.path.indexOf('/');
|
||||
if (slashPos != -1) {
|
||||
String packageName = uri.path.substring(0, slashPos);
|
||||
|
@ -42,7 +42,7 @@ class SchemeLocation implements CodeLocation {
|
|||
|
||||
@override
|
||||
bool inSameLocation(Uri uri) {
|
||||
return this.uri.scheme == uri.scheme;
|
||||
return this.uri.isScheme(uri.scheme);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -62,7 +62,7 @@ class PackageLocation implements CodeLocation {
|
|||
|
||||
@override
|
||||
bool inSameLocation(Uri uri) {
|
||||
return uri.scheme == 'package' && uri.path.startsWith('$packageName/');
|
||||
return uri.isScheme('package') && uri.path.startsWith('$packageName/');
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -19,17 +19,17 @@ int compareLibrariesUris(Uri a, Uri b) {
|
|||
}
|
||||
|
||||
// Order: platform < package < other.
|
||||
if (a.scheme == 'dart') {
|
||||
if (b.scheme == 'dart') return byCanonicalUriPath();
|
||||
if (a.isScheme('dart')) {
|
||||
if (b.isScheme('dart')) return byCanonicalUriPath();
|
||||
return -1;
|
||||
}
|
||||
if (b.scheme == 'dart') return 1;
|
||||
if (b.isScheme('dart')) return 1;
|
||||
|
||||
if (a.scheme == 'package') {
|
||||
if (b.scheme == 'package') return byCanonicalUriPath();
|
||||
if (a.isScheme('package')) {
|
||||
if (b.isScheme('package')) return byCanonicalUriPath();
|
||||
return -1;
|
||||
}
|
||||
if (b.scheme == 'package') return 1;
|
||||
if (b.isScheme('package')) return 1;
|
||||
|
||||
return _compareCanonicalUri(a, b);
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ bool containsFreeVariables(ir.DartType type) =>
|
|||
|
||||
/// Returns true if [importUri] corresponds to dart:html and related libraries.
|
||||
bool _isWebLibrary(Uri importUri) =>
|
||||
importUri.scheme == 'dart' &&
|
||||
importUri.isScheme('dart') &&
|
||||
(importUri.path == 'html' ||
|
||||
importUri.path == 'svg' ||
|
||||
importUri.path == 'indexed_db' ||
|
||||
|
|
|
@ -156,7 +156,7 @@ EnumSet<PragmaAnnotation> processMemberAnnotations(
|
|||
|
||||
Uri uri = member.enclosingLibrary.importUri;
|
||||
bool platformAnnotationsAllowed =
|
||||
options.testMode || uri.scheme == 'dart' || maybeEnableNative(uri);
|
||||
options.testMode || uri.isScheme('dart') || maybeEnableNative(uri);
|
||||
|
||||
for (PragmaAnnotationData data in pragmaAnnotationData) {
|
||||
String name = data.name;
|
||||
|
|
|
@ -158,7 +158,7 @@ class BackendUsageBuilderImpl implements BackendUsageBuilder {
|
|||
bool _isValidBackendUse(Entity element, LibraryEntity library) {
|
||||
if (_isValidEntity(element)) return true;
|
||||
SourceSpan span = _frontendStrategy.spanFromSpannable(element, element);
|
||||
if (library.canonicalUri.scheme == 'dart' &&
|
||||
if (library.canonicalUri.isScheme('dart') &&
|
||||
span.uri.path.contains('_internal/js_runtime/lib/')) {
|
||||
// TODO(johnniwinther): We should be more precise about these.
|
||||
return true;
|
||||
|
|
|
@ -55,7 +55,7 @@ bool allowedNativeTest(Uri uri) {
|
|||
|
||||
bool maybeEnableNative(Uri uri) {
|
||||
bool allowedDartLibrary() {
|
||||
if (uri.scheme != 'dart') return false;
|
||||
if (!uri.isScheme('dart')) return false;
|
||||
return _allowedDartSchemePaths.contains(uri.path);
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ class Dart2jsTarget extends Target {
|
|||
bool allowPlatformPrivateLibraryAccess(Uri importer, Uri imported) =>
|
||||
super.allowPlatformPrivateLibraryAccess(importer, imported) ||
|
||||
maybeEnableNative(importer) ||
|
||||
(importer.scheme == 'package' &&
|
||||
(importer.isScheme('package') &&
|
||||
importer.path.startsWith('dart2js_runtime_metrics/'));
|
||||
|
||||
@override
|
||||
|
|
|
@ -23,7 +23,7 @@ class CompilerFileSystem implements fe.FileSystem {
|
|||
|
||||
@override
|
||||
fe.FileSystemEntity entityForUri(Uri uri) {
|
||||
if (uri.scheme == 'data') {
|
||||
if (uri.isScheme('data')) {
|
||||
return fe.DataFileSystemEntity(Uri.base.resolveUri(uri));
|
||||
} else {
|
||||
return _CompilerFileSystemEntity(uri, this);
|
||||
|
|
|
@ -269,7 +269,7 @@ class KernelLoaderTask extends CompilerTask {
|
|||
|
||||
// Libraries dependencies do not show implicit imports to `dart:core`.
|
||||
var dartCore = component.libraries.firstWhere((lib) {
|
||||
return lib.importUri.scheme == 'dart' && lib.importUri.path == 'core';
|
||||
return lib.importUri.isScheme('dart') && lib.importUri.path == 'core';
|
||||
});
|
||||
search(dartCore);
|
||||
|
||||
|
|
|
@ -826,7 +826,7 @@ class CompilerOptions implements DiagnosticOptions {
|
|||
return true;
|
||||
}
|
||||
if (shownPackageWarnings != null) {
|
||||
return uri.scheme == 'package' &&
|
||||
return uri.isScheme('package') &&
|
||||
shownPackageWarnings!.contains(uri.pathSegments.first);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -40,9 +40,9 @@ abstract class SourceFileProvider implements CompilerInput {
|
|||
}
|
||||
if (input != null) return Future.value(input);
|
||||
|
||||
if (resourceUri.scheme == 'file') {
|
||||
if (resourceUri.isScheme('file')) {
|
||||
return _readFromFile(resourceUri, inputKind);
|
||||
} else if (resourceUri.scheme == 'http' || resourceUri.scheme == 'https') {
|
||||
} else if (resourceUri.isScheme('http') || resourceUri.isScheme('https')) {
|
||||
return _readFromHttp(resourceUri, inputKind);
|
||||
} else {
|
||||
throw ArgumentError("Unknown scheme in uri '$resourceUri'");
|
||||
|
@ -50,7 +50,7 @@ abstract class SourceFileProvider implements CompilerInput {
|
|||
}
|
||||
|
||||
api.Input _readFromFileSync(Uri resourceUri, api.InputKind inputKind) {
|
||||
assert(resourceUri.scheme == 'file');
|
||||
assert(resourceUri.isScheme('file'));
|
||||
List<int> source;
|
||||
try {
|
||||
source = readAll(resourceUri.toFilePath(),
|
||||
|
@ -99,7 +99,7 @@ abstract class SourceFileProvider implements CompilerInput {
|
|||
|
||||
Future<api.Input<List<int>>> _readFromHttp(
|
||||
Uri resourceUri, api.InputKind inputKind) {
|
||||
assert(resourceUri.scheme == 'http');
|
||||
assert(resourceUri.isScheme('http'));
|
||||
HttpClient client = HttpClient();
|
||||
return client
|
||||
.getUrl(resourceUri)
|
||||
|
@ -279,7 +279,7 @@ class FormattingDiagnosticHandler implements CompilerDiagnostics {
|
|||
api.Input file = provider.getUtf8SourceFile(uri);
|
||||
if (file == null &&
|
||||
autoReadFileUri &&
|
||||
(uri.scheme == 'file' || !uri.isAbsolute) &&
|
||||
(uri.isScheme('file') || !uri.isAbsolute) &&
|
||||
uri.path.endsWith('.dart')) {
|
||||
if (!uri.isAbsolute) {
|
||||
uri = provider.cwd.resolveUri(uri);
|
||||
|
@ -379,7 +379,7 @@ class RandomAccessFileOutputProvider implements CompilerOutput {
|
|||
Uri uri = createUri(name, extension, type);
|
||||
bool isPrimaryOutput = uri == out;
|
||||
|
||||
if (uri.scheme != 'file') {
|
||||
if (!uri.isScheme('file')) {
|
||||
onFailure('Unhandled scheme ${uri.scheme} in $uri.');
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,7 @@ class RandomAccessFileOutputProvider implements CompilerOutput {
|
|||
|
||||
allOutputFiles.add(fe.relativizeUri(Uri.base, uri, Platform.isWindows));
|
||||
|
||||
if (uri.scheme != 'file') {
|
||||
if (!uri.isScheme('file')) {
|
||||
onFailure('Unhandled scheme ${uri.scheme} in $uri.');
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,7 @@ class MultiRootInputProvider extends SourceFileProvider {
|
|||
Future<api.Input<List<int>>> readFromUri(Uri uri,
|
||||
{InputKind inputKind = InputKind.UTF8}) async {
|
||||
var resolvedUri = uri;
|
||||
if (resolvedUri.scheme == markerScheme) {
|
||||
if (resolvedUri.isScheme(markerScheme)) {
|
||||
var path = resolvedUri.path;
|
||||
if (path.startsWith('/')) path = path.substring(1);
|
||||
for (var dir in roots) {
|
||||
|
@ -634,7 +634,7 @@ class MultiRootInputProvider extends SourceFileProvider {
|
|||
|
||||
@override
|
||||
api.Input autoReadFromFile(Uri resourceUri) {
|
||||
if (resourceUri.scheme == markerScheme) {
|
||||
if (resourceUri.isScheme(markerScheme)) {
|
||||
var path = resourceUri.path;
|
||||
for (var dir in roots) {
|
||||
var file = dir.resolve(path);
|
||||
|
|
|
@ -40,7 +40,7 @@ main(List<String> args) {
|
|||
Uri packageConfig = getPackages(argResults);
|
||||
List<String> options = getOptions(argResults);
|
||||
run(entryPoint, null,
|
||||
analyzedUrisFilter: (Uri uri) => uri.scheme != 'dart',
|
||||
analyzedUrisFilter: (Uri uri) => !uri.isScheme('dart'),
|
||||
librariesSpecificationUri: librariesSpecificationUri,
|
||||
packageConfig: packageConfig,
|
||||
options: options);
|
||||
|
@ -362,7 +362,7 @@ class DynamicVisitor extends StaticTypeVisitorBase {
|
|||
String reportAssertionFailure(ir.Node node, String message) {
|
||||
SourceSpan span = computeSourceSpanFromTreeNode(node);
|
||||
Uri uri = span.uri;
|
||||
if (uri.scheme == 'org-dartlang-sdk') {
|
||||
if (uri.isScheme('org-dartlang-sdk')) {
|
||||
span = new SourceSpan(
|
||||
Uri.base.resolve(uri.path.substring(1)), span.begin, span.end);
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ class DynamicVisitor extends StaticTypeVisitorBase {
|
|||
String uriString = relativizeUri(Uri.base, uri, Platform.isWindows);
|
||||
Map<String, List<DiagnosticMessage>> actualMap = _actualMessages
|
||||
.putIfAbsent(uriString, () => <String, List<DiagnosticMessage>>{});
|
||||
if (uri.scheme == 'org-dartlang-sdk') {
|
||||
if (uri.isScheme('org-dartlang-sdk')) {
|
||||
span = new SourceSpan(
|
||||
Uri.base.resolve(uri.path.substring(1)), span.begin, span.end);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ main(List<String> args) {
|
|||
asyncTest(() async {
|
||||
await run(
|
||||
Uri.parse('memory:main.dart'), 'pkg/compiler/test/analyses/$goldenFile',
|
||||
analyzedUrisFilter: (Uri uri) => uri.scheme == 'dart',
|
||||
analyzedUrisFilter: (Uri uri) => uri.isScheme('dart'),
|
||||
memorySourceFiles: {'main.dart': 'main() {}'},
|
||||
verbose: args.contains('-v'),
|
||||
generate: args.contains('-g'));
|
||||
|
|
|
@ -109,7 +109,7 @@ class TestFileSystem implements FileSystem {
|
|||
|
||||
@override
|
||||
FileSystemEntity entityForUri(Uri uri) {
|
||||
if (uri.scheme == 'file') return physical.entityForUri(uri);
|
||||
if (uri.isScheme('file')) return physical.entityForUri(uri);
|
||||
return memory.entityForUri(uri);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,8 +248,8 @@ Future<CompiledData<T>> computeData<T>(String name, Uri entryPoint,
|
|||
|
||||
bool excludeLibrary(LibraryEntity library) {
|
||||
return forUserLibrariesOnly &&
|
||||
(library.canonicalUri.scheme == 'dart' ||
|
||||
library.canonicalUri.scheme == 'package');
|
||||
(library.canonicalUri.isScheme('dart') ||
|
||||
library.canonicalUri.isScheme('package'));
|
||||
}
|
||||
|
||||
ir.Library getIrLibrary(LibraryEntity library) {
|
||||
|
|
|
@ -65,7 +65,7 @@ show<T>(ArgResults argResults, DataComputer<T> dataComputer,
|
|||
SourceFileProvider provider = data.compiler.provider;
|
||||
for (Uri uri in data.actualMaps.keys) {
|
||||
Uri fileUri = uri;
|
||||
if (fileUri.scheme == 'org-dartlang-sdk') {
|
||||
if (fileUri.isScheme('org-dartlang-sdk')) {
|
||||
fileUri = Uri.base.resolve(fileUri.path.substring(1));
|
||||
}
|
||||
if (show != null && !show.any((f) => '$fileUri'.endsWith(f))) {
|
||||
|
|
|
@ -21,8 +21,8 @@ ClassEntity findClass(JClosedWorld closedWorld, String name) {
|
|||
closedWorld.commonElements.jsHelperLibrary, name);
|
||||
if (cls == null) {
|
||||
for (LibraryEntity library in elementEnvironment.libraries) {
|
||||
if (library.canonicalUri.scheme != 'dart' &&
|
||||
library.canonicalUri.scheme != 'package') {
|
||||
if (!library.canonicalUri.isScheme('dart') &&
|
||||
!library.canonicalUri.isScheme('package')) {
|
||||
cls = elementEnvironment.lookupClass(library, name);
|
||||
if (cls != null) {
|
||||
break;
|
||||
|
@ -70,8 +70,8 @@ MemberEntity findMember(JClosedWorld closedWorld, String name) {
|
|||
setter: isSetter);
|
||||
if (member == null) {
|
||||
for (LibraryEntity library in elementEnvironment.libraries) {
|
||||
if (library.canonicalUri.scheme != 'dart' &&
|
||||
library.canonicalUri.scheme != 'package') {
|
||||
if (!library.canonicalUri.isScheme('dart') &&
|
||||
!library.canonicalUri.isScheme('package')) {
|
||||
member = elementEnvironment.lookupLibraryMember(library, name,
|
||||
setter: isSetter);
|
||||
if (member != null) {
|
||||
|
|
|
@ -31,7 +31,7 @@ class MemorySourceFileProvider extends SourceFileProvider {
|
|||
@override
|
||||
Future<Input<List<int>>> readBytesFromUri(
|
||||
Uri resourceUri, InputKind inputKind) {
|
||||
if (resourceUri.scheme != 'memory') {
|
||||
if (!resourceUri.isScheme('memory')) {
|
||||
return super.readBytesFromUri(resourceUri, inputKind);
|
||||
}
|
||||
// TODO(johnniwinther): We should use inputs already in the cache. Some
|
||||
|
|
|
@ -351,7 +351,7 @@ main(List<String> args) {
|
|||
}
|
||||
|
||||
for (ir.Library library in component.libraries) {
|
||||
if (library.importUri.scheme == 'memory') {
|
||||
if (library.importUri.isScheme('memory')) {
|
||||
String libraryId = library.importUri.path;
|
||||
LibraryEntity libraryEntity = elementMap.getLibrary(library);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ Future runTest() async {
|
|||
Selector callSelector = new Selector.callClosure(0);
|
||||
closedWorld.classHierarchy.forEachStrictSubclassOf(
|
||||
closedWorld.commonElements.objectClass, (ClassEntity cls) {
|
||||
if (cls.library.canonicalUri.scheme != 'memory')
|
||||
if (!cls.library.canonicalUri.isScheme('memory'))
|
||||
return IterationStep.CONTINUE;
|
||||
|
||||
TypeMask mask = new TypeMask.nonNullSubclass(cls, closedWorld);
|
||||
|
|
|
@ -157,7 +157,7 @@ Future<TestResult> runTests(
|
|||
.process(['--csp', Flags.disableInlining, ...options], verbose: verbose);
|
||||
TestResult result = new TestResult(config, filename, processor);
|
||||
for (SourceMapInfo info in sourceMaps.elementSourceMapInfos.values) {
|
||||
if (info.element.library.canonicalUri.scheme == 'dart') continue;
|
||||
if (info.element.library.canonicalUri.isScheme('dart')) continue;
|
||||
result.userInfoList.add(info);
|
||||
Iterable<CodePoint> missingCodePoints =
|
||||
info.codePoints.where((c) => c.isMissing);
|
||||
|
|
|
@ -638,7 +638,7 @@ Future<void> resolveScripts(Options options) async {
|
|||
String sourceUriOrPath, String relativeSnapshotPath) async {
|
||||
Uri sourceUri = sdkRoot.resolve(sourceUriOrPath);
|
||||
String result =
|
||||
sourceUri.scheme == 'file' ? sourceUri.toFilePath() : sourceUriOrPath;
|
||||
sourceUri.isScheme('file') ? sourceUri.toFilePath() : sourceUriOrPath;
|
||||
if (_options.useSdk) {
|
||||
String snapshot = Uri.file(Platform.resolvedExecutable)
|
||||
.resolve(relativeSnapshotPath)
|
||||
|
|
|
@ -64,7 +64,7 @@ _showLayout(String file) async {
|
|||
print(' contains:');
|
||||
map.forEach((lib, elements) {
|
||||
var uri = lib.uri;
|
||||
var shortUri = (uri.scheme == 'file' && uri.path.startsWith(dir))
|
||||
var shortUri = (uri.isScheme('file') && uri.path.startsWith(dir))
|
||||
? uri.path.substring(dir.length + 1)
|
||||
: '$uri';
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ LibraryInfo _getLibraryOf(Info info) {
|
|||
return current;
|
||||
}
|
||||
|
||||
bool _isPackageUri(Uri uri) => uri.scheme == 'package';
|
||||
bool _isPackageUri(Uri uri) => uri.isScheme('package');
|
||||
|
||||
String _getPackageName(Uri uri) {
|
||||
assert(_isPackageUri(uri));
|
||||
|
|
|
@ -116,7 +116,7 @@ String packageName(Info info) {
|
|||
info = info.parent;
|
||||
}
|
||||
if (info is LibraryInfo) {
|
||||
if (info.uri.scheme == 'package') {
|
||||
if (info.uri.isScheme('package')) {
|
||||
return '${info.uri}'.split('/').first;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ String deobfuscateStackTrace(String obfuscatedTrace) {
|
|||
var provider = CachingFileProvider();
|
||||
StackDeobfuscationResult result = deobfuscateStack(obfuscatedTrace, provider);
|
||||
Frame firstFrame = result.original.frames.first;
|
||||
String translatedError = (firstFrame.uri.scheme == 'error'
|
||||
String translatedError = (firstFrame.uri.isScheme('error')
|
||||
? null
|
||||
: translate(error, provider.mappingFor(firstFrame.uri))) ??
|
||||
'<no error message found>';
|
||||
|
|
|
@ -34,7 +34,7 @@ class CachingFileProvider implements FileProvider {
|
|||
/// deobfuscation locally for debugging purposes.
|
||||
class DownloadedFileProvider extends CachingFileProvider {
|
||||
_localize(uri) {
|
||||
if (uri.scheme == 'http' || uri.scheme == 'https') {
|
||||
if (uri.isScheme('http') || uri.isScheme('https')) {
|
||||
String filename = uri.path.substring(uri.path.lastIndexOf('/') + 1);
|
||||
return Uri.base.resolve(filename);
|
||||
}
|
||||
|
|
|
@ -46,13 +46,13 @@ abstract class DartDevelopmentService {
|
|||
DevToolsConfiguration? devToolsConfiguration,
|
||||
bool logRequests = false,
|
||||
}) async {
|
||||
if (remoteVmServiceUri.scheme != 'http') {
|
||||
if (!remoteVmServiceUri.isScheme('http')) {
|
||||
throw ArgumentError(
|
||||
'remoteVmServiceUri must have an HTTP scheme. Actual: ${remoteVmServiceUri.scheme}',
|
||||
);
|
||||
}
|
||||
if (serviceUri != null) {
|
||||
if (serviceUri.scheme != 'http') {
|
||||
if (!serviceUri.isScheme('http')) {
|
||||
throw ArgumentError(
|
||||
'serviceUri must have an HTTP scheme. Actual: ${serviceUri.scheme}',
|
||||
);
|
||||
|
|
|
@ -460,11 +460,11 @@ class AmdModuleBuilder extends _ModuleBuilder {
|
|||
}
|
||||
|
||||
bool isSdkInternalRuntimeUri(Uri importUri) {
|
||||
return importUri.scheme == 'dart' && importUri.path == '_runtime';
|
||||
return importUri.isScheme('dart') && importUri.path == '_runtime';
|
||||
}
|
||||
|
||||
String libraryUriToJsIdentifier(Uri importUri) {
|
||||
if (importUri.scheme == 'dart') {
|
||||
if (importUri.isScheme('dart')) {
|
||||
return isSdkInternalRuntimeUri(importUri) ? 'dart' : importUri.path;
|
||||
}
|
||||
return pathToJSIdentifier(p.withoutExtension(importUri.pathSegments.last));
|
||||
|
|
|
@ -347,7 +347,7 @@ Uri sourcePathToUri(String source, {bool windows}) {
|
|||
|
||||
Uri sourcePathToRelativeUri(String source, {bool windows}) {
|
||||
var uri = sourcePathToUri(source, windows: windows);
|
||||
if (uri.scheme == 'file') {
|
||||
if (uri.isScheme('file')) {
|
||||
var uriPath = uri.path;
|
||||
var root = Uri.base.path;
|
||||
if (uriPath.startsWith(root)) {
|
||||
|
@ -400,7 +400,7 @@ Map placeSourceMap(Map sourceMap, String sourceMapPath, String multiRootScheme,
|
|||
return sourcePath;
|
||||
}
|
||||
|
||||
if (uri.scheme == 'http') return sourcePath;
|
||||
if (uri.isScheme('http')) return sourcePath;
|
||||
|
||||
// Convert to a local file path if it's not.
|
||||
sourcePath = sourcePathToUri(p.absolute(p.fromUri(uri))).path;
|
||||
|
|
|
@ -32,7 +32,7 @@ class AssetFileSystem implements FileSystem {
|
|||
|
||||
@override
|
||||
FileSystemEntity entityForUri(Uri uri) {
|
||||
if (uri.scheme == 'file') {
|
||||
if (uri.isScheme('file')) {
|
||||
return original.entityForUri(uri);
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ Future<CompilerResult> _compile(List<String> args,
|
|||
options.multiRootScheme, multiRootPaths, fe.StandardFileSystem.instance);
|
||||
|
||||
Uri toCustomUri(Uri uri) {
|
||||
if (uri.scheme == '') {
|
||||
if (!uri.hasScheme) {
|
||||
return Uri(scheme: options.multiRootScheme, path: '/' + uri.path);
|
||||
}
|
||||
return uri;
|
||||
|
@ -486,7 +486,7 @@ Future<CompilerResult> _compile(List<String> args,
|
|||
compilerState.incrementalCompiler.updateNeededDillLibrariesWithHierarchy(
|
||||
neededDillLibraries, result.classHierarchy);
|
||||
for (var lib in neededDillLibraries) {
|
||||
if (lib.importUri.scheme == 'dart') continue;
|
||||
if (lib.importUri.isScheme('dart')) continue;
|
||||
var uri = compilerState.libraryToInputDill[lib.importUri];
|
||||
if (uri == null) {
|
||||
throw StateError('Library ${lib.importUri} was recorded as used, '
|
||||
|
@ -552,7 +552,7 @@ Future<CompilerResult> compileSdkFromDill(List<String> args) async {
|
|||
var component = loadComponentFromBinary(inputs.single);
|
||||
var invalidLibraries = <Uri>[];
|
||||
for (var library in component.libraries) {
|
||||
if (library.importUri.scheme != 'dart') {
|
||||
if (!library.importUri.isScheme('dart')) {
|
||||
invalidLibraries.add(library.importUri);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -496,10 +496,10 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
|||
@override
|
||||
String jsLibraryAlias(Library library) {
|
||||
var uri = library.importUri.normalizePath();
|
||||
if (uri.scheme == 'dart') return null;
|
||||
if (uri.isScheme('dart')) return null;
|
||||
|
||||
Iterable<String> segments;
|
||||
if (uri.scheme == 'package') {
|
||||
if (uri.isScheme('package')) {
|
||||
// Strip the package name.
|
||||
segments = uri.pathSegments.skip(1);
|
||||
} else {
|
||||
|
@ -521,7 +521,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
|||
/// True when [library] is the sdk internal library 'dart:_internal'.
|
||||
bool _isDartInternal(Library library) {
|
||||
var importUri = library.importUri;
|
||||
return importUri.scheme == 'dart' && importUri.path == '_internal';
|
||||
return importUri.isScheme('dart') && importUri.path == '_internal';
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -531,7 +531,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
|||
|
||||
@override
|
||||
String libraryToModule(Library library) {
|
||||
if (library.importUri.scheme == 'dart') {
|
||||
if (library.importUri.isScheme('dart')) {
|
||||
// TODO(jmesserly): we need to split out HTML.
|
||||
return js_ast.dartSdkModule;
|
||||
}
|
||||
|
@ -1940,7 +1940,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
|||
|
||||
bool _isForwardingStub(Procedure member) {
|
||||
if (member.isForwardingStub || member.isForwardingSemiStub) {
|
||||
if (_currentLibrary.importUri.scheme != 'dart') return true;
|
||||
if (!_currentLibrary.importUri.isScheme('dart')) return true;
|
||||
// TODO(jmesserly): external methods in the SDK seem to get incorrectly
|
||||
// tagged as forwarding stubs even if they are patched. Perhaps there is
|
||||
// an ordering issue in CFE. So for now we pattern match to see if it
|
||||
|
@ -2254,7 +2254,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
|||
_hierarchy.getClassAsInstanceOf(c.superclass, _coreTypes.iterableClass);
|
||||
if (parentIterable != null) return null;
|
||||
|
||||
if (c.enclosingLibrary.importUri.scheme == 'dart' &&
|
||||
if (c.enclosingLibrary.importUri.isScheme('dart') &&
|
||||
c.procedures.any((m) => _jsExportName(m) == 'Symbol.iterator')) {
|
||||
return null;
|
||||
}
|
||||
|
@ -2764,7 +2764,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
|||
var fn = _emitFunction(p.function, p.name.text)
|
||||
..sourceInformation = _nodeEnd(p.fileEndOffset);
|
||||
|
||||
if (_currentLibrary.importUri.scheme == 'dart' &&
|
||||
if (_currentLibrary.importUri.isScheme('dart') &&
|
||||
_isInlineJSFunction(p.function.body)) {
|
||||
fn = js_ast.simplifyPassThroughArrowFunCallBody(fn);
|
||||
}
|
||||
|
@ -3737,7 +3737,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
|||
|
||||
bool _reifyGenericFunction(Member m) =>
|
||||
m == null ||
|
||||
m.enclosingLibrary.importUri.scheme != 'dart' ||
|
||||
!m.enclosingLibrary.importUri.isScheme('dart') ||
|
||||
!m.annotations
|
||||
.any((a) => isBuiltinAnnotation(a, '_js_helper', 'NoReifyGeneric'));
|
||||
|
||||
|
@ -5692,7 +5692,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
|||
|
||||
bool _isWebLibrary(Uri importUri) =>
|
||||
importUri != null &&
|
||||
importUri.scheme == 'dart' &&
|
||||
importUri.isScheme('dart') &&
|
||||
(importUri.path == 'html' ||
|
||||
importUri.path == 'svg' ||
|
||||
importUri.path == 'indexed_db' ||
|
||||
|
@ -5792,7 +5792,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
|||
|
||||
if (args.positional.isEmpty &&
|
||||
args.named.isEmpty &&
|
||||
ctorClass.enclosingLibrary.importUri.scheme == 'dart') {
|
||||
ctorClass.enclosingLibrary.importUri.isScheme('dart')) {
|
||||
// Skip the slow SDK factory constructors when possible.
|
||||
switch (ctorClass.name) {
|
||||
case 'Map':
|
||||
|
@ -6308,7 +6308,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
|||
]);
|
||||
|
||||
bool _reifyFunctionType(FunctionNode f) {
|
||||
if (_currentLibrary.importUri.scheme != 'dart') return true;
|
||||
if (!_currentLibrary.importUri.isScheme('dart')) return true;
|
||||
var parent = f.parent;
|
||||
|
||||
// SDK libraries can skip reification if they request it.
|
||||
|
@ -6337,7 +6337,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
|||
/// under which functions are compiled and exported.
|
||||
String _jsExportName(NamedNode n) {
|
||||
var library = getLibrary(n);
|
||||
if (library == null || library.importUri.scheme != 'dart') return null;
|
||||
if (library == null || !library.importUri.isScheme('dart')) return null;
|
||||
|
||||
return _annotationName(n, isJSExportNameAnnotation);
|
||||
}
|
||||
|
@ -6363,7 +6363,7 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
|
|||
js_ast.Expression visitConstant(Constant node) {
|
||||
if (node is StaticTearOffConstant) {
|
||||
// JS() or external JS consts should not be lazily loaded.
|
||||
var isSdk = node.target.enclosingLibrary.importUri.scheme == 'dart';
|
||||
var isSdk = node.target.enclosingLibrary.importUri.isScheme('dart');
|
||||
if (_isInForeignJS) {
|
||||
return _emitStaticTarget(node.target);
|
||||
}
|
||||
|
|
|
@ -299,7 +299,7 @@ class ExpressionCompilerWorker {
|
|||
var libraryUri = Uri.parse(request.libraryUri);
|
||||
var moduleName = request.moduleName;
|
||||
|
||||
if (libraryUri.scheme == 'dart') {
|
||||
if (libraryUri.isScheme('dart')) {
|
||||
// compiling expressions inside the SDK currently fails because
|
||||
// SDK kernel outlines do not contain information that is needed
|
||||
// to detect the scope for expression evaluation - such as local
|
||||
|
@ -329,7 +329,7 @@ class ExpressionCompilerWorker {
|
|||
var originalComponent = _moduleCache.componentForModuleName[moduleName];
|
||||
|
||||
var component = _sdkComponent;
|
||||
if (libraryUri.scheme != 'dart') {
|
||||
if (!libraryUri.isScheme('dart')) {
|
||||
_processedOptions.ticker.logMs('Collecting libraries for $moduleName');
|
||||
|
||||
var libraries =
|
||||
|
|
|
@ -92,7 +92,7 @@ bool isBuiltinAnnotation(
|
|||
var c = getAnnotationClass(value);
|
||||
if (c != null && c.name == className) {
|
||||
var uri = c.enclosingLibrary.importUri;
|
||||
return uri.scheme == 'dart' && uri.path == libraryName;
|
||||
return uri.isScheme('dart') && uri.path == libraryName;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ bool isCovariantField(Field f) {
|
|||
///
|
||||
/// `dart:html` has many of these.
|
||||
bool isUnsupportedFactoryConstructor(Procedure node) {
|
||||
if (node.name.isPrivate && node.enclosingLibrary.importUri.scheme == 'dart') {
|
||||
if (node.name.isPrivate && node.enclosingLibrary.importUri.isScheme('dart')) {
|
||||
var body = node.function.body;
|
||||
if (body is Block) {
|
||||
var statements = body.statements;
|
||||
|
@ -365,4 +365,4 @@ bool _isNativeMarkerAnnotation(Expression annotation) {
|
|||
}
|
||||
|
||||
bool _isDartInternal(Uri uri) =>
|
||||
uri.scheme == 'dart' && uri.path == '_internal';
|
||||
uri.isScheme('dart') && uri.path == '_internal';
|
||||
|
|
|
@ -170,5 +170,5 @@ bool _isNativeAnnotation(Expression annotation) {
|
|||
var c = getAnnotationClass(annotation);
|
||||
return c != null &&
|
||||
(c.name == 'Native' || c.name == 'JsPeerInterface') &&
|
||||
c.enclosingLibrary.importUri.scheme == 'dart';
|
||||
c.enclosingLibrary.importUri.isScheme('dart');
|
||||
}
|
||||
|
|
|
@ -338,9 +338,9 @@ class NullableInference extends ExpressionVisitor<bool> {
|
|||
|
||||
bool _isInternalSdkAnnotation(Library library) {
|
||||
var uri = library.importUri;
|
||||
return uri.scheme == 'dart' && uri.pathSegments[0] == '_js_helper' ||
|
||||
return uri.isScheme('dart') && uri.pathSegments[0] == '_js_helper' ||
|
||||
allowPackageMetaAnnotations &&
|
||||
uri.scheme == 'package' &&
|
||||
uri.isScheme('package') &&
|
||||
uri.pathSegments[0] == 'meta';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,11 +120,11 @@ class DevCompilerTarget extends Target {
|
|||
/// test framework.
|
||||
bool _allowedTestLibrary(Uri uri) {
|
||||
// Multi-root scheme used by modular test framework.
|
||||
if (uri.scheme == 'dev-dart-app') return true;
|
||||
if (uri.isScheme('dev-dart-app')) return true;
|
||||
return allowedNativeTest(uri);
|
||||
}
|
||||
|
||||
bool _allowedDartLibrary(Uri uri) => uri.scheme == 'dart';
|
||||
bool _allowedDartLibrary(Uri uri) => uri.isScheme('dart');
|
||||
|
||||
@override
|
||||
bool enableNative(Uri uri) =>
|
||||
|
|
|
@ -42,7 +42,7 @@ class Module {
|
|||
|
||||
Module(this.importUri, this.fileUri)
|
||||
: name = libraryUriToJsIdentifier(importUri),
|
||||
path = importUri.scheme == 'package'
|
||||
path = importUri.isScheme('package')
|
||||
? 'packages/${importUri.path}'
|
||||
: importUri.path;
|
||||
|
||||
|
|
|
@ -568,7 +568,7 @@ class _TestRecursiveVisitor extends RecursiveVisitor {
|
|||
void visitLibrary(Library node) {
|
||||
_staticTypeContext.enterLibrary(node);
|
||||
if (librariesFromDill.contains(node) ||
|
||||
node.importUri.scheme == 'package' &&
|
||||
node.importUri.isScheme('package') &&
|
||||
node.importUri.pathSegments[0] == 'meta') {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -93,9 +93,9 @@ bool isExperimentEnabledInLibrary(ExperimentalFlag flag, Uri canonicalUri,
|
|||
if (!enabled!) {
|
||||
allowedExperimentalFlags ??= defaultAllowedExperimentalFlags;
|
||||
Set<ExperimentalFlag>? allowedFlags;
|
||||
if (canonicalUri.scheme == 'dart') {
|
||||
if (canonicalUri.isScheme('dart')) {
|
||||
allowedFlags = allowedExperimentalFlags.forSdkLibrary(canonicalUri.path);
|
||||
} else if (canonicalUri.scheme == 'package') {
|
||||
} else if (canonicalUri.isScheme('package')) {
|
||||
int index = canonicalUri.path.indexOf('/');
|
||||
String packageName;
|
||||
if (index >= 0) {
|
||||
|
@ -123,9 +123,9 @@ Version getExperimentEnabledVersionInLibrary(ExperimentalFlag flag,
|
|||
allowedExperimentalFlags ??= defaultAllowedExperimentalFlags;
|
||||
|
||||
Set<ExperimentalFlag>? allowedFlags;
|
||||
if (canonicalUri.scheme == 'dart') {
|
||||
if (canonicalUri.isScheme('dart')) {
|
||||
allowedFlags = allowedExperimentalFlags.forSdkLibrary(canonicalUri.path);
|
||||
} else if (canonicalUri.scheme == 'package') {
|
||||
} else if (canonicalUri.isScheme('package')) {
|
||||
int index = canonicalUri.path.indexOf('/');
|
||||
String packageName;
|
||||
if (index >= 0) {
|
||||
|
@ -187,9 +187,9 @@ bool isExperimentEnabledInLibraryByVersion(
|
|||
|
||||
Set<ExperimentalFlag>? allowedFlags;
|
||||
bool enabledByAllowed = false;
|
||||
if (canonicalUri.scheme == 'dart') {
|
||||
if (canonicalUri.isScheme('dart')) {
|
||||
allowedFlags = allowedExperimentalFlags.forSdkLibrary(canonicalUri.path);
|
||||
} else if (canonicalUri.scheme == 'package') {
|
||||
} else if (canonicalUri.isScheme('package')) {
|
||||
int index = canonicalUri.path.indexOf('/');
|
||||
String packageName;
|
||||
if (index >= 0) {
|
||||
|
|
|
@ -57,7 +57,7 @@ Future<VersionAndPackageUri> languageVersionForUri(
|
|||
UriTranslator uriTranslator = await context.options.getUriTranslator();
|
||||
Uri? fileUri;
|
||||
Package? package;
|
||||
if (uri.scheme == "package") {
|
||||
if (uri.isScheme("package")) {
|
||||
fileUri = uriTranslator.translate(uri);
|
||||
package = uriTranslator.getPackage(uri);
|
||||
} else {
|
||||
|
@ -65,8 +65,8 @@ Future<VersionAndPackageUri> languageVersionForUri(
|
|||
package = uriTranslator.packages.packageOf(uri);
|
||||
}
|
||||
Uri packageUri = uri;
|
||||
if (packageUri.scheme != 'dart' &&
|
||||
packageUri.scheme != 'package' &&
|
||||
if (!packageUri.isScheme('dart') &&
|
||||
!packageUri.isScheme('package') &&
|
||||
package != null &&
|
||||
// ignore: unnecessary_null_comparison
|
||||
package.name != null) {
|
||||
|
|
|
@ -23,12 +23,12 @@ class StandardFileSystem implements FileSystem {
|
|||
|
||||
@override
|
||||
FileSystemEntity entityForUri(Uri uri) {
|
||||
if (uri.scheme == 'file') {
|
||||
if (uri.isScheme('file')) {
|
||||
return new _IoFileSystemEntity(uri);
|
||||
} else if (uri.scheme == '') {
|
||||
} else if (!uri.hasScheme) {
|
||||
// TODO(askesc): Empty schemes should have been handled elsewhere.
|
||||
return new _IoFileSystemEntity(Uri.base.resolveUri(uri));
|
||||
} else if (uri.scheme == 'data') {
|
||||
} else if (uri.isScheme('data')) {
|
||||
return new DataFileSystemEntity(Uri.base.resolveUri(uri));
|
||||
} else {
|
||||
throw new FileSystemException(
|
||||
|
@ -125,7 +125,7 @@ class DataFileSystemEntity implements FileSystemEntity {
|
|||
final Uri uri;
|
||||
|
||||
DataFileSystemEntity(this.uri)
|
||||
: assert(uri.scheme == 'data'),
|
||||
: assert(uri.isScheme('data')),
|
||||
assert(uri.data != null);
|
||||
|
||||
@override
|
||||
|
|
|
@ -563,7 +563,7 @@ class ProcessedOptions {
|
|||
}
|
||||
|
||||
// When compiling the SDK the input files are normally `dart:` URIs.
|
||||
if (inputs.every((uri) => uri.scheme == 'dart')) {
|
||||
if (inputs.every((uri) => uri.isScheme('dart'))) {
|
||||
return _packages = PackageConfig.empty;
|
||||
}
|
||||
|
||||
|
@ -577,7 +577,7 @@ class ProcessedOptions {
|
|||
|
||||
Uri input = inputs.first;
|
||||
|
||||
if (input.scheme == 'package') {
|
||||
if (input.isScheme('package')) {
|
||||
report(
|
||||
messageCantInferPackagesFromPackageUri.withLocation(
|
||||
input, -1, noLength),
|
||||
|
|
|
@ -95,7 +95,7 @@ Uri computePlatformBinariesLocation({bool forceBuildDir: false}) {
|
|||
/// Translates an SDK URI ("org-dartlang-sdk:///...") to a file URI.
|
||||
Uri translateSdk(Uri uri) {
|
||||
if (CompilerContext.isActive) {
|
||||
if (uri.scheme == "org-dartlang-sdk") {
|
||||
if (uri.isScheme("org-dartlang-sdk")) {
|
||||
String path = uri.path;
|
||||
if (path.startsWith("/sdk/")) {
|
||||
CompilerContext context = CompilerContext.current;
|
||||
|
@ -148,7 +148,7 @@ Uri translateSdk(Uri uri) {
|
|||
}
|
||||
|
||||
bool isExistingFile(Uri uri) {
|
||||
if (uri.scheme == "file") {
|
||||
if (uri.isScheme("file")) {
|
||||
return new File.fromUri(uri).existsSync();
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -326,7 +326,7 @@ abstract class ClassBuilderImpl extends DeclarationBuilderImpl
|
|||
}
|
||||
if (name == "FutureOr") {
|
||||
LibraryBuilder parentLibrary = parent as LibraryBuilder;
|
||||
if (parentLibrary.importUri.scheme == "dart" &&
|
||||
if (parentLibrary.importUri.isScheme("dart") &&
|
||||
parentLibrary.importUri.path == "async") {
|
||||
assert(arguments != null && arguments.length == 1);
|
||||
return new FutureOrType(arguments!.single, nullability);
|
||||
|
|
|
@ -86,7 +86,7 @@ class CompilerContext {
|
|||
}
|
||||
|
||||
static void recordDependency(Uri uri) {
|
||||
if (uri.scheme != "file" && uri.scheme != "http") {
|
||||
if (!uri.isScheme("file") && !uri.isScheme("http")) {
|
||||
throw new ArgumentError("Expected a file or http URI, but got: '$uri'.");
|
||||
}
|
||||
CompilerContext? context = Zone.current[compilerContextKey];
|
||||
|
|
|
@ -120,7 +120,7 @@ class DillLoader extends Loader {
|
|||
assert(libraryBuilder != null, "No library found for $uri.");
|
||||
_builders[uri] = libraryBuilder!;
|
||||
assert(libraryBuilder.loader == this);
|
||||
if (uri.scheme == "dart") {
|
||||
if (uri.isScheme("dart")) {
|
||||
if (uri.path == "core") {
|
||||
_coreLibrary = libraryBuilder;
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ severity: $severity
|
|||
void registerLibraryBuilder(DillLibraryBuilder libraryBuilder) {
|
||||
Uri importUri = libraryBuilder.importUri;
|
||||
libraryBuilder.loader = this;
|
||||
if (importUri.scheme == "dart" && importUri.path == "core") {
|
||||
if (importUri.isScheme("dart") && importUri.path == "core") {
|
||||
_coreLibrary = libraryBuilder;
|
||||
}
|
||||
_builders[importUri] = libraryBuilder;
|
||||
|
|
|
@ -37,7 +37,7 @@ class HybridFileSystemEntity implements FileSystemEntity {
|
|||
Future<FileSystemEntity> get delegate async {
|
||||
if (_delegate != null) return _delegate!;
|
||||
FileSystemEntity entity = _fs.memory.entityForUri(uri);
|
||||
if (((uri.scheme != 'file' && uri.scheme != 'data') &&
|
||||
if (((!uri.isScheme('file') && !uri.isScheme('data')) &&
|
||||
_fs.physical is StandardFileSystem) ||
|
||||
await entity.exists()) {
|
||||
_delegate = entity;
|
||||
|
|
|
@ -1272,7 +1272,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
|||
_platformBuilders = <LibraryBuilder>[];
|
||||
for (DillLibraryBuilder builder
|
||||
in dillLoadedData.loader.libraryBuilders) {
|
||||
if (builder.importUri.scheme == "dart") {
|
||||
if (builder.importUri.isScheme("dart")) {
|
||||
_platformBuilders!.add(builder);
|
||||
} else {
|
||||
_userBuilders![builder.importUri] = builder;
|
||||
|
@ -1425,7 +1425,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
|||
_platformBuilders = <LibraryBuilder>[];
|
||||
for (DillLibraryBuilder builder
|
||||
in _dillLoadedData!.loader.libraryBuilders) {
|
||||
if (builder.importUri.scheme == "dart") {
|
||||
if (builder.importUri.isScheme("dart")) {
|
||||
_platformBuilders!.add(builder);
|
||||
} else {
|
||||
_userBuilders![builder.importUri] = builder;
|
||||
|
@ -1492,7 +1492,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
|||
partUriToLibraryImportUri[partUri] = library.importUri;
|
||||
}
|
||||
}
|
||||
if (library.importUri.scheme == "dart") {
|
||||
if (library.importUri.isScheme("dart")) {
|
||||
result.add(library);
|
||||
inputLibrariesFiltered?.add(library);
|
||||
} else {
|
||||
|
@ -1501,7 +1501,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
|||
}
|
||||
}
|
||||
for (LibraryBuilder libraryBuilder in reusedLibraries) {
|
||||
if (libraryBuilder.importUri.scheme == "dart" &&
|
||||
if (libraryBuilder.importUri.isScheme("dart") &&
|
||||
!libraryBuilder.isSynthetic) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1550,7 +1550,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
|||
List<Library> removedLibraries = <Library>[];
|
||||
bool removedDillBuilders = false;
|
||||
for (Uri uri in potentiallyReferencedLibraries.keys) {
|
||||
if (uri.scheme == "package") continue;
|
||||
if (uri.isScheme("package")) continue;
|
||||
LibraryBuilder? builder =
|
||||
currentKernelTarget.loader.deregisterLibraryBuilder(uri);
|
||||
if (builder != null) {
|
||||
|
@ -1913,7 +1913,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
|||
if (importUri != fileUri && invalidatedUris.contains(fileUri)) {
|
||||
return true;
|
||||
}
|
||||
if (_hasToCheckPackageUris && importUri.scheme == "package") {
|
||||
if (_hasToCheckPackageUris && importUri.isScheme("package")) {
|
||||
// Get package name, check if the base URI has changed for the package,
|
||||
// if it has, translate the URI again,
|
||||
// otherwise the URI cannot have changed.
|
||||
|
@ -1935,7 +1935,7 @@ class IncrementalCompiler implements IncrementalKernelGenerator {
|
|||
}
|
||||
|
||||
void addBuilderAndInvalidateUris(Uri uri, LibraryBuilder libraryBuilder) {
|
||||
if (uri.scheme == "dart" && !libraryBuilder.isSynthetic) {
|
||||
if (uri.isScheme("dart") && !libraryBuilder.isSynthetic) {
|
||||
if (seenUris.add(libraryBuilder.importUri)) {
|
||||
reusedLibraries.add(libraryBuilder);
|
||||
}
|
||||
|
@ -2355,7 +2355,7 @@ class _InitializationFromComponent extends _InitializationStrategy {
|
|||
bool foundDartCore = false;
|
||||
for (int i = 0; i < component.libraries.length; i++) {
|
||||
Library library = component.libraries[i];
|
||||
if (library.importUri.scheme == "dart" &&
|
||||
if (library.importUri.isScheme("dart") &&
|
||||
library.importUri.path == "core") {
|
||||
foundDartCore = true;
|
||||
break;
|
||||
|
@ -2501,7 +2501,7 @@ class _InitializationFromUri extends _InitializationFromSdkSummary {
|
|||
// (e.g. the package still exists and hasn't been updated).
|
||||
// Also verify NNBD settings.
|
||||
for (Library lib in data.component!.libraries) {
|
||||
if (lib.importUri.scheme == "package" &&
|
||||
if (lib.importUri.isScheme("package") &&
|
||||
uriTranslator.translate(lib.importUri, false) != lib.fileUri) {
|
||||
// Package has been removed or updated.
|
||||
// This library should be thrown away.
|
||||
|
@ -2649,7 +2649,7 @@ class _ComponentProblems {
|
|||
extension on UriTranslator {
|
||||
Uri? getPartFileUri(Uri parentFileUri, LibraryPart part) {
|
||||
Uri? fileUri = getPartUri(parentFileUri, part);
|
||||
if (fileUri.scheme == "package") {
|
||||
if (fileUri.isScheme("package")) {
|
||||
// Part was specified via package URI and the resolve above thus
|
||||
// did not go as expected. Translate the package URI to get the
|
||||
// actual file URI.
|
||||
|
|
|
@ -43,7 +43,7 @@ class IncrementalSerializer {
|
|||
Uri uri = lib.importUri;
|
||||
// Uris need to be unique.
|
||||
if (!uris.add(lib.fileUri)) return false;
|
||||
if (uri.scheme == "package") {
|
||||
if (uri.isScheme("package")) {
|
||||
String thisPackageName = uri.pathSegments.first;
|
||||
if (packageName == null) {
|
||||
packageName = thisPackageName;
|
||||
|
@ -117,7 +117,7 @@ class IncrementalSerializer {
|
|||
List<Library> nonPackageLibraries = <Library>[];
|
||||
for (Library lib in component.libraries) {
|
||||
Uri uri = lib.importUri;
|
||||
if (uri.scheme == "package") {
|
||||
if (uri.isScheme("package")) {
|
||||
packageLibraries.add(lib);
|
||||
} else {
|
||||
nonPackageLibraries.add(lib);
|
||||
|
@ -179,7 +179,7 @@ class IncrementalSerializer {
|
|||
for (Library lib in component.libraries) {
|
||||
for (LibraryDependency dependency in lib.dependencies) {
|
||||
if (!got.contains(dependency.targetLibrary)) {
|
||||
if (dependency.targetLibrary.importUri.scheme == "dart") {
|
||||
if (dependency.targetLibrary.importUri.isScheme("dart")) {
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
|
@ -241,7 +241,7 @@ class IncrementalSerializer {
|
|||
for (Library lib in libraries) {
|
||||
for (LibraryDependency dep in lib.dependencies) {
|
||||
Library dependencyLibrary = dep.importedLibraryReference.asLibrary;
|
||||
if (dependencyLibrary.importUri.scheme != "package") continue;
|
||||
if (!dependencyLibrary.importUri.isScheme("package")) continue;
|
||||
Uri dependencyLibraryUri =
|
||||
dep.importedLibraryReference.asLibrary.fileUri;
|
||||
SerializationGroup? depGroup = uriToGroup[dependencyLibraryUri];
|
||||
|
|
|
@ -355,7 +355,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
|
|||
stringExpectedAfterNative = libraryBuilder
|
||||
.loader.target.backendTarget.nativeExtensionExpectsString,
|
||||
ignoreMainInGetMainClosure =
|
||||
libraryBuilder.importUri.scheme == 'dart' &&
|
||||
libraryBuilder.importUri.isScheme('dart') &&
|
||||
(libraryBuilder.importUri.path == "_builtin" ||
|
||||
libraryBuilder.importUri.path == "ui"),
|
||||
needsImplicitSuperInitializer =
|
||||
|
|
|
@ -965,7 +965,7 @@ class ConstantEvaluator implements ExpressionVisitor<Constant> {
|
|||
Map<String, String> _computeSupportedLibraries() {
|
||||
Map<String, String> map = {};
|
||||
for (Library library in component.libraries) {
|
||||
if (library.importUri.scheme == 'dart') {
|
||||
if (library.importUri.isScheme('dart')) {
|
||||
map[library.importUri.path] =
|
||||
DartLibrarySupport.getDartLibrarySupportValue(
|
||||
library.importUri.path,
|
||||
|
|
|
@ -1667,7 +1667,7 @@ class KernelTarget extends TargetImplementation {
|
|||
}
|
||||
|
||||
void readPatchFiles(SourceLibraryBuilder library) {
|
||||
assert(library.importUri.scheme == "dart");
|
||||
assert(library.importUri.isScheme("dart"));
|
||||
List<Uri>? patches = uriTranslator.getDartPatches(library.importUri.path);
|
||||
if (patches != null) {
|
||||
SourceLibraryBuilder? first;
|
||||
|
|
|
@ -66,7 +66,7 @@ class TypeLabeler implements DartTypeVisitor<void>, ConstantVisitor<void> {
|
|||
static bool isObject(DartType type) {
|
||||
if (type is InterfaceType && type.classNode.name == 'Object') {
|
||||
Uri importUri = type.classNode.enclosingLibrary.importUri;
|
||||
return importUri.scheme == 'dart' && importUri.path == 'core';
|
||||
return importUri.isScheme('dart') && importUri.path == 'core';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ class LabeledNode {
|
|||
}
|
||||
|
||||
String get originMessage {
|
||||
if (importUri.scheme == 'dart' && importUri.path == 'core') {
|
||||
if (importUri.isScheme('dart') && importUri.path == 'core') {
|
||||
if (node is Class && denylistedCoreClasses.contains(name)) {
|
||||
// Denylisted core class. Only print if ambiguous.
|
||||
List<LabeledNode> entityForName = typeLabeler.nameMap[name]!;
|
||||
|
@ -521,7 +521,7 @@ class LabeledNode {
|
|||
return "";
|
||||
}
|
||||
}
|
||||
Message message = (importUri == fileUri || importUri.scheme == 'dart')
|
||||
Message message = (importUri == fileUri || importUri.isScheme('dart'))
|
||||
? templateTypeOrigin.withArguments(toString(), importUri)
|
||||
: templateTypeOriginWithFileUri.withArguments(
|
||||
toString(), importUri, fileUri);
|
||||
|
|
|
@ -241,7 +241,7 @@ class FastaVerifyingVisitor extends VerifyingVisitor {
|
|||
// 'dart:test' is used in the unit tests and isn't an actual part of the
|
||||
// platform.
|
||||
if (skipPlatform &&
|
||||
node.importUri.scheme == 'dart' &&
|
||||
node.importUri.isScheme('dart') &&
|
||||
node.importUri.path != 'test') {
|
||||
return;
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ class FastaVerifyingVisitor extends VerifyingVisitor {
|
|||
|
||||
bool isObjectClass(Class c) {
|
||||
return c.name == "Object" &&
|
||||
c.enclosingLibrary.importUri.scheme == "dart" &&
|
||||
c.enclosingLibrary.importUri.isScheme("dart") &&
|
||||
c.enclosingLibrary.importUri.path == "core";
|
||||
}
|
||||
|
||||
|
@ -435,7 +435,7 @@ class FastaVerifyingVisitor extends VerifyingVisitor {
|
|||
}
|
||||
|
||||
void _checkConstructorTearOff(Node node, Member tearOffTarget) {
|
||||
if (tearOffTarget.enclosingLibrary.importUri.scheme == 'dart') {
|
||||
if (tearOffTarget.enclosingLibrary.importUri.isScheme('dart')) {
|
||||
// Platform libraries are not compilation with test flags and might
|
||||
// contain tear-offs not expected when testing lowerings.
|
||||
return;
|
||||
|
@ -540,7 +540,7 @@ class FastaVerifyGetStaticType extends VerifyGetStaticType {
|
|||
// 'dart:test' is used in the unit tests and isn't an actual part of the
|
||||
// platform.
|
||||
if (skipPlatform &&
|
||||
node.importUri.scheme == 'dart' &&
|
||||
node.importUri.isScheme('dart') &&
|
||||
node.importUri.path != "test") {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -714,7 +714,7 @@ class SourceClassBuilder extends ClassBuilderImpl
|
|||
this.charOffset,
|
||||
noLength);
|
||||
} else if (interface.cls.name == "FutureOr" &&
|
||||
interface.cls.enclosingLibrary.importUri.scheme == "dart" &&
|
||||
interface.cls.enclosingLibrary.importUri.isScheme("dart") &&
|
||||
interface.cls.enclosingLibrary.importUri.path == "async") {
|
||||
addProblem(messageImplementsFutureOr, this.charOffset, noLength);
|
||||
} else if (implemented.contains(interface)) {
|
||||
|
|
|
@ -289,12 +289,12 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
|||
new Scope.top()) {
|
||||
assert(
|
||||
_packageUri == null ||
|
||||
importUri.scheme != 'package' ||
|
||||
!importUri.isScheme('package') ||
|
||||
importUri.path.startsWith(_packageUri!.path),
|
||||
"Foreign package uri '$_packageUri' set on library with import uri "
|
||||
"'${importUri}'.");
|
||||
assert(
|
||||
importUri.scheme != 'dart' || _packageUri == null,
|
||||
!importUri.isScheme('dart') || _packageUri == null,
|
||||
"Package uri '$_packageUri' set on dart: library with import uri "
|
||||
"'${importUri}'.");
|
||||
}
|
||||
|
@ -638,7 +638,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
|||
return previous;
|
||||
}
|
||||
|
||||
bool uriIsValid(Uri uri) => uri.scheme != MALFORMED_URI_SCHEME;
|
||||
bool uriIsValid(Uri uri) => !uri.isScheme(MALFORMED_URI_SCHEME);
|
||||
|
||||
Uri resolve(Uri baseUri, String? uri, int uriOffset, {isPart: false}) {
|
||||
if (uri == null) {
|
||||
|
@ -657,7 +657,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
|||
return new Uri(
|
||||
scheme: MALFORMED_URI_SCHEME, query: Uri.encodeQueryComponent(uri));
|
||||
}
|
||||
if (isPart && baseUri.scheme == "dart") {
|
||||
if (isPart && baseUri.isScheme("dart")) {
|
||||
// Resolve using special rules for dart: URIs
|
||||
return resolveRelativeUri(baseUri, parsedUri);
|
||||
} else {
|
||||
|
@ -1668,7 +1668,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
|||
if (className != "Function") {
|
||||
return;
|
||||
}
|
||||
if (decType == "class" && importUri.scheme == "dart") {
|
||||
if (decType == "class" && importUri.isScheme("dart")) {
|
||||
// Allow declaration of class Function in the sdk.
|
||||
return;
|
||||
}
|
||||
|
@ -3158,9 +3158,9 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
|||
preferred = declaration;
|
||||
} else if (other is LoadLibraryBuilder) {
|
||||
preferred = other;
|
||||
} else if (otherUri.scheme == "dart" && uri.scheme != "dart") {
|
||||
} else if (otherUri.isScheme("dart") && !uri.isScheme("dart")) {
|
||||
preferred = declaration;
|
||||
} else if (uri.scheme == "dart" && otherUri.scheme != "dart") {
|
||||
} else if (uri.isScheme("dart") && !otherUri.isScheme("dart")) {
|
||||
preferred = other;
|
||||
}
|
||||
}
|
||||
|
@ -3901,7 +3901,7 @@ class SourceLibraryBuilder extends LibraryBuilderImpl {
|
|||
}
|
||||
|
||||
void exportMemberFromPatch(String name, Builder member) {
|
||||
if (importUri.scheme != "dart" || !importUri.path.startsWith("_")) {
|
||||
if (!importUri.isScheme("dart") || !importUri.path.startsWith("_")) {
|
||||
addProblem(templatePatchInjectionFailed.withArguments(name, importUri),
|
||||
member.charOffset, noLength, member.fileUri);
|
||||
}
|
||||
|
|
|
@ -265,7 +265,7 @@ class SourceLoader extends Loader {
|
|||
|
||||
void registerLibraryBuilder(LibraryBuilder libraryBuilder) {
|
||||
Uri uri = libraryBuilder.importUri;
|
||||
if (uri.scheme == "dart" && uri.path == "core") {
|
||||
if (uri.isScheme("dart") && uri.path == "core") {
|
||||
_coreLibrary = libraryBuilder;
|
||||
}
|
||||
_builders[uri] = libraryBuilder;
|
||||
|
@ -326,7 +326,7 @@ class SourceLoader extends Loader {
|
|||
referencesFrom: referencesFrom,
|
||||
referenceIsPartOwner: referenceIsPartOwner,
|
||||
isUnsupported: origin?.library.isUnsupported ??
|
||||
importUri.scheme == 'dart' &&
|
||||
importUri.isScheme('dart') &&
|
||||
!target.uriTranslator.isLibrarySupported(importUri.path));
|
||||
}
|
||||
|
||||
|
@ -359,9 +359,9 @@ class SourceLoader extends Loader {
|
|||
Library? referencesFrom,
|
||||
bool? referenceIsPartOwner) {
|
||||
if (fileUri != null &&
|
||||
(fileUri.scheme == "dart" ||
|
||||
fileUri.scheme == "package" ||
|
||||
fileUri.scheme == "dart-ext")) {
|
||||
(fileUri.isScheme("dart") ||
|
||||
fileUri.isScheme("package") ||
|
||||
fileUri.isScheme("dart-ext"))) {
|
||||
fileUri = null;
|
||||
}
|
||||
package_config.Package? packageForLanguageVersion;
|
||||
|
@ -373,7 +373,7 @@ class SourceLoader extends Loader {
|
|||
new Uri(
|
||||
scheme: untranslatableUriScheme,
|
||||
path: Uri.encodeComponent("$uri"));
|
||||
if (uri.scheme == "package") {
|
||||
if (uri.isScheme("package")) {
|
||||
packageForLanguageVersion = target.uriTranslator.getPackage(uri);
|
||||
} else {
|
||||
packageForLanguageVersion =
|
||||
|
@ -396,8 +396,8 @@ class SourceLoader extends Loader {
|
|||
Message? packageLanguageVersionProblem;
|
||||
if (packageForLanguageVersion != null) {
|
||||
Uri importUri = origin?.importUri ?? uri;
|
||||
if (importUri.scheme != 'dart' &&
|
||||
importUri.scheme != 'package' &&
|
||||
if (!importUri.isScheme('dart') &&
|
||||
!importUri.isScheme('package') &&
|
||||
// ignore: unnecessary_null_comparison
|
||||
packageForLanguageVersion.name != null) {
|
||||
packageUri =
|
||||
|
@ -455,7 +455,7 @@ class SourceLoader extends Loader {
|
|||
if (target.backendTarget.mayDefineRestrictedType(libraryUri)) {
|
||||
libraryBuilder.mayImplementRestrictedTypes = true;
|
||||
}
|
||||
if (uri.scheme == "dart") {
|
||||
if (uri.isScheme("dart")) {
|
||||
target.readPatchFiles(libraryBuilder);
|
||||
}
|
||||
_unparsedLibraries.addLast(libraryBuilder);
|
||||
|
@ -516,7 +516,7 @@ class SourceLoader extends Loader {
|
|||
}
|
||||
|
||||
void _checkForDartCore(Uri uri, LibraryBuilder libraryBuilder) {
|
||||
if (uri.scheme == "dart") {
|
||||
if (uri.isScheme("dart")) {
|
||||
if (uri.path == "core") {
|
||||
_coreLibrary = libraryBuilder;
|
||||
} else if (uri.path == "typed_data") {
|
||||
|
@ -595,7 +595,7 @@ class SourceLoader extends Loader {
|
|||
}
|
||||
|
||||
bool _hasLibraryAccess({required Uri imported, required Uri? importer}) {
|
||||
if (imported.scheme == "dart" && imported.path.startsWith("_")) {
|
||||
if (imported.isScheme("dart") && imported.path.startsWith("_")) {
|
||||
if (importer == null) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -810,7 +810,7 @@ severity: $severity
|
|||
|
||||
if (bytes == null) {
|
||||
// Error recovery.
|
||||
if (fileUri.scheme == untranslatableUriScheme) {
|
||||
if (fileUri.isScheme(untranslatableUriScheme)) {
|
||||
Message message =
|
||||
templateUntranslatableUri.withArguments(library.importUri);
|
||||
library.addProblemAtAccessors(message);
|
||||
|
@ -820,7 +820,7 @@ severity: $severity
|
|||
templateInternalProblemUriMissingScheme.withArguments(fileUri),
|
||||
-1,
|
||||
library.importUri);
|
||||
} else if (fileUri.scheme == SourceLibraryBuilder.MALFORMED_URI_SCHEME) {
|
||||
} else if (fileUri.isScheme(SourceLibraryBuilder.MALFORMED_URI_SCHEME)) {
|
||||
library.addProblemAtAccessors(messageExpectedUri);
|
||||
bytes = synthesizeSourceForMissingFile(library.importUri, null);
|
||||
}
|
||||
|
@ -1027,7 +1027,7 @@ severity: $severity
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if (libraryBuilder.importUri.scheme == 'package') {
|
||||
if (libraryBuilder.importUri.isScheme('package')) {
|
||||
(libraryByPackage[null] ??= []).add(libraryBuilder);
|
||||
} else {
|
||||
if (emitNonPackageErrors) {
|
||||
|
@ -1965,7 +1965,7 @@ severity: $severity
|
|||
for (LibraryBuilder libraryBuilder in libraryBuilders) {
|
||||
if (!libraryBuilder.isPatch &&
|
||||
(libraryBuilder.loader == this ||
|
||||
libraryBuilder.importUri.scheme == "dart" ||
|
||||
libraryBuilder.importUri.isScheme("dart") ||
|
||||
libraryBuilder == this.first)) {
|
||||
if (libraries.add(libraryBuilder.library)) {
|
||||
workList.add(libraryBuilder.library);
|
||||
|
|
|
@ -1064,7 +1064,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
|||
onType,
|
||||
onTypeInstantiateToBounds,
|
||||
target,
|
||||
isPlatform: extensionBuilder.library.importUri.scheme == 'dart');
|
||||
isPlatform: extensionBuilder.library.importUri.isScheme('dart'));
|
||||
if (noneMoreSpecific.isNotEmpty) {
|
||||
bool isMostSpecific = true;
|
||||
for (ExtensionAccessCandidate other in noneMoreSpecific) {
|
||||
|
|
|
@ -70,7 +70,7 @@ class _TypeSchemaEliminationVisitor extends ReplacementVisitor {
|
|||
assert(topType == const DynamicType() ||
|
||||
topType is InterfaceType &&
|
||||
topType.nullability == Nullability.nullable &&
|
||||
topType.classNode.enclosingLibrary.importUri.scheme == "dart" &&
|
||||
topType.classNode.enclosingLibrary.importUri.isScheme("dart") &&
|
||||
topType.classNode.enclosingLibrary.importUri.path == "core" &&
|
||||
topType.classNode.name == "Object");
|
||||
assert(
|
||||
|
|
|
@ -22,7 +22,7 @@ class UriTranslator {
|
|||
dartLibraries.libraryInfoFor(libraryName)?.patches;
|
||||
|
||||
bool isPlatformImplementation(Uri uri) {
|
||||
if (uri.scheme != "dart") return false;
|
||||
if (!uri.isScheme("dart")) return false;
|
||||
String path = uri.path;
|
||||
return dartLibraries.libraryInfoFor(path) == null || path.startsWith("_");
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ class UriTranslator {
|
|||
// callback, so we can provide an error location when one is available. For
|
||||
// example, if the error occurs in an `import`.
|
||||
Uri? translate(Uri uri, [bool reportMessage = true]) {
|
||||
if (uri.scheme == "dart") return _translateDartUri(uri);
|
||||
if (uri.scheme == "package") {
|
||||
if (uri.isScheme("dart")) return _translateDartUri(uri);
|
||||
if (uri.isScheme("package")) {
|
||||
return _translatePackageUri(uri, reportMessage);
|
||||
}
|
||||
return null;
|
||||
|
@ -42,7 +42,7 @@ class UriTranslator {
|
|||
Package? getPackage(Uri uri) {
|
||||
// ignore: unnecessary_null_comparison
|
||||
if (packages == null) return null;
|
||||
if (uri.scheme != "package") return null;
|
||||
if (!uri.isScheme("package")) return null;
|
||||
int firstSlash = uri.path.indexOf('/');
|
||||
if (firstSlash == -1) return null;
|
||||
String packageName = uri.path.substring(0, firstSlash);
|
||||
|
|
|
@ -116,7 +116,7 @@ class _Processor {
|
|||
Future<TopLevel> preprocessUri(Uri importUri, {Uri? partOf}) async {
|
||||
if (verbosityLevel >= 20) log("$importUri =>");
|
||||
Uri fileUri = importUri;
|
||||
if (importUri.scheme == "package") {
|
||||
if (importUri.isScheme("package")) {
|
||||
fileUri = uriTranslator.translate(importUri)!;
|
||||
}
|
||||
if (verbosityLevel >= 20) log("$fileUri");
|
||||
|
@ -202,14 +202,14 @@ class _Processor {
|
|||
worklist.add(new _TopLevelAndAstNode(entrypointish, child));
|
||||
|
||||
if (child is Part) {
|
||||
if (child.uri.scheme != "dart") {
|
||||
if (!child.uri.isScheme("dart")) {
|
||||
TopLevel partTopLevel = parsed[child.uri] ??
|
||||
await preprocessUri(child.uri, partOf: entrypointish.uri);
|
||||
await _premarkTopLevel(worklist, closed, partTopLevel);
|
||||
}
|
||||
} else if (child is Export) {
|
||||
for (Uri importedUri in child.uris) {
|
||||
if (importedUri.scheme != "dart") {
|
||||
if (!importedUri.isScheme("dart")) {
|
||||
TopLevel exportTopLevel =
|
||||
parsed[importedUri] ?? await preprocessUri(importedUri);
|
||||
await _premarkTopLevel(worklist, closed, exportTopLevel);
|
||||
|
@ -230,7 +230,7 @@ class _Processor {
|
|||
if (child is Import) {
|
||||
child.marked = Coloring.Marked;
|
||||
for (Uri importedUri in child.uris) {
|
||||
if (importedUri.scheme != "dart") {
|
||||
if (!importedUri.isScheme("dart")) {
|
||||
TopLevel importedTopLevel =
|
||||
parsed[importedUri] ?? await preprocessUri(importedUri);
|
||||
imported.add(importedTopLevel);
|
||||
|
@ -238,7 +238,7 @@ class _Processor {
|
|||
}
|
||||
} else if (child is PartOf) {
|
||||
child.marked = Coloring.Marked;
|
||||
if (child.partOfUri.scheme != "dart") {
|
||||
if (!child.partOfUri.isScheme("dart")) {
|
||||
TopLevel part = parsed[child.partOfUri]!;
|
||||
List<TopLevel> importsFromPart =
|
||||
await _preprocessImportsAsNeeded(imports, part);
|
||||
|
@ -392,7 +392,7 @@ class _Processor {
|
|||
if (child is Part) {
|
||||
child.marked = Coloring.Marked;
|
||||
// do stuff to part.
|
||||
if (child.uri.scheme != "dart") {
|
||||
if (!child.uri.isScheme("dart")) {
|
||||
other = parsed[child.uri] ??
|
||||
await preprocessUri(child.uri, partOf: topLevel.uri);
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ class _Processor {
|
|||
child.marked = Coloring.Marked;
|
||||
// do stuff to export.
|
||||
for (Uri importedUri in child.uris) {
|
||||
if (importedUri.scheme != "dart") {
|
||||
if (!importedUri.isScheme("dart")) {
|
||||
other = parsed[importedUri] ?? await preprocessUri(importedUri);
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ class _Processor {
|
|||
}
|
||||
if (child is Import) {
|
||||
for (Uri importedUri in child.uris) {
|
||||
if (importedUri.scheme != "dart") {
|
||||
if (!importedUri.isScheme("dart")) {
|
||||
imported.add(importedUri);
|
||||
}
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ class _Processor {
|
|||
if (sb.isNotEmpty) count++;
|
||||
Uri uri = entry.key;
|
||||
Uri fileUri = uri;
|
||||
if (uri.scheme == "package") {
|
||||
if (uri.isScheme("package")) {
|
||||
fileUri = uriTranslator.translate(uri)!;
|
||||
}
|
||||
result[fileUri] = sb.toString();
|
||||
|
@ -489,7 +489,7 @@ class _Processor {
|
|||
// uri imports a file we haven't read. Check if it exists and include it
|
||||
// as an empty file if it does.
|
||||
Uri fileUri = uri;
|
||||
if (uri.scheme == "package") {
|
||||
if (uri.isScheme("package")) {
|
||||
fileUri = uriTranslator.translate(uri)!;
|
||||
}
|
||||
if (await fileSystem.entityForUri(fileUri).exists()) {
|
||||
|
|
|
@ -140,7 +140,7 @@ String _invalidLibrariesSpec = '''
|
|||
''';
|
||||
|
||||
bool isDartCoreLibrary(Library lib) => isDartCore(lib.importUri);
|
||||
bool isDartCore(Uri uri) => uri.scheme == 'dart' && uri.path == 'core';
|
||||
bool isDartCore(Uri uri) => uri.isScheme('dart') && uri.path == 'core';
|
||||
|
||||
/// Find a library in [component] whose Uri ends with the given [suffix]
|
||||
Library findLibrary(Component component, String suffix) {
|
||||
|
|
|
@ -451,8 +451,8 @@ Future<TestResult<T>> runTestForConfig<T>(
|
|||
|
||||
bool excludeLibrary(Library library) {
|
||||
return forUserLibrariesOnly &&
|
||||
(library.importUri.scheme == 'dart' ||
|
||||
library.importUri.scheme == 'package');
|
||||
(library.importUri.isScheme('dart') ||
|
||||
library.importUri.isScheme('package'));
|
||||
}
|
||||
|
||||
await dataComputer.inspectTestResultData(testResultData);
|
||||
|
|
|
@ -55,7 +55,7 @@ Future<void> main(List<String> args) async {
|
|||
.where((Member m) =>
|
||||
!m.isAbstract &&
|
||||
m.name.text == "toString" &&
|
||||
m.enclosingLibrary.importUri.scheme != "dart")
|
||||
!m.enclosingLibrary.importUri.isScheme("dart"))
|
||||
.toList();
|
||||
if (toStringList.length > 1) throw "What?";
|
||||
if (toStringList.length == 1) {
|
||||
|
@ -157,7 +157,7 @@ Future<void> main(List<String> args) async {
|
|||
.where((Member m) =>
|
||||
!m.isAbstract &&
|
||||
m.name.text == "toString" &&
|
||||
m.enclosingLibrary.importUri.scheme != "dart")
|
||||
!m.enclosingLibrary.importUri.isScheme("dart"))
|
||||
.toList();
|
||||
Member toString = toStringList.single;
|
||||
if (toString.fileUri != uri) continue;
|
||||
|
|
|
@ -88,7 +88,7 @@ Future<void> main(List<String> args) async {
|
|||
component = incrementalCompilerResult.component;
|
||||
|
||||
for (Library library in component.libraries) {
|
||||
if (library.importUri.scheme == "dart") continue;
|
||||
if (library.importUri.isScheme("dart")) continue;
|
||||
// This isn't perfect because of parts, but (for now) it'll do.
|
||||
for (Uri uri in libUris) {
|
||||
if (library.fileUri.toString().startsWith(uri.toString())) {
|
||||
|
|
|
@ -363,7 +363,7 @@ class RegisterCallTransformer extends RecursiveVisitor {
|
|||
|
||||
@override
|
||||
void visitLibrary(Library node) {
|
||||
if (node.importUri.scheme == "package" &&
|
||||
if (node.importUri.isScheme("package") &&
|
||||
node.importUri.pathSegments.first == "front_end") {
|
||||
super.visitLibrary(node);
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ class RegisterTimeTransformer extends RecursiveVisitor {
|
|||
|
||||
@override
|
||||
void visitLibrary(Library node) {
|
||||
if (node.importUri.scheme == "package" &&
|
||||
if (node.importUri.isScheme("package") &&
|
||||
node.importUri.pathSegments.first == "front_end") {
|
||||
super.visitLibrary(node);
|
||||
}
|
||||
|
|
|
@ -778,9 +778,9 @@ worlds:
|
|||
void _rewriteImportsExportsToUriInternal(
|
||||
Token uriToken, Uri oldUri, List<_Replacement> replacements, Uri newUri) {
|
||||
Uri tokenUri = _getUri(uriToken, oldUri, resolvePackage: false);
|
||||
if (tokenUri.scheme == "package" || tokenUri.scheme == "dart") return;
|
||||
if (tokenUri.isScheme("package") || tokenUri.isScheme("dart")) return;
|
||||
Uri asPackageUri = _getImportUri(tokenUri);
|
||||
if (asPackageUri.scheme == "package") {
|
||||
if (asPackageUri.isScheme("package")) {
|
||||
// Just replace with this package uri.
|
||||
replacements.add(new _Replacement(
|
||||
uriToken.offset - 1,
|
||||
|
@ -803,7 +803,7 @@ worlds:
|
|||
String uriString = uriToken.lexeme;
|
||||
uriString = uriString.substring(1, uriString.length - 1);
|
||||
Uri uriTokenUri = uri.resolve(uriString);
|
||||
if (resolvePackage && uriTokenUri.scheme == "package") {
|
||||
if (resolvePackage && uriTokenUri.isScheme("package")) {
|
||||
Package package = _latestCrashingIncrementalCompiler!
|
||||
.getPackageForPackageName(uriTokenUri.pathSegments.first)!;
|
||||
uriTokenUri = package.packageUriRoot
|
||||
|
|
|
@ -116,7 +116,7 @@ Future<void> test(
|
|||
Expect.isFalse(
|
||||
hadDiagnostic, "Compilation had diagnostics (errors, warnings)!");
|
||||
for (Library library in result.component!.libraries) {
|
||||
if (library.importUri.scheme != 'dart') {
|
||||
if (!library.importUri.isScheme('dart')) {
|
||||
bool usesLegacy =
|
||||
await uriUsesLegacyLanguageVersion(library.fileUri, options);
|
||||
VersionAndPackageUri versionAndPackageUri =
|
||||
|
@ -143,7 +143,7 @@ Future<void> test(
|
|||
"Expected library ${library.importUri} with version "
|
||||
"${library.languageVersion} to be opted in.");
|
||||
Expect.isTrue(
|
||||
versionAndPackageUri.packageUri.scheme != 'package' ||
|
||||
!versionAndPackageUri.packageUri.isScheme('package') ||
|
||||
!versionAndPackageUri.packageUri.path
|
||||
.startsWith('allowed_package') ||
|
||||
library.languageVersion < versionOptsInAllowed ||
|
||||
|
|
|
@ -598,7 +598,7 @@ class FastaContext extends ChainContext with MatchContext {
|
|||
}
|
||||
for (String argument in parsedOptions.arguments) {
|
||||
Uri uri = description.uri.resolve(argument);
|
||||
if (uri.scheme != 'package') {
|
||||
if (!uri.isScheme('package')) {
|
||||
File f = new File.fromUri(uri);
|
||||
if (!f.existsSync()) {
|
||||
throw new UnsupportedError("No file found: $f ($argument)");
|
||||
|
@ -1328,11 +1328,11 @@ class FuzzCompiles
|
|||
Map<Uri, LibraryBuilder> builders = {};
|
||||
for (LibraryBuilder builder
|
||||
in incrementalCompiler.kernelTargetForTesting!.loader.libraryBuilders) {
|
||||
if (builder.importUri.scheme == "dart" && !builder.isSynthetic) continue;
|
||||
if (builder.importUri.isScheme("dart") && !builder.isSynthetic) continue;
|
||||
builders[builder.fileUri] = builder;
|
||||
for (LibraryPart part in builder.library.parts) {
|
||||
Uri thisPartUri = builder.importUri.resolve(part.partUri);
|
||||
if (thisPartUri.scheme == "package") {
|
||||
if (thisPartUri.isScheme("package")) {
|
||||
thisPartUri = incrementalCompiler
|
||||
.kernelTargetForTesting!.uriTranslator
|
||||
.translate(thisPartUri)!;
|
||||
|
@ -1761,8 +1761,8 @@ Set<Uri> createUserLibrariesImportUriSet(
|
|||
component.libraries.map((Library library) => library.importUri).toSet();
|
||||
Set<Uri> userLibraries = component.libraries
|
||||
.where((Library library) =>
|
||||
library.importUri.scheme != 'dart' &&
|
||||
library.importUri.scheme != 'package' &&
|
||||
!library.importUri.isScheme('dart') &&
|
||||
!library.importUri.isScheme('package') &&
|
||||
!excludedLibraries.contains(library))
|
||||
.map((Library library) => library.importUri)
|
||||
.toSet();
|
||||
|
@ -2171,7 +2171,7 @@ class MatchHierarchy
|
|||
ComponentResult result, FastaContext context) {
|
||||
Component component = result.component;
|
||||
Uri uri =
|
||||
component.uriToSource.keys.firstWhere((uri) => uri.scheme == "file");
|
||||
component.uriToSource.keys.firstWhere((uri) => uri.isScheme("file"));
|
||||
KernelTarget target = result.sourceTarget;
|
||||
ClassHierarchyBuilder hierarchy = target.loader.hierarchyBuilder;
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
|
|
@ -48,13 +48,13 @@ class TypeConstraintGathererTest {
|
|||
"the core library and the test library.");
|
||||
Library firstLibrary = env.component.libraries.first;
|
||||
Library secondLibrary = env.component.libraries.last;
|
||||
if (firstLibrary.importUri.scheme == "dart" &&
|
||||
if (firstLibrary.importUri.isScheme("dart") &&
|
||||
firstLibrary.importUri.path == "core") {
|
||||
_coreLibrary = firstLibrary;
|
||||
_testLibrary = secondLibrary;
|
||||
} else {
|
||||
assert(
|
||||
secondLibrary.importUri.scheme == "dart" &&
|
||||
secondLibrary.importUri.isScheme("dart") &&
|
||||
secondLibrary.importUri.path == "core",
|
||||
"One of the libraries is expected to be 'dart:core'.");
|
||||
_coreLibrary == secondLibrary;
|
||||
|
|
|
@ -48,13 +48,13 @@ class TypeConstraintGathererTest {
|
|||
"the core library and the test library.");
|
||||
Library firstLibrary = env.component.libraries.first;
|
||||
Library secondLibrary = env.component.libraries.last;
|
||||
if (firstLibrary.importUri.scheme == "dart" &&
|
||||
if (firstLibrary.importUri.isScheme("dart") &&
|
||||
firstLibrary.importUri.path == "core") {
|
||||
_coreLibrary = firstLibrary;
|
||||
_testLibrary = secondLibrary;
|
||||
} else {
|
||||
assert(
|
||||
secondLibrary.importUri.scheme == "dart" &&
|
||||
secondLibrary.importUri.isScheme("dart") &&
|
||||
secondLibrary.importUri.path == "core",
|
||||
"One of the libraries is expected to be 'dart:core'.");
|
||||
_coreLibrary == secondLibrary;
|
||||
|
|
|
@ -46,13 +46,13 @@ class TypeSchemaEnvironmentTest {
|
|||
"the core library and the test library.");
|
||||
Library firstLibrary = typeParserEnvironment.component.libraries.first;
|
||||
Library secondLibrary = typeParserEnvironment.component.libraries.last;
|
||||
if (firstLibrary.importUri.scheme == "dart" &&
|
||||
if (firstLibrary.importUri.isScheme("dart") &&
|
||||
firstLibrary.importUri.path == "core") {
|
||||
_coreLibrary = firstLibrary;
|
||||
_testLibrary = secondLibrary;
|
||||
} else {
|
||||
assert(
|
||||
secondLibrary.importUri.scheme == "dart" &&
|
||||
secondLibrary.importUri.isScheme("dart") &&
|
||||
secondLibrary.importUri.path == "core",
|
||||
"One of the libraries is expected to be 'dart:core'.");
|
||||
_coreLibrary == secondLibrary;
|
||||
|
|
|
@ -46,13 +46,13 @@ class TypeSchemaEnvironmentTest {
|
|||
"the core library and the test library.");
|
||||
Library firstLibrary = typeParserEnvironment.component.libraries.first;
|
||||
Library secondLibrary = typeParserEnvironment.component.libraries.last;
|
||||
if (firstLibrary.importUri.scheme == "dart" &&
|
||||
if (firstLibrary.importUri.isScheme("dart") &&
|
||||
firstLibrary.importUri.path == "core") {
|
||||
_coreLibrary = firstLibrary;
|
||||
_testLibrary = secondLibrary;
|
||||
} else {
|
||||
assert(
|
||||
secondLibrary.importUri.scheme == "dart" &&
|
||||
secondLibrary.importUri.isScheme("dart") &&
|
||||
secondLibrary.importUri.path == "core",
|
||||
"One of the libraries is expected to be 'dart:core'.");
|
||||
_coreLibrary == secondLibrary;
|
||||
|
|
|
@ -28,13 +28,13 @@ abstract class LegacyUpperBoundTest {
|
|||
"the core library and the test library.");
|
||||
Library firstLibrary = env.component.libraries.first;
|
||||
Library secondLibrary = env.component.libraries.last;
|
||||
if (firstLibrary.importUri.scheme == "dart" &&
|
||||
if (firstLibrary.importUri.isScheme("dart") &&
|
||||
firstLibrary.importUri.path == "core") {
|
||||
coreLibrary = firstLibrary;
|
||||
testLibrary = secondLibrary;
|
||||
} else {
|
||||
assert(
|
||||
secondLibrary.importUri.scheme == "dart" &&
|
||||
secondLibrary.importUri.isScheme("dart") &&
|
||||
secondLibrary.importUri.path == "core",
|
||||
"One of the libraries is expected to be 'dart:core'.");
|
||||
coreLibrary = secondLibrary;
|
||||
|
|
|
@ -330,7 +330,7 @@ Future<Null> writeProgram(Component component, Uri outputUri) async {
|
|||
// TODO(sigmund): the incremental generator should always filter these
|
||||
// libraries instead.
|
||||
new BinaryPrinter(sink,
|
||||
libraryFilter: (library) => library.importUri.scheme != 'dart')
|
||||
libraryFilter: (library) => !library.importUri.isScheme('dart'))
|
||||
.writeComponentFile(component);
|
||||
await sink.close();
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ class Dart2jsTester {
|
|||
uris = c.uriToSource.values
|
||||
.map((s) => s.importUri)
|
||||
.whereType<Uri>()
|
||||
.where((u) => u.scheme != "dart")
|
||||
.where((u) => !u.isScheme("dart"))
|
||||
.toSet()
|
||||
.toList();
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ Future<void> main(List<String> args) async {
|
|||
List<Uri> uris = c.uriToSource.values
|
||||
.map((s) => s.importUri)
|
||||
.whereType<Uri>()
|
||||
.where((u) => u.scheme != "dart")
|
||||
.where((u) => !u.isScheme("dart"))
|
||||
.toSet()
|
||||
.toList();
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue