mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[cfe] Move relativize code from dart2js to cfe
Change-Id: I2e07dcf91adf65965583189972b0c27cc0aee526 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111427 Reviewed-by: Vyacheslav Egorov <vegorov@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
parent
db3028ac5e
commit
972d4e9a75
|
@ -17,7 +17,6 @@ import 'filenames.dart';
|
|||
import 'options.dart' show CompilerOptions;
|
||||
import 'source_file_provider.dart';
|
||||
import 'util/command_line.dart';
|
||||
import 'util/uri_extras.dart';
|
||||
import 'util/util.dart' show stackTraceFilePrefix;
|
||||
|
||||
const String _defaultSpecificationUri = '../../../../sdk/lib/libraries.json';
|
||||
|
@ -675,16 +674,16 @@ Future<api.CompilationResult> compile(List<String> argv,
|
|||
inputName = 'bytes data';
|
||||
inputSize = inputProvider.dartCharactersRead;
|
||||
String dataInput =
|
||||
relativize(currentDirectory, readDataUri, Platform.isWindows);
|
||||
fe.relativizeUri(currentDirectory, readDataUri, Platform.isWindows);
|
||||
summary = 'Data files $input and $dataInput ';
|
||||
break;
|
||||
case ReadStrategy.fromCodegen:
|
||||
inputName = 'bytes data';
|
||||
inputSize = inputProvider.dartCharactersRead;
|
||||
String dataInput =
|
||||
relativize(currentDirectory, readDataUri, Platform.isWindows);
|
||||
String codeInput =
|
||||
relativize(currentDirectory, readCodegenUri, Platform.isWindows);
|
||||
fe.relativizeUri(currentDirectory, readDataUri, Platform.isWindows);
|
||||
String codeInput = fe.relativizeUri(
|
||||
currentDirectory, readCodegenUri, Platform.isWindows);
|
||||
summary = 'Data files $input, $dataInput and '
|
||||
'${codeInput}[0-${codegenShards - 1}] ';
|
||||
break;
|
||||
|
@ -696,31 +695,34 @@ Future<api.CompilationResult> compile(List<String> argv,
|
|||
outputName = 'characters JavaScript';
|
||||
outputSize = outputProvider.totalCharactersWrittenJavaScript;
|
||||
primaryOutputSize = outputProvider.totalCharactersWrittenPrimary;
|
||||
String output = relativize(currentDirectory, out, Platform.isWindows);
|
||||
String output =
|
||||
fe.relativizeUri(currentDirectory, out, Platform.isWindows);
|
||||
summary += 'compiled to JavaScript: ${output}';
|
||||
break;
|
||||
case WriteStrategy.toKernel:
|
||||
processName = 'Compiled';
|
||||
outputName = 'kernel bytes';
|
||||
outputSize = outputProvider.totalDataWritten;
|
||||
String output = relativize(currentDirectory, out, Platform.isWindows);
|
||||
String output =
|
||||
fe.relativizeUri(currentDirectory, out, Platform.isWindows);
|
||||
summary += 'compiled to dill: ${output}.';
|
||||
break;
|
||||
case WriteStrategy.toData:
|
||||
processName = 'Serialized';
|
||||
outputName = 'bytes data';
|
||||
outputSize = outputProvider.totalDataWritten;
|
||||
String output = relativize(currentDirectory, out, Platform.isWindows);
|
||||
String dataOutput =
|
||||
relativize(currentDirectory, writeDataUri, Platform.isWindows);
|
||||
String output =
|
||||
fe.relativizeUri(currentDirectory, out, Platform.isWindows);
|
||||
String dataOutput = fe.relativizeUri(
|
||||
currentDirectory, writeDataUri, Platform.isWindows);
|
||||
summary += 'serialized to dill and data: ${output} and ${dataOutput}.';
|
||||
break;
|
||||
case WriteStrategy.toCodegen:
|
||||
processName = 'Serialized';
|
||||
outputName = 'bytes data';
|
||||
outputSize = outputProvider.totalDataWritten;
|
||||
String codeOutput =
|
||||
relativize(currentDirectory, writeCodegenUri, Platform.isWindows);
|
||||
String codeOutput = fe.relativizeUri(
|
||||
currentDirectory, writeCodegenUri, Platform.isWindows);
|
||||
summary += 'serialized to codegen data: '
|
||||
'${codeOutput}${codegenShard}.';
|
||||
break;
|
||||
|
@ -731,9 +733,9 @@ Future<api.CompilationResult> compile(List<String> argv,
|
|||
'${_formatCharacterCount(outputSize)} $outputName in '
|
||||
'${_formatDurationAsSeconds(wallclock.elapsed)} seconds');
|
||||
if (primaryOutputSize != null) {
|
||||
diagnosticHandler
|
||||
.info('${_formatCharacterCount(primaryOutputSize)} $outputName '
|
||||
'in ${relativize(currentDirectory, out, Platform.isWindows)}');
|
||||
diagnosticHandler.info(
|
||||
'${_formatCharacterCount(primaryOutputSize)} $outputName '
|
||||
'in ${fe.relativizeUri(currentDirectory, out, Platform.isWindows)}');
|
||||
}
|
||||
if (writeStrategy == WriteStrategy.toJs) {
|
||||
if (outputSpecified || diagnosticHandler.verbose) {
|
||||
|
|
|
@ -6,6 +6,8 @@ library deferred_load;
|
|||
|
||||
import 'dart:collection' show Queue;
|
||||
|
||||
import 'package:front_end/src/api_unstable/dart2js.dart' as fe;
|
||||
|
||||
import 'common/tasks.dart' show CompilerTask;
|
||||
import 'common.dart';
|
||||
import 'common_elements.dart'
|
||||
|
@ -26,7 +28,6 @@ import 'options.dart';
|
|||
import 'universe/use.dart';
|
||||
import 'universe/world_impact.dart'
|
||||
show ImpactUseCase, WorldImpact, WorldImpactVisitorImpl;
|
||||
import 'util/uri_extras.dart' as uri_extras;
|
||||
import 'util/util.dart' show makeUnique;
|
||||
import 'world.dart' show KClosedWorld;
|
||||
|
||||
|
@ -972,7 +973,7 @@ class ImportDescription {
|
|||
ImportDescription(
|
||||
ImportEntity import, LibraryEntity importingLibrary, Uri mainLibraryUri)
|
||||
: this.internal(
|
||||
uri_extras.relativize(
|
||||
fe.relativizeUri(
|
||||
mainLibraryUri, importingLibrary.canonicalUri, false),
|
||||
import.name,
|
||||
importingLibrary);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
library dart2js.diagnostics.code_location;
|
||||
|
||||
import '../util/uri_extras.dart' as uri_extras show relativize;
|
||||
import 'package:front_end/src/api_unstable/dart2js.dart' as fe;
|
||||
|
||||
/// [CodeLocation] divides uris into different classes.
|
||||
///
|
||||
|
@ -47,7 +47,7 @@ class SchemeLocation implements CodeLocation {
|
|||
|
||||
@override
|
||||
String relativize(Uri baseUri) {
|
||||
return uri_extras.relativize(baseUri, uri, false);
|
||||
return fe.relativizeUri(baseUri, uri, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ class UriLocation implements CodeLocation {
|
|||
|
||||
@override
|
||||
String relativize(Uri baseUri) {
|
||||
return uri_extras.relativize(baseUri, uri, false);
|
||||
return fe.relativizeUri(baseUri, uri, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
library dart2js.source_map_builder;
|
||||
|
||||
import 'package:front_end/src/api_unstable/dart2js.dart' as fe;
|
||||
import 'package:kernel/ast.dart' show Location;
|
||||
import '../../compiler_new.dart' show CompilerOutput, OutputSink, OutputType;
|
||||
import '../util/uri_extras.dart' show relativize;
|
||||
import '../util/util.dart';
|
||||
import 'location_provider.dart';
|
||||
import 'code_output.dart' show SourceLocationsProvider, SourceLocations;
|
||||
|
@ -122,15 +122,15 @@ class SourceMapBuilder {
|
|||
buffer.write(' "version": 3,\n');
|
||||
buffer.write(' "engine": "$version",\n');
|
||||
if (sourceMapUri != null && targetFileUri != null) {
|
||||
buffer.write(
|
||||
' "file": "${relativize(sourceMapUri, targetFileUri, false)}",\n');
|
||||
buffer.write(' "file": '
|
||||
'"${fe.relativizeUri(sourceMapUri, targetFileUri, false)}",\n');
|
||||
}
|
||||
buffer.write(' "sourceRoot": "",\n');
|
||||
buffer.write(' "sources": ');
|
||||
Iterable<String> relativeSourceUriList = const <String>[];
|
||||
if (sourceMapUri != null) {
|
||||
relativeSourceUriList =
|
||||
uriMap.elements.map((u) => relativize(sourceMapUri, u, false));
|
||||
uriMap.elements.map((u) => fe.relativizeUri(sourceMapUri, u, false));
|
||||
}
|
||||
printStringListOn(relativeSourceUriList, buffer);
|
||||
buffer.write(',\n');
|
||||
|
@ -255,7 +255,7 @@ class SourceMapBuilder {
|
|||
/// make it point to the source map file in [sourceMapUri].
|
||||
static String generateSourceMapTag(Uri sourceMapUri, Uri fileUri) {
|
||||
if (sourceMapUri != null && fileUri != null) {
|
||||
String sourceMapFileName = relativize(fileUri, sourceMapUri, false);
|
||||
String sourceMapFileName = fe.relativizeUri(fileUri, sourceMapUri, false);
|
||||
return '''
|
||||
|
||||
//# sourceMappingURL=$sourceMapFileName
|
||||
|
|
|
@ -9,6 +9,8 @@ import 'dart:io';
|
|||
import 'dart:math' as math;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:front_end/src/api_unstable/dart2js.dart' as fe;
|
||||
|
||||
import '../compiler.dart' as api show Diagnostic;
|
||||
import '../compiler_new.dart' as api;
|
||||
import '../compiler_new.dart';
|
||||
|
@ -16,7 +18,6 @@ import 'colors.dart' as colors;
|
|||
import 'dart2js.dart' show AbortLeg;
|
||||
import 'filenames.dart';
|
||||
import 'io/source_file.dart';
|
||||
import 'util/uri_extras.dart';
|
||||
|
||||
abstract class SourceFileProvider implements CompilerInput {
|
||||
bool isWindows = (Platform.operatingSystem == 'windows');
|
||||
|
@ -107,7 +108,7 @@ abstract class SourceFileProvider implements CompilerInput {
|
|||
.getUrl(resourceUri)
|
||||
.then((HttpClientRequest request) => request.close())
|
||||
.then((HttpClientResponse response) {
|
||||
if (response.statusCode != HttpStatus.OK) {
|
||||
if (response.statusCode != HttpStatus.ok) {
|
||||
String msg = 'Failure getting $resourceUri: '
|
||||
'${response.statusCode} ${response.reasonPhrase}';
|
||||
throw msg;
|
||||
|
@ -145,7 +146,7 @@ abstract class SourceFileProvider implements CompilerInput {
|
|||
throw "unimplemented";
|
||||
}
|
||||
|
||||
relativizeUri(Uri uri) => relativize(cwd, uri, isWindows);
|
||||
relativizeUri(Uri uri) => fe.relativizeUri(cwd, uri, isWindows);
|
||||
|
||||
SourceFile<List<int>> getUtf8SourceFile(Uri resourceUri) {
|
||||
return utf8SourceFiles[resourceUri];
|
||||
|
@ -384,12 +385,13 @@ class RandomAccessFileOutputProvider implements CompilerOutput {
|
|||
|
||||
RandomAccessFile output;
|
||||
try {
|
||||
output = new File(uri.toFilePath()).openSync(mode: FileMode.WRITE);
|
||||
output = new File(uri.toFilePath()).openSync(mode: FileMode.write);
|
||||
} on FileSystemException catch (e) {
|
||||
onFailure('$e');
|
||||
}
|
||||
|
||||
allOutputFiles.add(relativize(currentDirectory, uri, Platform.isWindows));
|
||||
allOutputFiles
|
||||
.add(fe.relativizeUri(currentDirectory, uri, Platform.isWindows));
|
||||
|
||||
int charactersWritten = 0;
|
||||
|
||||
|
@ -424,7 +426,8 @@ class RandomAccessFileOutputProvider implements CompilerOutput {
|
|||
BinaryOutputSink createBinarySink(Uri uri) {
|
||||
uri = currentDirectory.resolveUri(uri);
|
||||
|
||||
allOutputFiles.add(relativize(currentDirectory, uri, Platform.isWindows));
|
||||
allOutputFiles
|
||||
.add(fe.relativizeUri(currentDirectory, uri, Platform.isWindows));
|
||||
|
||||
if (uri.scheme != 'file') {
|
||||
onFailure('Unhandled scheme ${uri.scheme} in $uri.');
|
||||
|
@ -432,7 +435,7 @@ class RandomAccessFileOutputProvider implements CompilerOutput {
|
|||
|
||||
RandomAccessFile output;
|
||||
try {
|
||||
output = new File(uri.toFilePath()).openSync(mode: FileMode.WRITE);
|
||||
output = new File(uri.toFilePath()).openSync(mode: FileMode.write);
|
||||
} on FileSystemException catch (e) {
|
||||
onFailure('$e');
|
||||
}
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
// Copyright (c) 2012, 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.
|
||||
|
||||
library uri_extras;
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
String relativize(Uri base, Uri uri, bool isWindows) {
|
||||
bool equalsNCS(String a, String b) {
|
||||
return a.toLowerCase() == b.toLowerCase();
|
||||
}
|
||||
|
||||
if (!equalsNCS(base.scheme, uri.scheme) ||
|
||||
equalsNCS(base.scheme, 'dart') ||
|
||||
equalsNCS(base.scheme, 'package')) {
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
if (!equalsNCS(base.scheme, 'file')) {
|
||||
isWindows = false;
|
||||
}
|
||||
|
||||
String normalize(String path) {
|
||||
if (isWindows) {
|
||||
return path.toLowerCase();
|
||||
} else {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
if (base.userInfo == uri.userInfo &&
|
||||
equalsNCS(base.host, uri.host) &&
|
||||
base.port == uri.port &&
|
||||
uri.query == "" &&
|
||||
uri.fragment == "") {
|
||||
if (normalize(uri.path).startsWith(normalize(base.path))) {
|
||||
return uri.path.substring(base.path.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
if (!base.path.startsWith('/') || !uri.path.startsWith('/')) {
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
List<String> uriParts = uri.path.split('/');
|
||||
List<String> baseParts = base.path.split('/');
|
||||
int common = 0;
|
||||
int length = min(uriParts.length, baseParts.length);
|
||||
while (common < length &&
|
||||
normalize(uriParts[common]) == normalize(baseParts[common])) {
|
||||
common++;
|
||||
}
|
||||
if (common == 1 || (isWindows && common == 2)) {
|
||||
// The first part will always be an empty string because the
|
||||
// paths are absolute. On Windows, we must also consider drive
|
||||
// letters or hostnames.
|
||||
if (baseParts.length > common + 1) {
|
||||
// Avoid using '..' to go to the root, unless we are already there.
|
||||
return uri.path;
|
||||
}
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = common + 1; i < baseParts.length; i++) {
|
||||
sb.write('../');
|
||||
}
|
||||
for (int i = common; i < uriParts.length - 1; i++) {
|
||||
sb.write('${uriParts[i]}/');
|
||||
}
|
||||
sb.write('${uriParts.last}');
|
||||
return sb.toString();
|
||||
}
|
||||
return uri.toString();
|
||||
}
|
|
@ -33,9 +33,9 @@ main(List<String> args) async {
|
|||
];
|
||||
|
||||
if (flags.rest.isEmpty) {
|
||||
var script = relativizeUri(Platform.script);
|
||||
var platform =
|
||||
relativizeUri(Uri.base.resolve(nativeToUriPath(flags['platform'])));
|
||||
var script = relativizeUri(Uri.base, Platform.script, false);
|
||||
var platform = relativizeUri(
|
||||
Uri.base, Uri.base.resolve(nativeToUriPath(flags['platform'])), false);
|
||||
print('usage: ${Platform.executable} $script '
|
||||
'[--platform=$platform] [--out=out.dill] program.dart');
|
||||
exit(1);
|
||||
|
|
|
@ -90,7 +90,8 @@
|
|||
// TODO(sigmund): move this file to a shared package.
|
||||
import 'dart:convert' show jsonDecode, jsonEncode;
|
||||
|
||||
import '../fasta/util/relativize.dart';
|
||||
import '../fasta/util/relativize.dart' show relativizeUri;
|
||||
import '../fasta/resolve_input_uri.dart' show isWindows;
|
||||
|
||||
/// Contents from a single library specification file.
|
||||
///
|
||||
|
@ -202,7 +203,7 @@ class LibrariesSpecification {
|
|||
Map toJsonMap(Uri outputUri) {
|
||||
var result = {};
|
||||
var dir = outputUri.resolve('.');
|
||||
String pathFor(Uri uri) => relativizeUri(uri, base: dir);
|
||||
String pathFor(Uri uri) => relativizeUri(dir, uri, isWindows);
|
||||
_targets.forEach((targetName, target) {
|
||||
var libraries = {};
|
||||
target._libraries.forEach((name, lib) {
|
||||
|
|
|
@ -28,6 +28,8 @@ import 'messages.dart' show getLocation, getSourceLine;
|
|||
|
||||
import 'problems.dart' show unhandled;
|
||||
|
||||
import 'resolve_input_uri.dart' show isWindows;
|
||||
|
||||
import 'severity.dart' show Severity, severityPrefixes;
|
||||
|
||||
import 'scanner/characters.dart' show $CARET, $SPACE, $TAB;
|
||||
|
@ -74,7 +76,8 @@ String format(LocatedMessage message, Severity severity, {Location location}) {
|
|||
}
|
||||
|
||||
if (message.uri != null) {
|
||||
String path = relativizeUri(translateSdk(message.uri));
|
||||
String path =
|
||||
relativizeUri(Uri.base, translateSdk(message.uri), isWindows);
|
||||
int offset = message.charOffset;
|
||||
location ??= (offset == -1 ? null : getLocation(message.uri, offset));
|
||||
if (location?.line == TreeNode.noOffset) {
|
||||
|
|
|
@ -17,6 +17,8 @@ import 'kernel/type_labeler.dart';
|
|||
|
||||
import 'severity.dart' show Severity;
|
||||
|
||||
import 'resolve_input_uri.dart' show isWindows;
|
||||
|
||||
import 'util/relativize.dart' as util show relativizeUri;
|
||||
|
||||
part 'fasta_codes_generated.dart';
|
||||
|
@ -251,7 +253,7 @@ String relativizeUri(Uri uri) {
|
|||
// (otherwise, we might get an `UNUSED_IMPORT` warning).
|
||||
//
|
||||
// 2. We can change `base` argument here if needed.
|
||||
return util.relativizeUri(uri, base: Uri.base);
|
||||
return uri == null ? null : util.relativizeUri(Uri.base, uri, isWindows);
|
||||
}
|
||||
|
||||
typedef SummaryTemplate = Message Function(int, int, num, num, num);
|
||||
|
|
|
@ -52,6 +52,8 @@ import '../messages.dart' show LocatedMessage;
|
|||
import '../fasta_codes.dart'
|
||||
show templateInternalProblemUnhandled, templateUnspecified;
|
||||
|
||||
import '../resolve_input_uri.dart' show isWindows;
|
||||
|
||||
import '../util/relativize.dart' show relativizeUri;
|
||||
|
||||
final Uri platformBinariesLocation = computePlatformBinariesLocation();
|
||||
|
@ -232,7 +234,8 @@ class MatchExpectation extends Step<Component, Component, MatchContext> {
|
|||
});
|
||||
printer.writeConstantTable(component);
|
||||
String actual = "$buffer";
|
||||
String binariesPath = relativizeUri(platformBinariesLocation);
|
||||
String binariesPath =
|
||||
relativizeUri(Uri.base, platformBinariesLocation, isWindows);
|
||||
if (binariesPath.endsWith("/dart-sdk/lib/_internal/")) {
|
||||
// We are running from the built SDK.
|
||||
actual = actual.replaceAll(
|
||||
|
|
|
@ -4,14 +4,70 @@
|
|||
|
||||
library fasta.util.relativize;
|
||||
|
||||
// TODO(ahe): Move more advanced version from dart2js here.
|
||||
import 'dart:math';
|
||||
|
||||
final Uri currentDirectory = Uri.base;
|
||||
String relativizeUri(Uri base, Uri uri, bool isWindows) {
|
||||
bool equalsNCS(String a, String b) {
|
||||
return a.toLowerCase() == b.toLowerCase();
|
||||
}
|
||||
|
||||
String relativizeUri(Uri uri, {Uri base}) {
|
||||
if (uri == null) return null;
|
||||
base ??= currentDirectory;
|
||||
String result = "$uri";
|
||||
final prefix = "$base";
|
||||
return result.startsWith(prefix) ? result.substring(prefix.length) : result;
|
||||
if (!equalsNCS(base.scheme, uri.scheme) ||
|
||||
equalsNCS(base.scheme, 'dart') ||
|
||||
equalsNCS(base.scheme, 'package')) {
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
if (!equalsNCS(base.scheme, 'file')) {
|
||||
isWindows = false;
|
||||
}
|
||||
|
||||
String normalize(String path) {
|
||||
if (isWindows) {
|
||||
return path.toLowerCase();
|
||||
} else {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
if (base.userInfo == uri.userInfo &&
|
||||
equalsNCS(base.host, uri.host) &&
|
||||
base.port == uri.port &&
|
||||
uri.query == "" &&
|
||||
uri.fragment == "") {
|
||||
if (normalize(uri.path).startsWith(normalize(base.path))) {
|
||||
return uri.path.substring(base.path.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
if (!base.path.startsWith('/') || !uri.path.startsWith('/')) {
|
||||
return uri.toString();
|
||||
}
|
||||
|
||||
List<String> uriParts = uri.path.split('/');
|
||||
List<String> baseParts = base.path.split('/');
|
||||
int common = 0;
|
||||
int length = min(uriParts.length, baseParts.length);
|
||||
while (common < length &&
|
||||
normalize(uriParts[common]) == normalize(baseParts[common])) {
|
||||
common++;
|
||||
}
|
||||
if (common == 1 || (isWindows && common == 2)) {
|
||||
// The first part will always be an empty string because the
|
||||
// paths are absolute. On Windows, we must also consider drive
|
||||
// letters or hostnames.
|
||||
if (baseParts.length > common + 1) {
|
||||
// Avoid using '..' to go to the root, unless we are already there.
|
||||
return uri.path;
|
||||
}
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = common + 1; i < baseParts.length; i++) {
|
||||
sb.write('../');
|
||||
}
|
||||
for (int i = common; i < uriParts.length - 1; i++) {
|
||||
sb.write('${uriParts[i]}/');
|
||||
}
|
||||
sb.write('${uriParts.last}');
|
||||
return sb.toString();
|
||||
}
|
||||
return uri.toString();
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import "package:expect/expect.dart";
|
||||
|
||||
import 'package:compiler/src/util/uri_extras.dart';
|
||||
import 'package:front_end/src/fasta/util/relativize.dart';
|
||||
|
||||
void testRelativize() {
|
||||
void c(String expected, String base, String path, bool isWindows) {
|
||||
|
@ -15,7 +15,7 @@ void testRelativize() {
|
|||
}
|
||||
|
||||
test(Uri base, Uri uri) {
|
||||
String r = relativize(base, uri, isWindows);
|
||||
String r = relativizeUri(base, uri, isWindows);
|
||||
Uri resolved = base.resolve(r);
|
||||
Expect.equals(uri.scheme.toLowerCase(), resolved.scheme.toLowerCase());
|
||||
if (isWindows) {
|
|
@ -10,6 +10,7 @@ import 'dart:convert' show LineSplitter, jsonDecode, jsonEncode, utf8;
|
|||
|
||||
import 'dart:io' show File, Platform, exitCode, stderr, stdin, stdout;
|
||||
|
||||
import 'package:front_end/src/fasta/resolve_input_uri.dart';
|
||||
import 'package:kernel/kernel.dart'
|
||||
show CanonicalName, Library, Component, Source, loadComponentFromBytes;
|
||||
|
||||
|
@ -383,7 +384,7 @@ Future<void> writeDepsFile(
|
|||
//
|
||||
// ninja explain: expected depfile 'vm_platform.dill.d' to mention \
|
||||
// 'vm_platform.dill', got '/.../xcodebuild/ReleaseX64/vm_platform.dill'
|
||||
return Uri.parse(relativizeUri(uri, base: Uri.base)).toFilePath();
|
||||
return Uri.parse(relativizeUri(Uri.base, uri, isWindows)).toFilePath();
|
||||
}
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
|
|
@ -6233,7 +6233,7 @@ TEST_CASE(DartAPI_ImportLibrary3) {
|
|||
lib = TestCase::LoadTestScriptWithDFE(sourcefiles_count, sourcefiles, NULL,
|
||||
true);
|
||||
EXPECT_ERROR(lib,
|
||||
"Compilation failed file:///test-lib:4:10:"
|
||||
"Compilation failed /test-lib:4:10:"
|
||||
" Error: Setter not found: 'foo'");
|
||||
return;
|
||||
|
||||
|
|
|
@ -1700,7 +1700,7 @@ TEST_CASE(IsolateReload_TearOff_Parameter_Count_Mismatch) {
|
|||
|
||||
const char* error;
|
||||
error =
|
||||
"file:///test-lib:8:12: Error: Too few positional"
|
||||
"/test-lib:8:12: Error: Too few positional"
|
||||
" arguments: 1 required, 0 given.\n"
|
||||
" return f1();";
|
||||
EXPECT_ERROR(error_handle, error);
|
||||
|
|
|
@ -259,7 +259,7 @@ ISOLATE_UNIT_TEST_CASE(SourceReport_Coverage_UnusedClass_ForceCompileError) {
|
|||
"\"error\":{\"type\":\"@Error\",\"_vmType\":\"LanguageError\","
|
||||
"\"kind\":\"LanguageError\",\"id\":\"objects\\/0\","
|
||||
"\"message\":\"'file:\\/\\/\\/test-lib': error: "
|
||||
"file:\\/\\/\\/test-lib:3:26: "
|
||||
"\\/test-lib:3:26: "
|
||||
"Error: This couldn't be parsed.\\n"
|
||||
" helper1() { helper0()+ }\\n ^\"}},"
|
||||
|
||||
|
|
|
@ -17,11 +17,10 @@ import 'package:compiler/src/ir/static_type.dart';
|
|||
import 'package:compiler/src/ir/util.dart';
|
||||
import 'package:compiler/src/kernel/dart2js_target.dart';
|
||||
import 'package:compiler/src/kernel/loader.dart';
|
||||
import 'package:compiler/src/util/uri_extras.dart';
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:front_end/src/api_prototype/constant_evaluator.dart' as ir;
|
||||
import 'package:front_end/src/api_unstable/dart2js.dart'
|
||||
show isRedirectingFactory;
|
||||
show isRedirectingFactory, relativizeUri;
|
||||
import 'package:kernel/ast.dart' as ir;
|
||||
import 'package:kernel/class_hierarchy.dart' as ir;
|
||||
import 'package:kernel/core_types.dart' as ir;
|
||||
|
@ -240,11 +239,11 @@ class DynamicVisitor extends StaticTypeVisitorBase {
|
|||
********************************************************************************
|
||||
* Unexpected dynamic invocations found by test:
|
||||
*
|
||||
* ${relativize(Uri.base, Platform.script, Platform.isWindows)}
|
||||
* ${relativizeUri(Uri.base, Platform.script, Platform.isWindows)}
|
||||
*
|
||||
* Please address the reported errors, or, if the errors are as expected, run
|
||||
*
|
||||
* dart ${relativize(Uri.base, Platform.script, Platform.isWindows)} -g
|
||||
* dart ${relativizeUri(Uri.base, Platform.script, Platform.isWindows)} -g
|
||||
*
|
||||
* to update the expectation file.
|
||||
********************************************************************************
|
||||
|
@ -372,7 +371,7 @@ class DynamicVisitor extends StaticTypeVisitorBase {
|
|||
void registerError(ir.Node node, String message) {
|
||||
SourceSpan span = computeSourceSpanFromTreeNode(node);
|
||||
Uri uri = span.uri;
|
||||
String uriString = relativize(Uri.base, uri, Platform.isWindows);
|
||||
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') {
|
||||
|
|
|
@ -15,7 +15,7 @@ import 'package:compiler/src/commandline_options.dart';
|
|||
import 'package:compiler/src/null_compiler_output.dart';
|
||||
import 'package:compiler/src/options.dart';
|
||||
import 'package:compiler/src/source_file_provider.dart';
|
||||
import 'package:compiler/src/util/uri_extras.dart';
|
||||
import 'package:front_end/src/api_unstable/dart2js.dart' as fe;
|
||||
import 'package:compiler/src/inferrer/debug.dart' show PRINT_GRAPH;
|
||||
import 'package:compiler/src/tracer.dart' show TRACE_FILTER_PATTERN_FOR_TEST;
|
||||
import 'package:expect/expect.dart';
|
||||
|
@ -28,7 +28,7 @@ class TestRandomAccessFileOutputProvider implements CompilerOutput {
|
|||
|
||||
@override
|
||||
OutputSink createOutputSink(String name, String extension, OutputType type) {
|
||||
outputs.add(relativize(provider.out,
|
||||
outputs.add(fe.relativizeUri(provider.out,
|
||||
provider.createUri(name, extension, type), Platform.isWindows));
|
||||
return NullSink.outputProvider(name, extension, type);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue