From 86ef569471ea01c56521af0c44061e763746ad31 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:32:26 -0700 Subject: [PATCH 1/3] Update load strategy with changes needed for debugging tests internally --- dwds/lib/src/loaders/strategy.dart | 16 ++++++++++++++++ dwds/lib/src/utilities/dart_uri.dart | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/dwds/lib/src/loaders/strategy.dart b/dwds/lib/src/loaders/strategy.dart index 77f43acd8..820653c1d 100644 --- a/dwds/lib/src/loaders/strategy.dart +++ b/dwds/lib/src/loaders/strategy.dart @@ -2,6 +2,8 @@ // 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. +import 'dart:typed_data'; + import 'package:dwds/src/debugging/metadata/provider.dart'; import 'package:dwds/src/readers/asset_reader.dart'; import 'package:dwds/src/services/expression_compiler.dart'; @@ -41,6 +43,10 @@ abstract class LoadStrategy { /// argument which is the module name to load. String get loadModuleSnippet; + /// The relative root path for library paths. The current directory will be + /// used if this is not overridden. + String? get libraryRoot => null; + /// The reload configuration for this strategy, e.g. liveReload. ReloadConfiguration get reloadConfiguration; @@ -107,6 +113,16 @@ abstract class LoadStrategy { /// Returns `null` if not a google3 app. String? g3RelativePath(String absolutePath); + + /// Returns a loader to read the content of the package configuration. + /// + /// The package configuration URIs will be resolved relative to + /// [packageConfigPath], but the loader can read the config from a different + /// location. + /// + /// If null, the default loader will read from `packageConfigPath`. + Future Function(Uri uri)? get packageConfigLoader => null; + /// The absolute path to the app's package configuration. String get packageConfigPath { return _packageConfigPath ?? _defaultPackageConfigPath; diff --git a/dwds/lib/src/utilities/dart_uri.dart b/dwds/lib/src/utilities/dart_uri.dart index f8aa66ab2..c93e46697 100644 --- a/dwds/lib/src/utilities/dart_uri.dart +++ b/dwds/lib/src/utilities/dart_uri.dart @@ -211,6 +211,7 @@ class DartUri { static Future _loadPackageConfig(Uri uri) async { _packageConfig = await loadPackageConfigUri( uri, + loader: globalToolConfiguration.loadStrategy.packageConfigLoader, onError: (e) { _logger.warning('Cannot read packages spec: $uri', e); }, @@ -237,7 +238,9 @@ class DartUri { // Both currentDirectoryUri and the libraryUri path should have '/' // separators, so we can join them as url paths to get the absolute file // url. - libraryPath = p.url.join(currentDirectoryUri, uri.path.substring(1)); + final libraryRoot = globalToolConfiguration.loadStrategy.libraryRoot; + libraryPath = p.url + .join(libraryRoot ?? currentDirectoryUri, uri.path.substring(1)); break; case 'package': libraryPath = _packageConfig?.resolve(uri)?.toString(); From b68b43a7b074f2d91928dc23f80b509854dfd025 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:35:16 -0700 Subject: [PATCH 2/3] Update dartdoc --- dwds/lib/src/loaders/strategy.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwds/lib/src/loaders/strategy.dart b/dwds/lib/src/loaders/strategy.dart index 820653c1d..ea2312a8a 100644 --- a/dwds/lib/src/loaders/strategy.dart +++ b/dwds/lib/src/loaders/strategy.dart @@ -120,7 +120,7 @@ abstract class LoadStrategy { /// [packageConfigPath], but the loader can read the config from a different /// location. /// - /// If null, the default loader will read from `packageConfigPath`. + /// If null, the default loader will read from [packageConfigPath]. Future Function(Uri uri)? get packageConfigLoader => null; /// The absolute path to the app's package configuration. From ee8c10afe32d32547f951b6257d37e670d0f46d1 Mon Sep 17 00:00:00 2001 From: Elliott Brooks <21270878+elliette@users.noreply.github.com> Date: Tue, 26 Mar 2024 09:01:36 -0700 Subject: [PATCH 3/3] Format --- dwds/lib/src/loaders/strategy.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/dwds/lib/src/loaders/strategy.dart b/dwds/lib/src/loaders/strategy.dart index ea2312a8a..a8b077d42 100644 --- a/dwds/lib/src/loaders/strategy.dart +++ b/dwds/lib/src/loaders/strategy.dart @@ -113,7 +113,6 @@ abstract class LoadStrategy { /// Returns `null` if not a google3 app. String? g3RelativePath(String absolutePath); - /// Returns a loader to read the content of the package configuration. /// /// The package configuration URIs will be resolved relative to