From 972d4e9a754a2859e2de19c205140e3d8adcae54 Mon Sep 17 00:00:00 2001 From: Johnni Winther Date: Thu, 1 Aug 2019 21:07:50 +0000 Subject: [PATCH] [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 Commit-Queue: Johnni Winther --- pkg/compiler/lib/src/dart2js.dart | 32 ++++---- pkg/compiler/lib/src/deferred_load.dart | 5 +- .../lib/src/diagnostics/code_location.dart | 6 +- .../lib/src/io/source_map_builder.dart | 10 +-- .../lib/src/source_file_provider.dart | 17 +++-- pkg/compiler/lib/src/util/uri_extras.dart | 73 ------------------- pkg/compiler/tool/generate_kernel.dart | 6 +- .../lib/src/base/libraries_specification.dart | 5 +- .../lib/src/fasta/command_line_reporting.dart | 5 +- pkg/front_end/lib/src/fasta/fasta_codes.dart | 4 +- .../lib/src/fasta/testing/kernel_chain.dart | 5 +- .../lib/src/fasta/util/relativize.dart | 72 ++++++++++++++++-- .../front_end/test/relativize_test.dart | 4 +- pkg/front_end/tool/_fasta/entry_points.dart | 3 +- runtime/vm/dart_api_impl_test.cc | 2 +- runtime/vm/isolate_reload_test.cc | 2 +- runtime/vm/source_report_test.cc | 2 +- .../dart2js/analyses/analysis_helper.dart | 9 +-- .../dart2js/end_to_end/output_type_test.dart | 4 +- 19 files changed, 132 insertions(+), 134 deletions(-) delete mode 100644 pkg/compiler/lib/src/util/uri_extras.dart rename tests/compiler/dart2js/model/uri_extras_test.dart => pkg/front_end/test/relativize_test.dart (95%) diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart index f961525e4c97..2ff28bde325c 100644 --- a/pkg/compiler/lib/src/dart2js.dart +++ b/pkg/compiler/lib/src/dart2js.dart @@ -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 compile(List 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 compile(List 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 compile(List 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) { diff --git a/pkg/compiler/lib/src/deferred_load.dart b/pkg/compiler/lib/src/deferred_load.dart index a501c3bcb96c..67332bec9bb5 100644 --- a/pkg/compiler/lib/src/deferred_load.dart +++ b/pkg/compiler/lib/src/deferred_load.dart @@ -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); diff --git a/pkg/compiler/lib/src/diagnostics/code_location.dart b/pkg/compiler/lib/src/diagnostics/code_location.dart index 8e923f96eaed..17b48f631d20 100644 --- a/pkg/compiler/lib/src/diagnostics/code_location.dart +++ b/pkg/compiler/lib/src/diagnostics/code_location.dart @@ -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); } } diff --git a/pkg/compiler/lib/src/io/source_map_builder.dart b/pkg/compiler/lib/src/io/source_map_builder.dart index 0e88362ff4f5..654c87bd34f5 100644 --- a/pkg/compiler/lib/src/io/source_map_builder.dart +++ b/pkg/compiler/lib/src/io/source_map_builder.dart @@ -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 relativeSourceUriList = const []; 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 diff --git a/pkg/compiler/lib/src/source_file_provider.dart b/pkg/compiler/lib/src/source_file_provider.dart index 3a6f81a3afa3..5cfda65bd6a9 100644 --- a/pkg/compiler/lib/src/source_file_provider.dart +++ b/pkg/compiler/lib/src/source_file_provider.dart @@ -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> 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'); } diff --git a/pkg/compiler/lib/src/util/uri_extras.dart b/pkg/compiler/lib/src/util/uri_extras.dart deleted file mode 100644 index 516437889953..000000000000 --- a/pkg/compiler/lib/src/util/uri_extras.dart +++ /dev/null @@ -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 uriParts = uri.path.split('/'); - List 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(); -} diff --git a/pkg/compiler/tool/generate_kernel.dart b/pkg/compiler/tool/generate_kernel.dart index f610317483ee..f01de63d655a 100644 --- a/pkg/compiler/tool/generate_kernel.dart +++ b/pkg/compiler/tool/generate_kernel.dart @@ -33,9 +33,9 @@ main(List 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); diff --git a/pkg/front_end/lib/src/base/libraries_specification.dart b/pkg/front_end/lib/src/base/libraries_specification.dart index 7838edafa0b4..09baff1cfb99 100644 --- a/pkg/front_end/lib/src/base/libraries_specification.dart +++ b/pkg/front_end/lib/src/base/libraries_specification.dart @@ -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) { diff --git a/pkg/front_end/lib/src/fasta/command_line_reporting.dart b/pkg/front_end/lib/src/fasta/command_line_reporting.dart index 157780433ae6..2f406fb0373f 100644 --- a/pkg/front_end/lib/src/fasta/command_line_reporting.dart +++ b/pkg/front_end/lib/src/fasta/command_line_reporting.dart @@ -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) { diff --git a/pkg/front_end/lib/src/fasta/fasta_codes.dart b/pkg/front_end/lib/src/fasta/fasta_codes.dart index 53d19105077b..a0d556ef1e07 100644 --- a/pkg/front_end/lib/src/fasta/fasta_codes.dart +++ b/pkg/front_end/lib/src/fasta/fasta_codes.dart @@ -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); diff --git a/pkg/front_end/lib/src/fasta/testing/kernel_chain.dart b/pkg/front_end/lib/src/fasta/testing/kernel_chain.dart index 7f8b997126b8..8a1b4e54416d 100644 --- a/pkg/front_end/lib/src/fasta/testing/kernel_chain.dart +++ b/pkg/front_end/lib/src/fasta/testing/kernel_chain.dart @@ -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 { }); 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( diff --git a/pkg/front_end/lib/src/fasta/util/relativize.dart b/pkg/front_end/lib/src/fasta/util/relativize.dart index ab7406b1dc42..df4f926d119e 100644 --- a/pkg/front_end/lib/src/fasta/util/relativize.dart +++ b/pkg/front_end/lib/src/fasta/util/relativize.dart @@ -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 uriParts = uri.path.split('/'); + List 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(); } diff --git a/tests/compiler/dart2js/model/uri_extras_test.dart b/pkg/front_end/test/relativize_test.dart similarity index 95% rename from tests/compiler/dart2js/model/uri_extras_test.dart rename to pkg/front_end/test/relativize_test.dart index 7a500f1566f2..e279c7379b9d 100644 --- a/tests/compiler/dart2js/model/uri_extras_test.dart +++ b/pkg/front_end/test/relativize_test.dart @@ -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) { diff --git a/pkg/front_end/tool/_fasta/entry_points.dart b/pkg/front_end/tool/_fasta/entry_points.dart index 806f1aed232b..b11e45784a45 100644 --- a/pkg/front_end/tool/_fasta/entry_points.dart +++ b/pkg/front_end/tool/_fasta/entry_points.dart @@ -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 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(); diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc index e5b44d6290ae..9defa2d8d452 100644 --- a/runtime/vm/dart_api_impl_test.cc +++ b/runtime/vm/dart_api_impl_test.cc @@ -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; diff --git a/runtime/vm/isolate_reload_test.cc b/runtime/vm/isolate_reload_test.cc index 8f5c3abe9661..02e02bf50328 100644 --- a/runtime/vm/isolate_reload_test.cc +++ b/runtime/vm/isolate_reload_test.cc @@ -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); diff --git a/runtime/vm/source_report_test.cc b/runtime/vm/source_report_test.cc index 9b0070d29327..0187da59c3ca 100644 --- a/runtime/vm/source_report_test.cc +++ b/runtime/vm/source_report_test.cc @@ -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 ^\"}}," diff --git a/tests/compiler/dart2js/analyses/analysis_helper.dart b/tests/compiler/dart2js/analyses/analysis_helper.dart index 7bcf56d80bab..4b6234d74216 100644 --- a/tests/compiler/dart2js/analyses/analysis_helper.dart +++ b/tests/compiler/dart2js/analyses/analysis_helper.dart @@ -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> actualMap = _actualMessages .putIfAbsent(uriString, () => >{}); if (uri.scheme == 'org-dartlang-sdk') { diff --git a/tests/compiler/dart2js/end_to_end/output_type_test.dart b/tests/compiler/dart2js/end_to_end/output_type_test.dart index aa4dcf1dd5d1..93726a9b340c 100644 --- a/tests/compiler/dart2js/end_to_end/output_type_test.dart +++ b/tests/compiler/dart2js/end_to_end/output_type_test.dart @@ -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); }