CQ. Move PackageConfigFileBuilder to analyzer_testing.
Move PackageConfigFileBuilder into the analyzer_testing public API and deprecate the copy exposed from package:analyzer. The builder is only used by test infrastructure, so keeping it in analyzer_testing makes the ownership clearer and avoids exposing test-only utilities from analyzer. Update the builder API to accept a rootFolder instead of a rootPath. This lets callers pass the resource-provider folder directly, so the generated rootUri is derived from the same file-system abstraction that created the test files. This avoids accidentally passing POSIX paths where resource provider paths are required, such as on Windows. Update existing test utilities and callers to import the new library and pass Folder objects. Remove the production analysis server dependency on the builder by emitting the temporary plugin package config JSON directly. Change-Id: I46b14710626e0d6d5884afcdc5a05b23077acfc9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499081 Reviewed-by: Paul Berry <paulberry@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
18c3034f20
commit
e20704c3b0
@@ -26,7 +26,6 @@ import 'package:analyzer/src/util/glob.dart';
|
||||
import 'package:analyzer/src/util/platform_info.dart';
|
||||
import 'package:analyzer/src/workspace/blaze.dart';
|
||||
import 'package:analyzer/src/workspace/workspace.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_generated.dart';
|
||||
@@ -752,18 +751,18 @@ class PluginManager {
|
||||
|
||||
packages.sort((a, b) => a.name.compareTo(b.name));
|
||||
|
||||
var packageConfigBuilder = PackageConfigFileBuilder();
|
||||
for (var package in packages) {
|
||||
packageConfigBuilder.add(
|
||||
name: package.name,
|
||||
rootPath: package.root.path,
|
||||
);
|
||||
}
|
||||
packageConfigFile.writeAsStringSync(
|
||||
packageConfigBuilder.toContent(
|
||||
pathContext: _resourceProvider.pathContext,
|
||||
),
|
||||
);
|
||||
var packageConfigContent = const JsonEncoder.withIndent(' ').convert({
|
||||
'configVersion': 2,
|
||||
'packages': [
|
||||
for (var package in packages)
|
||||
{
|
||||
'name': package.name,
|
||||
'rootUri': '${package.root.toUri()}',
|
||||
'packageUri': 'lib/',
|
||||
},
|
||||
],
|
||||
});
|
||||
packageConfigFile.writeAsStringSync('$packageConfigContent\n');
|
||||
} catch (exception) {
|
||||
// If we are not able to produce a package config file, return `null` so
|
||||
// that callers will not try to load the plugin.
|
||||
|
||||
@@ -6,8 +6,8 @@ import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:linter/src/rules.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -96,7 +96,7 @@ include: package:lints/lints.yaml
|
||||
);
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'lints', rootPath: lintsRootPath),
|
||||
..add(name: 'lints', rootFolder: getFolder(lintsRootPath)),
|
||||
);
|
||||
|
||||
// Ensure the errors disappear.
|
||||
@@ -182,8 +182,8 @@ analyzer:
|
||||
|
||||
// Add the generated project into package_config.json.
|
||||
var config = PackageConfigFileBuilder();
|
||||
config.add(name: 'foo', rootPath: generatedProject);
|
||||
newFile(configPath, config.toContent(pathContext: pathContext));
|
||||
config.add(name: 'foo', rootFolder: getFolder(generatedProject));
|
||||
newFile(configPath, config.toContent());
|
||||
|
||||
// Set up project that references the class prior to initial analysis.
|
||||
var generatedFile = newFile(generatedFilePath, 'class A {}');
|
||||
|
||||
@@ -6,8 +6,8 @@ import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -89,7 +89,7 @@ class UpdateContentTest extends PubPackageAnalysisServerTest {
|
||||
writePackageConfig(
|
||||
workspaceRootPath,
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$workspaceRootPath/aaa')),
|
||||
);
|
||||
|
||||
var aaa = newFile('$workspaceRootPath/aaa/lib/aaa.dart', r'''
|
||||
|
||||
@@ -15,8 +15,8 @@ import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/file_system/memory_file_system.dart';
|
||||
import 'package:analyzer/src/generated/sdk.dart';
|
||||
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/resource_provider_mixin.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
@@ -162,10 +162,10 @@ class X extends A with M {}
|
||||
|
||||
// Write both packages, in two events so that the first one will trigger
|
||||
// a rebuild.
|
||||
config.add(name: 'foo', rootPath: fooLibFolder.parent.path);
|
||||
config.add(name: 'foo', rootFolder: fooLibFolder.parent);
|
||||
writePackageConfig(projectPackageConfigFile, config);
|
||||
await pumpEventQueue(times: 1); // Allow server to begin processing.
|
||||
config.add(name: 'bar', rootPath: barLibFolder.parent.path);
|
||||
config.add(name: 'bar', rootFolder: barLibFolder.parent);
|
||||
writePackageConfig(projectPackageConfigFile, config);
|
||||
|
||||
// Eventually the errors are gone.
|
||||
@@ -351,7 +351,7 @@ analyzer:
|
||||
}
|
||||
|
||||
void writePackageConfig(String path, PackageConfigFileBuilder config) {
|
||||
newFile(path, config.toContent(pathContext: pathContext));
|
||||
newFile(path, config.toContent());
|
||||
}
|
||||
|
||||
/// Creates a simple package named [name] with [content] in the file at
|
||||
|
||||
@@ -11,9 +11,9 @@ import 'package:analysis_server/src/plugin/plugin_locator.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
|
||||
import 'package:analyzer/src/utilities/extensions/file_system.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/utilities/utilities.dart';
|
||||
import 'package:analyzer_utilities/testing/tree_string_sink.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
@@ -447,7 +447,7 @@ AnalysisErrors
|
||||
// Write `package_config.json`, recreate analysis contexts.
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaRootPath)),
|
||||
);
|
||||
|
||||
await pumpEventQueue(times: 5000);
|
||||
@@ -997,7 +997,7 @@ AnalysisErrors
|
||||
// Write `package_config.json`, recreate analysis contexts.
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaRootPath)),
|
||||
);
|
||||
|
||||
await pumpEventQueue(times: 5000);
|
||||
@@ -1330,7 +1330,7 @@ class A {}
|
||||
// Write the empty file, without `package:aaa`.
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaRootPath)),
|
||||
);
|
||||
|
||||
newFile(testFilePath, '''
|
||||
@@ -1908,7 +1908,7 @@ class A {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaRootPath)),
|
||||
);
|
||||
|
||||
newFile(testFilePath, '''
|
||||
@@ -2133,7 +2133,8 @@ class SetAnalysisRootsTest extends PubPackageAnalysisServerTest {
|
||||
// plugins.
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()..add(name: 'plugin1', rootPath: plugin1.path),
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'plugin1', rootFolder: getFolder(plugin1.path)),
|
||||
);
|
||||
|
||||
// Set the analysis roots to the folder ('/home') that contains both
|
||||
@@ -2177,8 +2178,8 @@ class SetAnalysisRootsTest extends PubPackageAnalysisServerTest {
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'plugin1', rootPath: plugin1.path)
|
||||
..add(name: 'plugin2', rootPath: plugin2.path),
|
||||
..add(name: 'plugin1', rootFolder: getFolder(plugin1.path))
|
||||
..add(name: 'plugin2', rootFolder: getFolder(plugin2.path)),
|
||||
);
|
||||
|
||||
// Set the analysis roots to the folder ('/home') that contains both
|
||||
@@ -2220,7 +2221,8 @@ class SetAnalysisRootsTest extends PubPackageAnalysisServerTest {
|
||||
// plugins.
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()..add(name: 'plugin1', rootPath: plugin1.path),
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'plugin1', rootFolder: getFolder(plugin1.path)),
|
||||
);
|
||||
|
||||
// Set the analysis roots to the folder ('/home') that contains both
|
||||
@@ -2261,7 +2263,8 @@ class SetAnalysisRootsTest extends PubPackageAnalysisServerTest {
|
||||
// plugins.
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()..add(name: 'plugin1', rootPath: plugin1.path),
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'plugin1', rootFolder: getFolder(plugin1.path)),
|
||||
);
|
||||
|
||||
// Set the analysis roots to the folder ('/home') that contains both
|
||||
@@ -2313,8 +2316,8 @@ class SetAnalysisRootsTest extends PubPackageAnalysisServerTest {
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'plugin1', rootPath: plugin1.path)
|
||||
..add(name: 'plugin2', rootPath: plugin2.path),
|
||||
..add(name: 'plugin1', rootFolder: getFolder(plugin1.path))
|
||||
..add(name: 'plugin2', rootFolder: getFolder(plugin2.path)),
|
||||
);
|
||||
|
||||
// Set the analysis roots to the folder ('/home') that contains both
|
||||
@@ -2355,8 +2358,8 @@ class SetAnalysisRootsTest extends PubPackageAnalysisServerTest {
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'plugin1', rootPath: plugin1.path)
|
||||
..add(name: 'plugin2', rootPath: plugin2.path),
|
||||
..add(name: 'plugin1', rootFolder: getFolder(plugin1.path))
|
||||
..add(name: 'plugin2', rootFolder: getFolder(plugin2.path)),
|
||||
);
|
||||
|
||||
// Set the analysis roots to the folder ('/home') that contains both
|
||||
@@ -2396,7 +2399,8 @@ class SetAnalysisRootsTest extends PubPackageAnalysisServerTest {
|
||||
// Write the single package config at the root that can resolve the plugin.
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()..add(name: 'plugin1', rootPath: plugin1.path),
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'plugin1', rootFolder: getFolder(plugin1.path)),
|
||||
);
|
||||
|
||||
// Set the analysis roots to the folder ('/home') that contains the
|
||||
@@ -2447,9 +2451,12 @@ class SetAnalysisRootsTest extends PubPackageAnalysisServerTest {
|
||||
|
||||
if (withPackageConfig) {
|
||||
var packageConfig = PackageConfigFileBuilder()
|
||||
..add(name: name, rootPath: packagePath);
|
||||
..add(name: name, rootFolder: getFolder(packagePath));
|
||||
for (var plugin in plugins) {
|
||||
packageConfig.add(name: plugin.name, rootPath: plugin.path);
|
||||
packageConfig.add(
|
||||
name: plugin.name,
|
||||
rootFolder: getFolder(plugin.path),
|
||||
);
|
||||
}
|
||||
newPackageConfigJsonFileFromBuilder(packagePath, packageConfig);
|
||||
}
|
||||
@@ -2516,7 +2523,7 @@ class A {}
|
||||
writePackageConfig(
|
||||
convertPath('/project'),
|
||||
config: (PackageConfigFileBuilder()
|
||||
..add(name: 'pkgA', rootPath: convertPath('/packages/pkgA'))),
|
||||
..add(name: 'pkgA', rootFolder: getFolder('/packages/pkgA'))),
|
||||
);
|
||||
//
|
||||
addTestFile('''
|
||||
@@ -2568,7 +2575,7 @@ class A {}
|
||||
writePackageConfig(
|
||||
convertPath('/project'),
|
||||
config: (PackageConfigFileBuilder()
|
||||
..add(name: 'pkgA', rootPath: convertPath('/packages/pkgA'))),
|
||||
..add(name: 'pkgA', rootFolder: getFolder('/packages/pkgA'))),
|
||||
);
|
||||
//
|
||||
addTestFile('// no "pkgA" reference');
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:analysis_server/src/protocol_server.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/src/test_utilities/platform.dart';
|
||||
import 'package:analyzer/src/test_utilities/test_code_format.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -110,8 +110,7 @@ class Test {}
|
||||
''');
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRoot.path),
|
||||
config: PackageConfigFileBuilder()..add(name: 'aaa', rootFolder: aaaRoot),
|
||||
);
|
||||
|
||||
await _configureWithWorkspaceRoot();
|
||||
@@ -789,8 +788,8 @@ class A02 {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRoot.path)
|
||||
..add(name: 'bbb', rootPath: bbbRoot.path),
|
||||
..add(name: 'aaa', rootFolder: aaaRoot)
|
||||
..add(name: 'bbb', rootFolder: bbbRoot),
|
||||
);
|
||||
|
||||
await _configureWithWorkspaceRoot();
|
||||
@@ -843,8 +842,8 @@ class A04 {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRoot.path)
|
||||
..add(name: 'bbb', rootPath: bbbRoot.path),
|
||||
..add(name: 'aaa', rootFolder: aaaRoot)
|
||||
..add(name: 'bbb', rootFolder: bbbRoot),
|
||||
);
|
||||
|
||||
await _configureWithWorkspaceRoot();
|
||||
@@ -893,8 +892,8 @@ class A04 {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRoot.path)
|
||||
..add(name: 'bbb', rootPath: bbbRoot.path),
|
||||
..add(name: 'aaa', rootFolder: aaaRoot)
|
||||
..add(name: 'bbb', rootFolder: bbbRoot),
|
||||
);
|
||||
|
||||
await _configureWithWorkspaceRoot();
|
||||
@@ -945,8 +944,8 @@ class A02 {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRoot.path)
|
||||
..add(name: 'bbb', rootPath: bbbRoot.path),
|
||||
..add(name: 'aaa', rootFolder: aaaRoot)
|
||||
..add(name: 'bbb', rootFolder: bbbRoot),
|
||||
);
|
||||
|
||||
await _configureWithWorkspaceRoot();
|
||||
|
||||
@@ -10,9 +10,9 @@ import 'package:analysis_server/src/services/correction/fix_internal.dart';
|
||||
import 'package:analysis_server/src/session_logger/session_logger.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/instrumentation/service.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -196,7 +196,7 @@ print(1)
|
||||
writePackageConfig(
|
||||
convertPath('$workspaceRootPath/aaa'),
|
||||
config: (PackageConfigFileBuilder()
|
||||
..add(name: 'bbb', rootPath: '$workspaceRootPath/bbb')),
|
||||
..add(name: 'bbb', rootFolder: getFolder('$workspaceRootPath/bbb'))),
|
||||
);
|
||||
newPubspecYamlFile('$workspaceRootPath/aaa', r'''
|
||||
dependencies:
|
||||
|
||||
@@ -9,9 +9,9 @@ import 'package:analysis_server/src/services/correction/assist_internal.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix_internal.dart';
|
||||
import 'package:analyzer/src/lint/registry.dart';
|
||||
import 'package:analyzer/src/test_utilities/test_code_format.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart' as plugin;
|
||||
import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:linter/src/rules.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
@@ -300,7 +300,7 @@ void f() {
|
||||
var onePackagePath = convertPath('/home/one');
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'one', rootPath: onePackagePath),
|
||||
..add(name: 'one', rootFolder: getFolder(onePackagePath)),
|
||||
);
|
||||
newFile(convertPath('$onePackagePath/lib/one.dart'), '''
|
||||
@deprecated
|
||||
@@ -324,7 +324,7 @@ void f() {
|
||||
var onePackagePath = convertPath('/home/one');
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'one', rootPath: onePackagePath),
|
||||
..add(name: 'one', rootFolder: getFolder(onePackagePath)),
|
||||
);
|
||||
newFile(convertPath('$onePackagePath/lib/one.dart'), '''
|
||||
@deprecated
|
||||
@@ -646,7 +646,7 @@ linter:
|
||||
writePackageConfig(
|
||||
projectPackagePath,
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'my_lints', rootPath: lintsPackagePath),
|
||||
..add(name: 'my_lints', rootFolder: getFolder(lintsPackagePath)),
|
||||
);
|
||||
newFile('$projectPackagePath/analysis_options.yaml', '''
|
||||
include: package:my_lints/analysis_options.yaml
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:analysis_server/src/lsp/constants.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:language_server_protocol/protocol_custom_generated.dart';
|
||||
import 'package:language_server_protocol/protocol_generated.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -365,8 +365,8 @@ Widget b() => Text('B');
|
||||
|
||||
var config = PackageConfigFileBuilder();
|
||||
// Do NOT add 'test' package here as writeTestPackageConfig will add it.
|
||||
config.add(name: 'a', rootPath: join(projectFolderPath, 'pkgs', 'a'));
|
||||
config.add(name: 'b', rootPath: join(projectFolderPath, 'pkgs', 'b'));
|
||||
config.add(name: 'a', rootFolder: getFolder('$projectFolderPath/pkgs/a'));
|
||||
config.add(name: 'b', rootFolder: getFolder('$projectFolderPath/pkgs/b'));
|
||||
|
||||
writeTestPackageConfig(config: config, flutter: true);
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import 'package:analysis_server/lsp_protocol/protocol.dart';
|
||||
import 'package:analysis_server/src/legacy_analysis_server.dart';
|
||||
import 'package:analysis_server/src/lsp/constants.dart';
|
||||
import 'package:analyzer/src/test_utilities/test_code_format.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/experiments/experiments.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -233,7 +233,7 @@ environment:
|
||||
sdk: ^3.7.0
|
||||
''');
|
||||
var config = PackageConfigFileBuilder();
|
||||
config.add(name: 'a', rootPath: join(projectFolderPath, 'pkgs', 'a'));
|
||||
config.add(name: 'a', rootFolder: getFolder('$projectFolderPath/pkgs/a'));
|
||||
writeTestPackageConfig(config: config, flutter: true);
|
||||
|
||||
var fileUri = toUri(
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -231,7 +231,7 @@ class B extends A {}
|
||||
// reference the package from a project
|
||||
writeTestPackageConfig(
|
||||
config: (PackageConfigFileBuilder()
|
||||
..add(name: 'pkgA', rootPath: '$packagesRootPath/pkgA')),
|
||||
..add(name: 'pkgA', rootFolder: getFolder('$packagesRootPath/pkgA'))),
|
||||
);
|
||||
addTestFile('''
|
||||
import 'package:pkgA/libA.dart';
|
||||
|
||||
@@ -2,8 +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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../../../../client/completion_driver_test.dart';
|
||||
@@ -77,8 +77,8 @@ suggestions
|
||||
var barRootPath = '$workspaceRootPath/bar';
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: fooRootPath)
|
||||
..add(name: 'bar', rootPath: barRootPath),
|
||||
..add(name: 'foo', rootFolder: getFolder(fooRootPath))
|
||||
..add(name: 'bar', rootFolder: getFolder(barRootPath)),
|
||||
);
|
||||
newFile('$fooRootPath/lib/foo.dart', '''
|
||||
library foo;
|
||||
@@ -659,8 +659,8 @@ suggestions
|
||||
var barRootPath = '$workspaceRootPath/bar';
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: fooRootPath)
|
||||
..add(name: 'bar', rootPath: barRootPath),
|
||||
..add(name: 'foo', rootFolder: getFolder(fooRootPath))
|
||||
..add(name: 'bar', rootFolder: getFolder(barRootPath)),
|
||||
);
|
||||
newFile('$fooRootPath/lib/foo.dart', '''
|
||||
|
||||
@@ -706,8 +706,8 @@ suggestions
|
||||
var barRootPath = '$workspaceRootPath/bar';
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: fooRootPath)
|
||||
..add(name: 'bar', rootPath: barRootPath),
|
||||
..add(name: 'foo', rootFolder: getFolder(fooRootPath))
|
||||
..add(name: 'bar', rootFolder: getFolder(barRootPath)),
|
||||
);
|
||||
newFile('$fooRootPath/lib/foo.dart', '''
|
||||
|
||||
@@ -737,8 +737,8 @@ suggestions
|
||||
var barRootPath = '$workspaceRootPath/bar';
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: fooRootPath)
|
||||
..add(name: 'bar', rootPath: barRootPath),
|
||||
..add(name: 'foo', rootFolder: getFolder(fooRootPath))
|
||||
..add(name: 'bar', rootFolder: getFolder(barRootPath)),
|
||||
);
|
||||
newFile('$fooRootPath/lib/foo.dart', '''
|
||||
|
||||
@@ -768,8 +768,8 @@ suggestions
|
||||
var barRootPath = '$workspaceRootPath/bar';
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: fooRootPath)
|
||||
..add(name: 'bar', rootPath: barRootPath),
|
||||
..add(name: 'foo', rootFolder: getFolder(fooRootPath))
|
||||
..add(name: 'bar', rootFolder: getFolder(barRootPath)),
|
||||
);
|
||||
newFile('$fooRootPath/lib/foo.dart', '''
|
||||
|
||||
@@ -799,7 +799,7 @@ suggestions
|
||||
var barRootPath = '$workspaceRootPath/bar';
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'bar', rootPath: barRootPath),
|
||||
..add(name: 'bar', rootFolder: getFolder(barRootPath)),
|
||||
);
|
||||
await computeSuggestions('''
|
||||
import "p^" class
|
||||
@@ -828,8 +828,8 @@ suggestions
|
||||
var barRootPath = '$workspaceRootPath/bar';
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: fooRootPath)
|
||||
..add(name: 'bar', rootPath: barRootPath),
|
||||
..add(name: 'foo', rootFolder: getFolder(fooRootPath))
|
||||
..add(name: 'bar', rootFolder: getFolder(barRootPath)),
|
||||
);
|
||||
newFile('$fooRootPath/lib/foo.dart', '''
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -90,8 +90,8 @@ import '$uriContent';
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: fooPackageRoot.path)
|
||||
..add(name: 'bar', rootPath: barPackageRoot.path),
|
||||
..add(name: 'foo', rootFolder: fooPackageRoot)
|
||||
..add(name: 'bar', rootFolder: barPackageRoot),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -2,7 +2,7 @@
|
||||
// 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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../../../../client/completion_driver_test.dart';
|
||||
@@ -250,7 +250,7 @@ class A {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'other', rootPath: otherRoot.path),
|
||||
..add(name: 'other', rootFolder: otherRoot),
|
||||
meta: true,
|
||||
);
|
||||
|
||||
@@ -603,7 +603,7 @@ class A {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'other', rootPath: otherRoot.path),
|
||||
..add(name: 'other', rootFolder: otherRoot),
|
||||
meta: true,
|
||||
);
|
||||
|
||||
@@ -637,7 +637,7 @@ class A {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'other', rootPath: otherRoot.path),
|
||||
..add(name: 'other', rootFolder: otherRoot),
|
||||
meta: true,
|
||||
);
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ import 'package:analyzer/src/summary2/reference.dart';
|
||||
import 'package:analyzer/src/test_utilities/platform.dart';
|
||||
import 'package:analyzer/src/test_utilities/test_code_format.dart';
|
||||
import 'package:analyzer/src/utilities/extensions/file_system.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
@@ -600,7 +600,7 @@ void test(int a, int b) {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$packagesRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$packagesRootPath/foo')),
|
||||
);
|
||||
|
||||
var availability = await _analyzeAvailability(r'''
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
import 'package:analysis_server/src/services/refactoring/legacy/extract_method.dart';
|
||||
import 'package:analyzer/source/source.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_plugin/src/utilities/string_utilities.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/utilities/utilities.dart';
|
||||
import 'package:linter/src/rules.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -243,8 +243,8 @@ class A {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa')
|
||||
..add(name: 'bbb', rootPath: '$workspaceRootPath/bbb'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$workspaceRootPath/aaa'))
|
||||
..add(name: 'bbb', rootFolder: getFolder('$workspaceRootPath/bbb')),
|
||||
);
|
||||
|
||||
await resolveTestCode('''
|
||||
@@ -270,8 +270,8 @@ import 'package:bbb/bbb.dart';
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa')
|
||||
..add(name: 'bbb', rootPath: '$workspaceRootPath/bbb'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$workspaceRootPath/aaa'))
|
||||
..add(name: 'bbb', rootFolder: getFolder('$workspaceRootPath/bbb')),
|
||||
);
|
||||
|
||||
await resolveTestCode('''
|
||||
@@ -299,10 +299,10 @@ import 'package:bbb/bbb.dart';
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa')
|
||||
..add(name: 'bbb', rootPath: '$workspaceRootPath/bbb')
|
||||
..add(name: 'ccc', rootPath: '$workspaceRootPath/ccc')
|
||||
..add(name: 'ddd', rootPath: '$workspaceRootPath/ddd'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$workspaceRootPath/aaa'))
|
||||
..add(name: 'bbb', rootFolder: getFolder('$workspaceRootPath/bbb'))
|
||||
..add(name: 'ccc', rootFolder: getFolder('$workspaceRootPath/ccc'))
|
||||
..add(name: 'ddd', rootFolder: getFolder('$workspaceRootPath/ddd')),
|
||||
);
|
||||
|
||||
await resolveTestCode('''
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/test_utilities/test_code_format.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -1373,7 +1373,7 @@ processObj(p) {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$packagesRootPath/aaa'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$packagesRootPath/aaa')),
|
||||
);
|
||||
|
||||
await indexTestUnit('''
|
||||
@@ -1456,7 +1456,7 @@ void foo(A a) {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$workspaceRootPath/aaa')),
|
||||
);
|
||||
|
||||
await indexTestUnit('''
|
||||
|
||||
@@ -2,8 +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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -264,7 +264,7 @@ class A {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$workspaceRootPath/aaa')),
|
||||
);
|
||||
|
||||
await indexTestUnit('''
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:analyzer/src/test_utilities/find_element2.dart';
|
||||
import 'package:analyzer/src/test_utilities/find_node.dart';
|
||||
import 'package:analyzer/src/test_utilities/test_code_format.dart';
|
||||
import 'package:analyzer/src/util/performance/operation_performance.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
@@ -740,7 +740,7 @@ class B extends A {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaRootPath)),
|
||||
);
|
||||
|
||||
return aaaRootPath;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
|
||||
/// A common interface that can be implemented by a set of base classes to
|
||||
/// allow tests to be written to run in different configurations
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/computer/import_elements_computer.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/utilities/utilities.dart';
|
||||
import 'package:linter/src/rules.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -112,7 +112,7 @@ void f() {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -132,7 +132,7 @@ import 'package:pkg/foo.dart';
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -152,7 +152,7 @@ import 'package:pkg/foo.dart' as foo;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -173,7 +173,7 @@ import 'package:pkg/foo.dart' as foo;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -192,7 +192,7 @@ import 'package:pkg/foo.dart' show A, B, C hide D;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -211,7 +211,7 @@ import 'package:pkg/foo.dart' show B, A;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -232,7 +232,7 @@ import 'package:pkg/foo.dart' as foo show B, A;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -249,7 +249,7 @@ import 'package:pkg/foo.dart';
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -266,7 +266,7 @@ import 'package:pkg/foo.dart' as foo;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -295,7 +295,7 @@ class A {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -321,7 +321,7 @@ import 'package:pkg/foo.dart';
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -340,7 +340,7 @@ import 'package:pkg/foo.dart' hide B, C;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -359,7 +359,7 @@ import 'package:pkg/foo.dart' hide A, B;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -378,7 +378,7 @@ import 'package:pkg/foo.dart' hide A, C;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -397,7 +397,7 @@ import 'package:pkg/foo.dart' hide A, C hide A, C;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -416,7 +416,7 @@ import 'package:pkg/foo.dart' hide B, C hide D, F hide G, H;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -435,7 +435,7 @@ import 'package:pkg/foo.dart' hide B hide C;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -454,7 +454,7 @@ import 'package:pkg/foo.dart' hide A hide B;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -473,7 +473,7 @@ import 'package:pkg/foo.dart' hide A hide C;
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
@@ -492,7 +492,7 @@ import 'package:pkg/foo.dart';
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await createBuilder('''
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analysis_server/src/computer/imported_elements_computer.dart';
|
||||
import 'package:analyzer/src/test_utilities/test_code_format.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -224,7 +224,7 @@ class B {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
);
|
||||
|
||||
var content = '''
|
||||
@@ -249,7 +249,7 @@ class Foo {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
);
|
||||
|
||||
var content = '''
|
||||
@@ -274,7 +274,7 @@ class Foo {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
);
|
||||
|
||||
var content = '''
|
||||
@@ -297,7 +297,7 @@ String foo() => '';
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
);
|
||||
|
||||
var content = '''
|
||||
@@ -320,7 +320,7 @@ String foo = '';
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
);
|
||||
|
||||
var content = '''
|
||||
@@ -343,7 +343,7 @@ String foo = '';
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
);
|
||||
|
||||
var content = '''
|
||||
@@ -368,7 +368,7 @@ class Foo {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
);
|
||||
|
||||
var content = '''
|
||||
@@ -394,7 +394,7 @@ class Foo {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
);
|
||||
|
||||
var content = '''
|
||||
|
||||
@@ -457,6 +457,10 @@ class PluginManagerLegacyTest with ResourceProviderMixin, _ContextRoot {
|
||||
var cRootPath = newPackage('c', ['d']);
|
||||
var dRootPath = newPackage('d');
|
||||
var pluginFile = newFile('$pluginDirPath/bin/plugin.dart', '');
|
||||
var bRootUri = getFolder(bRootPath).toUri();
|
||||
var cRootUri = getFolder(cRootPath).toUri();
|
||||
var dRootUri = getFolder(dRootPath).toUri();
|
||||
var pluginRootUri = getFolder(pluginDirPath).toUri();
|
||||
//
|
||||
// Test path computation.
|
||||
//
|
||||
@@ -472,22 +476,22 @@ class PluginManagerLegacyTest with ResourceProviderMixin, _ContextRoot {
|
||||
"packages": [
|
||||
{
|
||||
"name": "b",
|
||||
"rootUri": "${toUriStr(bRootPath)}",
|
||||
"rootUri": "$bRootUri",
|
||||
"packageUri": "lib/"
|
||||
},
|
||||
{
|
||||
"name": "c",
|
||||
"rootUri": "${toUriStr(cRootPath)}",
|
||||
"rootUri": "$cRootUri",
|
||||
"packageUri": "lib/"
|
||||
},
|
||||
{
|
||||
"name": "d",
|
||||
"rootUri": "${toUriStr(dRootPath)}",
|
||||
"rootUri": "$dRootUri",
|
||||
"packageUri": "lib/"
|
||||
},
|
||||
{
|
||||
"name": "plugin",
|
||||
"rootUri": "${toUriStr(pluginDirPath)}",
|
||||
"rootUri": "$pluginRootUri",
|
||||
"packageUri": "lib/"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'dart:async';
|
||||
import 'package:analysis_server/src/plugin/plugin_locator.dart';
|
||||
import 'package:analysis_server/src/plugin/plugin_watcher.dart';
|
||||
import 'package:analysis_server/src/utilities/mocks.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -51,7 +51,7 @@ analyzer:
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: convertPath('/foo')),
|
||||
..add(name: 'foo', rootFolder: getFolder('/foo')),
|
||||
);
|
||||
|
||||
var driver = driverFor(testFile);
|
||||
|
||||
+3
-3
@@ -5,8 +5,8 @@
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analysis_server_plugin/src/correction/change_workspace.dart';
|
||||
import 'package:analysis_server_plugin/src/correction/dart_change_workspace.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'fix_processor.dart';
|
||||
@@ -304,7 +304,7 @@ class AddMissingParameterRequiredTest_Workspace
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$workspaceRootPath/aaa')),
|
||||
);
|
||||
|
||||
_workspace = DartChangeWorkspace([await session, await sessionFor(a)]);
|
||||
@@ -325,7 +325,7 @@ void f() {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'bbb', rootPath: '$workspaceRootPath/bbb'),
|
||||
..add(name: 'bbb', rootFolder: getFolder('$workspaceRootPath/bbb')),
|
||||
);
|
||||
|
||||
await resolveTestCode('''
|
||||
|
||||
+4
-4
@@ -5,8 +5,8 @@
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analyzer/diagnostic/diagnostic.dart';
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'fix_processor.dart';
|
||||
@@ -452,7 +452,7 @@ dependencies:
|
||||
''');
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'other', rootPath: otherRoot.path),
|
||||
..add(name: 'other', rootFolder: otherRoot),
|
||||
);
|
||||
await resolveTestCode('''
|
||||
import 'package:other/exposed.dart';
|
||||
@@ -489,7 +489,7 @@ dependencies:
|
||||
''');
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'other', rootPath: otherRoot.path),
|
||||
..add(name: 'other', rootFolder: otherRoot),
|
||||
);
|
||||
await resolveTestCode('''
|
||||
import 'package:other/exposed.dart';
|
||||
@@ -1098,7 +1098,7 @@ dependencies:
|
||||
''');
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'other', rootPath: otherRoot.path),
|
||||
..add(name: 'other', rootFolder: otherRoot),
|
||||
);
|
||||
await resolveTestCode('''
|
||||
import 'package:other/exposed.dart';
|
||||
|
||||
+1
-1
@@ -3,8 +3,8 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'fix_processor.dart';
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -239,7 +239,7 @@ class C {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'pkg', rootPath: '$workspaceRootPath/pkg'),
|
||||
..add(name: 'pkg', rootFolder: getFolder('$workspaceRootPath/pkg')),
|
||||
);
|
||||
|
||||
await resolveTestCode('''
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
// 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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'data_driven_test_support.dart';
|
||||
@@ -29,7 +29,7 @@ extension IterableNullableExtension<T extends Object> on Iterable<T?> {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p')),
|
||||
);
|
||||
|
||||
addPackageDataFile('''
|
||||
@@ -79,7 +79,7 @@ extension IterableNullableExtension<T extends Object> on Iterable<T?> {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p')),
|
||||
);
|
||||
|
||||
addPackageDataFile('''
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ import 'package:analysis_server/src/services/correction/dart/data_driven.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix/data_driven/transform_set_manager.dart';
|
||||
import 'package:analysis_server_plugin/edit/dart/correction_producer.dart';
|
||||
import 'package:analysis_server_plugin/src/correction/fix_generators.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -2340,7 +2340,7 @@ class _DataDrivenTest extends BulkFixProcessorTest {
|
||||
newFile('$workspaceRootPath/p/lib/lib.dart', content);
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p')),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -10,8 +10,8 @@ import 'package:analysis_server/src/services/correction/fix/data_driven/transfor
|
||||
import 'package:analysis_server/src/services/correction/fix/data_driven/transform_set_manager.dart';
|
||||
import 'package:analyzer/diagnostic/diagnostic.dart';
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
|
||||
import '../../../../../abstract_single_unit.dart';
|
||||
import '../fix_processor.dart';
|
||||
@@ -68,7 +68,7 @@ mixin DataDrivenFixProcessorTestMixin on AbstractSingleUnitTest {
|
||||
newFile('$workspaceRootPath/p/lib/lib.dart', content);
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p')),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
import 'package:analysis_server/src/services/correction/fix/data_driven/element_descriptor.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix/data_driven/element_kind.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix/data_driven/element_matcher.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
@@ -676,7 +676,7 @@ String s = '';
|
||||
newFile('$packageRootPath/lib/other.dart', '');
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'other', rootPath: packageRootPath),
|
||||
..add(name: 'other', rootFolder: getFolder(packageRootPath)),
|
||||
);
|
||||
|
||||
await resolveTestCode('''
|
||||
|
||||
+8
-8
@@ -2,7 +2,7 @@
|
||||
// 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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'data_driven_test_support.dart';
|
||||
@@ -2755,7 +2755,7 @@ void f() {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p')),
|
||||
);
|
||||
|
||||
addPackageDataFile('''
|
||||
@@ -2818,8 +2818,8 @@ void f(CupertinoPageTransitionsBuilder builder) {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p')
|
||||
..add(name: 'p2', rootPath: '$workspaceRootPath/p2'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p'))
|
||||
..add(name: 'p2', rootFolder: getFolder('$workspaceRootPath/p2')),
|
||||
);
|
||||
|
||||
addPackageDataFile('''
|
||||
@@ -2869,7 +2869,7 @@ void f(CupertinoPageTransitionsBuilder builder) {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p')),
|
||||
);
|
||||
|
||||
addPackageDataFile('''
|
||||
@@ -2925,9 +2925,9 @@ class MyApp extends StatelessWidget {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p')
|
||||
..add(name: 'p2', rootPath: '$workspaceRootPath/p2')
|
||||
..add(name: 'p3', rootPath: '$workspaceRootPath/p3'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p'))
|
||||
..add(name: 'p2', rootFolder: getFolder('$workspaceRootPath/p2'))
|
||||
..add(name: 'p3', rootFolder: getFolder('$workspaceRootPath/p3')),
|
||||
);
|
||||
|
||||
addPackageDataFile('''
|
||||
|
||||
+7
-7
@@ -2,7 +2,7 @@
|
||||
// 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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'data_driven_test_support.dart';
|
||||
@@ -31,8 +31,8 @@ class PlatformUseCaseTest extends DataDrivenFixProcessorTest {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p')
|
||||
..add(name: 'p2', rootPath: '$workspaceRootPath/p2'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p'))
|
||||
..add(name: 'p2', rootFolder: getFolder('$workspaceRootPath/p2')),
|
||||
);
|
||||
|
||||
addPackageDataFile('''
|
||||
@@ -88,7 +88,7 @@ class HostPlatform {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p')),
|
||||
);
|
||||
|
||||
addPackageDataFile('''
|
||||
@@ -145,7 +145,7 @@ class NativePlatform {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p')),
|
||||
);
|
||||
|
||||
addPackageDataFile('''
|
||||
@@ -202,7 +202,7 @@ class NativePlatform {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p')),
|
||||
);
|
||||
|
||||
addSdkDataFile('''
|
||||
@@ -254,7 +254,7 @@ class HostPlatform {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p'),
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p')),
|
||||
);
|
||||
|
||||
addSdkDataFile('''
|
||||
|
||||
+6
-3
@@ -2,7 +2,7 @@
|
||||
// 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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'data_driven_test_support.dart';
|
||||
@@ -27,8 +27,11 @@ void expect(actual, matcher) {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'matcher', rootPath: '$workspaceRootPath/matcher')
|
||||
..add(name: 'p', rootPath: '$workspaceRootPath/p'),
|
||||
..add(
|
||||
name: 'matcher',
|
||||
rootFolder: getFolder('$workspaceRootPath/matcher'),
|
||||
)
|
||||
..add(name: 'p', rootFolder: getFolder('$workspaceRootPath/p')),
|
||||
);
|
||||
|
||||
addPackageDataFile('''
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@ import 'package:analysis_server/src/services/correction/fix/data_driven/element_
|
||||
import 'package:analysis_server/src/services/correction/fix/data_driven/transform_set_manager.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/dart/analysis/session.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -34,7 +34,7 @@ class TransformSetManagerTest extends AbstractContextTest {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p1', rootPath: '$workspaceRootPath/p1-1.0'),
|
||||
..add(name: 'p1', rootFolder: getFolder('$workspaceRootPath/p1-1.0')),
|
||||
);
|
||||
|
||||
newFile('/home/test/pubspec.yaml', '');
|
||||
@@ -63,7 +63,7 @@ class TransformSetManagerTest extends AbstractContextTest {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p1', rootPath: '$workspaceRootPath/p1'),
|
||||
..add(name: 'p1', rootFolder: getFolder('$workspaceRootPath/p1')),
|
||||
);
|
||||
|
||||
newFile('/home/test/pubspec.yaml', '');
|
||||
@@ -107,8 +107,8 @@ class TransformSetManagerTest extends AbstractContextTest {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'p1', rootPath: '$workspaceRootPath/p1')
|
||||
..add(name: 'p2', rootPath: '$workspaceRootPath/p2'),
|
||||
..add(name: 'p1', rootFolder: getFolder('$workspaceRootPath/p1'))
|
||||
..add(name: 'p2', rootFolder: getFolder('$workspaceRootPath/p2')),
|
||||
);
|
||||
|
||||
newFile('/home/test/pubspec.yaml', '');
|
||||
|
||||
+30
-16
@@ -4,8 +4,8 @@
|
||||
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'fix_processor.dart';
|
||||
@@ -754,7 +754,10 @@ class Test {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'my_pkg', rootPath: '$packagesRootPath/my_pkg'),
|
||||
..add(
|
||||
name: 'my_pkg',
|
||||
rootFolder: getFolder('$packagesRootPath/my_pkg'),
|
||||
),
|
||||
);
|
||||
|
||||
newPubspecYamlFile('/home/test', r'''
|
||||
@@ -788,7 +791,10 @@ extension E on int {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'my_pkg', rootPath: '$packagesRootPath/my_pkg'),
|
||||
..add(
|
||||
name: 'my_pkg',
|
||||
rootFolder: getFolder('$packagesRootPath/my_pkg'),
|
||||
),
|
||||
);
|
||||
|
||||
newPubspecYamlFile('/home/test', r'''
|
||||
@@ -818,7 +824,10 @@ class Test {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'my_pkg', rootPath: '$packagesRootPath/my_pkg'),
|
||||
..add(
|
||||
name: 'my_pkg',
|
||||
rootFolder: getFolder('$packagesRootPath/my_pkg'),
|
||||
),
|
||||
);
|
||||
|
||||
newPubspecYamlFile('/home/test', r'''
|
||||
@@ -1356,8 +1365,7 @@ dependencies:
|
||||
''');
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRoot.path),
|
||||
config: PackageConfigFileBuilder()..add(name: 'aaa', rootFolder: aaaRoot),
|
||||
);
|
||||
|
||||
await resolveTestCode('''
|
||||
@@ -1384,8 +1392,7 @@ dev_dependencies:
|
||||
''');
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRoot.path),
|
||||
config: PackageConfigFileBuilder()..add(name: 'aaa', rootFolder: aaaRoot),
|
||||
);
|
||||
|
||||
await resolveTestCode('''
|
||||
@@ -1406,8 +1413,7 @@ name: test
|
||||
''');
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRoot.path),
|
||||
config: PackageConfigFileBuilder()..add(name: 'aaa', rootFolder: aaaRoot),
|
||||
);
|
||||
|
||||
await resolveTestCode('''
|
||||
@@ -1878,8 +1884,7 @@ dependencies:
|
||||
''');
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaRoot.path),
|
||||
config: PackageConfigFileBuilder()..add(name: 'aaa', rootFolder: aaaRoot),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2319,7 +2324,7 @@ extension IntExtension on int {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: pkgRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(pkgRootPath)),
|
||||
);
|
||||
|
||||
updateTestPubspecFile('''
|
||||
@@ -2352,7 +2357,10 @@ class Test {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'my_pkg', rootPath: '$packagesRootPath/my_pkg'),
|
||||
..add(
|
||||
name: 'my_pkg',
|
||||
rootFolder: getFolder('$packagesRootPath/my_pkg'),
|
||||
),
|
||||
);
|
||||
|
||||
newPubspecYamlFile('/home/test', r'''
|
||||
@@ -2385,7 +2393,10 @@ class Test {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'my_pkg', rootPath: '$packagesRootPath/my_pkg'),
|
||||
..add(
|
||||
name: 'my_pkg',
|
||||
rootFolder: getFolder('$packagesRootPath/my_pkg'),
|
||||
),
|
||||
);
|
||||
|
||||
newPubspecYamlFile('/home/test', r'''
|
||||
@@ -2420,7 +2431,10 @@ extension E on int {
|
||||
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'my_pkg', rootPath: '$packagesRootPath/my_pkg'),
|
||||
..add(
|
||||
name: 'my_pkg',
|
||||
rootFolder: getFolder('$packagesRootPath/my_pkg'),
|
||||
),
|
||||
);
|
||||
|
||||
newPubspecYamlFile('/home/test', r'''
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/src/dart/analysis/experiments.dart';
|
||||
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/mock_packages/mock_packages.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/utilities/extensions/resource_provider.dart';
|
||||
|
||||
/// A mixin adding functionality to write `.dart_tool/package_config.json`
|
||||
@@ -67,21 +67,24 @@ mixin ConfigurationFilesMixin on MockPackagesMixin {
|
||||
// Add this package to its own config.
|
||||
config.add(
|
||||
name: packageName ?? pathContext.basename(projectFolderPath),
|
||||
rootPath: projectFolderPath,
|
||||
rootFolder: resourceProvider.getFolder(projectFolderPath),
|
||||
languageVersion: languageVersion ?? testPackageLanguageVersion,
|
||||
);
|
||||
|
||||
if (meta || flutter) {
|
||||
var libFolder = addMeta();
|
||||
config.add(name: 'meta', rootPath: libFolder.parent.path);
|
||||
config.add(name: 'meta', rootFolder: libFolder.parent);
|
||||
}
|
||||
|
||||
if (flutter) {
|
||||
var skyEnginePath = addSkyEngine(sdkPath: dartSdkPath).parent.path;
|
||||
config.add(name: 'sky_engine', rootPath: skyEnginePath);
|
||||
config.add(
|
||||
name: 'sky_engine',
|
||||
rootFolder: resourceProvider.getFolder(skyEnginePath),
|
||||
);
|
||||
|
||||
var flutterLibFolder = addFlutter();
|
||||
config.add(name: 'flutter', rootPath: flutterLibFolder.parent.path);
|
||||
config.add(name: 'flutter', rootFolder: flutterLibFolder.parent);
|
||||
}
|
||||
|
||||
if (addFlutterTestPackageDep) {
|
||||
@@ -104,15 +107,15 @@ void main() {
|
||||
}
|
||||
|
||||
''');
|
||||
config.add(name: 'flutter_test', rootPath: flutterTestRootPath);
|
||||
config.add(name: 'flutter_test', rootFolder: flutterTestRoot);
|
||||
}
|
||||
|
||||
if (addVectorMathPackageDep) {
|
||||
var libFolder = addVectorMath();
|
||||
config.add(name: 'vector_math', rootPath: libFolder.parent.path);
|
||||
config.add(name: 'vector_math', rootFolder: libFolder.parent);
|
||||
}
|
||||
|
||||
var content = config.toContent(pathContext: pathContext);
|
||||
var content = config.toContent();
|
||||
|
||||
var projectFolder = resourceProvider.getFolder(projectFolderPath);
|
||||
var dartToolFolder = projectFolder.getChildAssumingFolder(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## 13.1.0-dev
|
||||
|
||||
* Internal changes only
|
||||
* Deprecate `PackageConfigFileBuilder` in `package:analyzer/utilities/package_config_file_builder.dart`. Use `package:analyzer_testing/package_config_file_builder.dart` instead.
|
||||
|
||||
## 13.0.0
|
||||
|
||||
|
||||
@@ -5016,8 +5016,8 @@ package:analyzer/utilities/extensions/uri.dart:
|
||||
isImplementation (getter: bool)
|
||||
isSamePackageAs (method: bool Function(Uri))
|
||||
package:analyzer/utilities/package_config_file_builder.dart:
|
||||
PackageConfigFileBuilder (class extends Object):
|
||||
new (constructor: PackageConfigFileBuilder Function())
|
||||
PackageConfigFileBuilder (class extends Object, deprecated):
|
||||
new (constructor: PackageConfigFileBuilder Function(), deprecated)
|
||||
add (method: void Function({String? languageVersion, required String name, String packageUri, required String rootPath}))
|
||||
copy (method: PackageConfigFileBuilder Function())
|
||||
toContent (method: String Function({required Context pathContext}))
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
// 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.
|
||||
|
||||
@Deprecated('Use package:analyzer_testing/package_config_file_builder.dart.')
|
||||
library;
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
/// Helper for building `.dart_tool/package_config.json` files.
|
||||
@@ -11,6 +14,7 @@ import 'package:path/path.dart' as path;
|
||||
///
|
||||
/// Use the [add] method to add package configurations. These configurations
|
||||
/// will accumulate into one package config file with the [toContent] method.
|
||||
@Deprecated('Use PackageConfigFileBuilder from analyzer_testing')
|
||||
class PackageConfigFileBuilder {
|
||||
final List<_PackageDescription> _packages = [];
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:analyzer/src/clients/build_resolvers/build_resolvers.dart';
|
||||
import 'package:analyzer/src/context/packages.dart';
|
||||
import 'package:analyzer/src/source/package_map_resolver.dart';
|
||||
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/resource_provider_mixin.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
@@ -38,7 +38,7 @@ name: test
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
testPackageRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'test', rootPath: testPackageRootPath),
|
||||
..add(name: 'test', rootFolder: getFolder(testPackageRootPath)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import 'package:analyzer/src/utilities/extensions/file_system.dart';
|
||||
import 'package:analyzer/src/workspace/basic.dart';
|
||||
import 'package:analyzer/src/workspace/pub.dart';
|
||||
import 'package:analyzer/src/workspace/workspace.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/resource_provider_mixin.dart';
|
||||
import 'package:analyzer_utilities/testing/tree_string_sink.dart';
|
||||
import 'package:linter/src/rules.dart';
|
||||
@@ -75,7 +75,7 @@ linter:
|
||||
''');
|
||||
|
||||
var packageConfigFileBuilder = PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: fooFolder.path);
|
||||
..add(name: 'foo', rootFolder: fooFolder);
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
rootFolder.path,
|
||||
packageConfigFileBuilder,
|
||||
@@ -1141,8 +1141,8 @@ resolution: workspace
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'package1', rootPath: package1RootPath)
|
||||
..add(name: 'package2', rootPath: package2RootPath),
|
||||
..add(name: 'package1', rootFolder: getFolder(package1RootPath))
|
||||
..add(name: 'package2', rootFolder: getFolder(package2RootPath)),
|
||||
);
|
||||
|
||||
newFile('$package1RootPath/lib/library1.dart', '');
|
||||
@@ -1207,8 +1207,8 @@ resolution: workspace
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'package1', rootPath: package1RootPath)
|
||||
..add(name: 'package2', rootPath: package2RootPath),
|
||||
..add(name: 'package1', rootFolder: getFolder(package1RootPath))
|
||||
..add(name: 'package2', rootFolder: getFolder(package2RootPath)),
|
||||
);
|
||||
|
||||
newFile('$package1RootPath/lib/library1.dart', '');
|
||||
@@ -1291,9 +1291,9 @@ resolution: workspace
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'package1', rootPath: package1RootPath)
|
||||
..add(name: 'package2', rootPath: package2RootPath)
|
||||
..add(name: 'package3', rootPath: package3RootPath),
|
||||
..add(name: 'package1', rootFolder: getFolder(package1RootPath))
|
||||
..add(name: 'package2', rootFolder: getFolder(package2RootPath))
|
||||
..add(name: 'package3', rootFolder: getFolder(package3RootPath)),
|
||||
);
|
||||
|
||||
newFile('$package1RootPath/lib/library1.dart', '');
|
||||
@@ -1368,8 +1368,8 @@ resolution: workspace
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'package1', rootPath: package1RootPath)
|
||||
..add(name: 'package2', rootPath: package2RootPath),
|
||||
..add(name: 'package1', rootFolder: getFolder(package1RootPath))
|
||||
..add(name: 'package2', rootFolder: getFolder(package2RootPath)),
|
||||
);
|
||||
|
||||
newAnalysisOptionsYamlFile(workspaceRootPath, '');
|
||||
@@ -1448,8 +1448,8 @@ resolution: workspace
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'package1', rootPath: package1RootPath)
|
||||
..add(name: 'package2', rootPath: package2RootPath),
|
||||
..add(name: 'package1', rootFolder: getFolder(package1RootPath))
|
||||
..add(name: 'package2', rootFolder: getFolder(package2RootPath)),
|
||||
);
|
||||
|
||||
newFile('$package1RootPath/lib/library1.dart', '');
|
||||
@@ -1523,8 +1523,8 @@ resolution: workspace
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'package1', rootPath: package1RootPath)
|
||||
..add(name: 'package2', rootPath: package2RootPath),
|
||||
..add(name: 'package1', rootFolder: getFolder(package1RootPath))
|
||||
..add(name: 'package2', rootFolder: getFolder(package2RootPath)),
|
||||
);
|
||||
|
||||
newFile('$package1RootPath/lib/library1.dart', '');
|
||||
@@ -1595,8 +1595,8 @@ resolution: workspace
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'root_package', rootPath: workspaceRootPath)
|
||||
..add(name: 'package1', rootPath: package1RootPath),
|
||||
..add(name: 'root_package', rootFolder: getFolder(workspaceRootPath))
|
||||
..add(name: 'package1', rootFolder: getFolder(package1RootPath)),
|
||||
);
|
||||
|
||||
var collection = AnalysisContextCollectionImpl(
|
||||
@@ -1655,8 +1655,8 @@ resolution: workspace
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
workspaceRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'root_package', rootPath: workspaceRootPath)
|
||||
..add(name: 'package1', rootPath: package1RootPath),
|
||||
..add(name: 'root_package', rootFolder: getFolder(workspaceRootPath))
|
||||
..add(name: 'package1', rootFolder: getFolder(package1RootPath)),
|
||||
);
|
||||
|
||||
var collection = AnalysisContextCollectionImpl(
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:analyzer/src/workspace/blaze.dart';
|
||||
import 'package:analyzer/src/workspace/gn.dart';
|
||||
import 'package:analyzer/src/workspace/pub.dart';
|
||||
import 'package:analyzer/src/workspace/workspace.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/resource_provider_mixin.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
@@ -1354,10 +1354,10 @@ ${getFolder(outPath).path}
|
||||
var flutterPath = '/home/packages/flutter';
|
||||
|
||||
var packageConfigFileBuilder = PackageConfigFileBuilder()
|
||||
..add(name: 'flutter', rootPath: flutterPath);
|
||||
..add(name: 'flutter', rootFolder: getFolder(flutterPath));
|
||||
var packagesFile = newPackageConfigJsonFile(
|
||||
rootFolder.path,
|
||||
packageConfigFileBuilder.toContent(pathContext: pathContext),
|
||||
packageConfigFileBuilder.toContent(),
|
||||
);
|
||||
|
||||
var roots = locateContextRoots(
|
||||
|
||||
@@ -11,7 +11,7 @@ import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/src/dart/analysis/driver.dart';
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/src/error/codes.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/utilities/utilities.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
@@ -256,7 +256,7 @@ import 'a.dart';
|
||||
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaPackageRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaPackageRootPath)),
|
||||
);
|
||||
|
||||
// Configure with the lint.
|
||||
|
||||
@@ -23,7 +23,7 @@ import 'package:analyzer/src/dart/element/element.dart';
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/src/test_utilities/lint_registration_mixin.dart';
|
||||
import 'package:analyzer/src/utilities/extensions/async.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/utilities/utilities.dart';
|
||||
import 'package:analyzer_utilities/testing/tree_string_sink.dart';
|
||||
import 'package:linter/src/rules.dart';
|
||||
@@ -1491,8 +1491,8 @@ final v = 2;
|
||||
test_discoverAvailableFiles_packages() {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$packagesRootPath/aaa')
|
||||
..add(name: 'bbb', rootPath: '$packagesRootPath/bbb'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$packagesRootPath/aaa'))
|
||||
..add(name: 'bbb', rootFolder: getFolder('$packagesRootPath/bbb')),
|
||||
);
|
||||
|
||||
var t1 = newFile('$testPackageLibPath/t1.dart', '');
|
||||
@@ -1836,8 +1836,8 @@ void main() {}
|
||||
test_getFilesReferencingName_discover() async {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$packagesRootPath/aaa')
|
||||
..add(name: 'bbb', rootPath: '$packagesRootPath/bbb'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$packagesRootPath/aaa'))
|
||||
..add(name: 'bbb', rootFolder: getFolder('$packagesRootPath/bbb')),
|
||||
);
|
||||
|
||||
var t = newFile('$testPackageLibPath/t.dart', '''
|
||||
@@ -4840,14 +4840,16 @@ class B2 {}
|
||||
var test1Path = '$workspaceRootPath/test1';
|
||||
writePackageConfig(
|
||||
test1Path,
|
||||
PackageConfigFileBuilder()..add(name: 'test1', rootPath: test1Path),
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'test1', rootFolder: getFolder(test1Path)),
|
||||
);
|
||||
|
||||
// Make sure that `test2` is its own analysis context.
|
||||
var test2Path = '$workspaceRootPath/test2';
|
||||
writePackageConfig(
|
||||
test2Path,
|
||||
PackageConfigFileBuilder()..add(name: 'test2', rootPath: test2Path),
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'test2', rootFolder: getFolder(test2Path)),
|
||||
);
|
||||
|
||||
// `b` imports `a`, so `b` is reanalyzed when `a` API changes.
|
||||
@@ -4910,14 +4912,16 @@ class B2 {}
|
||||
var test1Path = '$workspaceRootPath/test1';
|
||||
writePackageConfig(
|
||||
test1Path,
|
||||
PackageConfigFileBuilder()..add(name: 'test1', rootPath: test1Path),
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'test1', rootFolder: getFolder(test1Path)),
|
||||
);
|
||||
|
||||
// Make sure that `test2` is its own analysis context.
|
||||
var test2Path = '$workspaceRootPath/test2';
|
||||
writePackageConfig(
|
||||
test2Path,
|
||||
PackageConfigFileBuilder()..add(name: 'test2', rootPath: test2Path),
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'test2', rootFolder: getFolder(test2Path)),
|
||||
);
|
||||
|
||||
var a = newFile('$test1Path/lib/a.dart', '');
|
||||
@@ -4975,14 +4979,16 @@ class B2 {}
|
||||
var test1Path = '$workspaceRootPath/test1';
|
||||
writePackageConfig(
|
||||
test1Path,
|
||||
PackageConfigFileBuilder()..add(name: 'test1', rootPath: test1Path),
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'test1', rootFolder: getFolder(test1Path)),
|
||||
);
|
||||
|
||||
// Make sure that `test2` is its own analysis context.
|
||||
var test2Path = '$workspaceRootPath/test2';
|
||||
writePackageConfig(
|
||||
test2Path,
|
||||
PackageConfigFileBuilder()..add(name: 'test2', rootPath: test2Path),
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'test2', rootFolder: getFolder(test2Path)),
|
||||
);
|
||||
|
||||
var a = newFile('$test1Path/lib/a.dart', '');
|
||||
@@ -84658,17 +84664,17 @@ class B extends A {}
|
||||
writePackageConfig(
|
||||
'$workspaceRootPath/test_1',
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '/packages/foo_v1')
|
||||
..add(name: 'bar', rootPath: '/packages/bar')
|
||||
..add(name: 'test', rootPath: '$workspaceRootPath/test_1'),
|
||||
..add(name: 'foo', rootFolder: getFolder('/packages/foo_v1'))
|
||||
..add(name: 'bar', rootFolder: getFolder('/packages/bar'))
|
||||
..add(name: 'test', rootFolder: getFolder('$workspaceRootPath/test_1')),
|
||||
);
|
||||
|
||||
writePackageConfig(
|
||||
'$workspaceRootPath/test_2',
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '/packages/foo_v2')
|
||||
..add(name: 'bar', rootPath: '/packages/bar')
|
||||
..add(name: 'test', rootPath: '$workspaceRootPath/test_2'),
|
||||
..add(name: 'foo', rootFolder: getFolder('/packages/foo_v2'))
|
||||
..add(name: 'bar', rootFolder: getFolder('/packages/bar'))
|
||||
..add(name: 'test', rootFolder: getFolder('$workspaceRootPath/test_2')),
|
||||
);
|
||||
|
||||
var testFile1 = newFile('$workspaceRootPath/test_1/lib/test.dart', r'''
|
||||
@@ -84805,16 +84811,16 @@ class B extends A {}
|
||||
writePackageConfig(
|
||||
'$workspaceRootPath/test_1',
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '/packages/foo')
|
||||
..add(name: 'test', rootPath: '$workspaceRootPath/test_1'),
|
||||
..add(name: 'foo', rootFolder: getFolder('/packages/foo'))
|
||||
..add(name: 'test', rootFolder: getFolder('$workspaceRootPath/test_1')),
|
||||
);
|
||||
|
||||
writePackageConfig(
|
||||
'$workspaceRootPath/test_2',
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '/packages/foo')
|
||||
..add(name: 'bar', rootPath: '/packages/bar')
|
||||
..add(name: 'test', rootPath: '$workspaceRootPath/test_2'),
|
||||
..add(name: 'foo', rootFolder: getFolder('/packages/foo'))
|
||||
..add(name: 'bar', rootFolder: getFolder('/packages/bar'))
|
||||
..add(name: 'test', rootFolder: getFolder('$workspaceRootPath/test_2')),
|
||||
);
|
||||
|
||||
var testFile1 = newFile('$workspaceRootPath/test_1/lib/test.dart', r'''
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:analyzer/src/dart/analysis/search.dart';
|
||||
import 'package:analyzer/src/test_utilities/find_element2.dart';
|
||||
import 'package:analyzer/src/util/performance/operation_performance.dart';
|
||||
import 'package:analyzer/src/utilities/cancellation.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_utilities/testing/tree_string_sink.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:test/test.dart';
|
||||
@@ -358,8 +358,8 @@ class {
|
||||
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaPackageRootPath)
|
||||
..add(name: 'bbb', rootPath: bbbPackageRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaPackageRootPath))
|
||||
..add(name: 'bbb', rootFolder: getFolder(bbbPackageRootPath)),
|
||||
);
|
||||
|
||||
var file_a = newFile(aaaFilePath, 'class A {}');
|
||||
@@ -905,7 +905,7 @@ class A {}
|
||||
// Configure `package:my`.
|
||||
writePackageConfig(
|
||||
myRoot.path,
|
||||
PackageConfigFileBuilder()..add(name: 'my', rootPath: myRoot.path),
|
||||
PackageConfigFileBuilder()..add(name: 'my', rootFolder: myRoot),
|
||||
);
|
||||
|
||||
var myDriver = driverFor(myFile);
|
||||
@@ -4545,7 +4545,7 @@ Random bar() => null;
|
||||
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaPackageRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaPackageRootPath)),
|
||||
);
|
||||
|
||||
fileForContextSelection = testFile;
|
||||
@@ -4643,7 +4643,7 @@ label:
|
||||
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaPackageRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaPackageRootPath)),
|
||||
);
|
||||
|
||||
var libPath = convertPath('$aaaPackageRootPath/lib/a.dart');
|
||||
@@ -4873,7 +4873,7 @@ main() {
|
||||
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaPackageRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaPackageRootPath)),
|
||||
);
|
||||
|
||||
fileForContextSelection = testFile;
|
||||
@@ -5913,7 +5913,7 @@ void f() {
|
||||
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaPackageRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaPackageRootPath)),
|
||||
);
|
||||
|
||||
fileForContextSelection = testFile;
|
||||
@@ -6018,7 +6018,7 @@ package:test/part2.dart v2@16
|
||||
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaPackageRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaPackageRootPath)),
|
||||
);
|
||||
|
||||
fileForContextSelection = this.testFile;
|
||||
@@ -6858,8 +6858,8 @@ class F {}
|
||||
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaPackageRootPath)
|
||||
..add(name: 'bbb', rootPath: bbbPackageRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaPackageRootPath))
|
||||
..add(name: 'bbb', rootFolder: getFolder(bbbPackageRootPath)),
|
||||
);
|
||||
|
||||
var tUri = 'package:test/test.dart';
|
||||
@@ -6928,8 +6928,8 @@ class A {
|
||||
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: aaaPackageRootPath)
|
||||
..add(name: 'bbb', rootPath: bbbPackageRootPath),
|
||||
..add(name: 'aaa', rootFolder: getFolder(aaaPackageRootPath))
|
||||
..add(name: 'bbb', rootFolder: getFolder(bbbPackageRootPath)),
|
||||
);
|
||||
|
||||
addTestFile('class T implements List {}');
|
||||
|
||||
@@ -21,9 +21,9 @@ import 'package:analyzer/src/workspace/basic.dart';
|
||||
import 'package:analyzer/src/workspace/blaze.dart';
|
||||
import 'package:analyzer/src/workspace/gn.dart';
|
||||
import 'package:analyzer/src/workspace/pub.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/experiments/experiments.dart';
|
||||
import 'package:analyzer_testing/mock_packages/mock_packages.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/resource_provider_mixin.dart';
|
||||
import 'package:analyzer_testing/src/analysis_rule/pub_package_resolution.dart';
|
||||
import 'package:analyzer_testing/utilities/utilities.dart';
|
||||
@@ -305,7 +305,7 @@ class PubPackageResolutionTest extends ContextResolutionTest
|
||||
|
||||
writePackageConfig(
|
||||
rootFolder.path,
|
||||
PackageConfigFileBuilder()..add(name: 'foo', rootPath: rootFolder.path),
|
||||
PackageConfigFileBuilder()..add(name: 'foo', rootFolder: rootFolder),
|
||||
);
|
||||
|
||||
for (var entry in files.entries) {
|
||||
@@ -343,7 +343,7 @@ class PubPackageResolutionTest extends ContextResolutionTest
|
||||
String directoryPath,
|
||||
PackageConfigFileBuilder config,
|
||||
) {
|
||||
var content = config.toContent(pathContext: pathContext);
|
||||
var content = config.toContent();
|
||||
newPackageConfigJsonFile(directoryPath, content);
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ class PubPackageResolutionTest extends ContextResolutionTest
|
||||
|
||||
config.add(
|
||||
name: 'test',
|
||||
rootPath: testPackageRootPath,
|
||||
rootFolder: getFolder(testPackageRootPath),
|
||||
languageVersion: languageVersion ?? testPackageLanguageVersion,
|
||||
);
|
||||
|
||||
@@ -395,25 +395,28 @@ class _VisibleOutsideTemplate {
|
||||
const _VisibleOutsideTemplate();
|
||||
}
|
||||
''');
|
||||
config.add(name: 'angular_meta', rootPath: angularMetaRootPath);
|
||||
config.add(
|
||||
name: 'angular_meta',
|
||||
rootFolder: getFolder(angularMetaRootPath),
|
||||
);
|
||||
}
|
||||
|
||||
if (ffi) {
|
||||
var ffiPath = addFfi().parent.path;
|
||||
config.add(name: 'ffi', rootPath: ffiPath);
|
||||
config.add(name: 'ffi', rootFolder: getFolder(ffiPath));
|
||||
}
|
||||
|
||||
if (flutter) {
|
||||
var skyEnginePath = addSkyEngine(sdkPath: sdkRoot.path).parent.path;
|
||||
config.add(name: 'sky_engine', rootPath: skyEnginePath);
|
||||
config.add(name: 'sky_engine', rootFolder: getFolder(skyEnginePath));
|
||||
|
||||
var flutterPath = addFlutter().parent.path;
|
||||
config.add(name: 'flutter', rootPath: flutterPath);
|
||||
config.add(name: 'flutter', rootFolder: getFolder(flutterPath));
|
||||
}
|
||||
|
||||
if (meta || flutter) {
|
||||
var metaPath = addMeta().parent.path;
|
||||
config.add(name: 'meta', rootPath: metaPath);
|
||||
config.add(name: 'meta', rootFolder: getFolder(metaPath));
|
||||
}
|
||||
|
||||
writePackageConfig(testPackageRootPath, config);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'package:analyzer/dart/analysis/features.dart';
|
||||
import 'package:analyzer/src/dart/analysis/experiments.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:pub_semver/pub_semver.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'context_collection_resolution.dart';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../dart/resolution/context_collection_resolution.dart';
|
||||
@@ -145,7 +145,7 @@ class DeprecatedMemberUse_PackageBuildWorkspaceTest
|
||||
test_generated() async {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$workspaceRootPath/aaa')),
|
||||
);
|
||||
|
||||
newPubspecYamlFile(testPackageRootPath, 'name: test');
|
||||
@@ -171,7 +171,7 @@ void f(A a) {}
|
||||
test_lib() async {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$workspaceRootPath/aaa')),
|
||||
);
|
||||
|
||||
newFile('$workspaceRootPath/aaa/lib/a.dart', r'''
|
||||
@@ -231,7 +231,7 @@ $code
|
||||
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$workspaceRootPath/aaa')),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../dart/resolution/context_collection_resolution.dart';
|
||||
@@ -2653,7 +2653,7 @@ $code
|
||||
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'aaa', rootPath: '$workspaceRootPath/aaa'),
|
||||
..add(name: 'aaa', rootFolder: getFolder('$workspaceRootPath/aaa')),
|
||||
meta: true,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../dart/resolution/context_collection_resolution.dart';
|
||||
@@ -68,7 +68,7 @@ import 'dart:_wasm';
|
||||
var builder = PackageConfigFileBuilder();
|
||||
builder.add(
|
||||
name: packageName,
|
||||
rootPath: packageRootPath,
|
||||
rootFolder: getFolder(packageRootPath),
|
||||
languageVersion: testPackageLanguageVersion,
|
||||
);
|
||||
writePackageConfig(packageRootPath, builder);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/utilities/utilities.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'package:analyzer/src/dart/analysis/experiments.dart';
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:pub_semver/pub_semver.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/utilities/utilities.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -31,7 +31,7 @@ class InvalidUseOfInternalMemberTest extends PubPackageResolutionTest {
|
||||
);
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: fooPackageRootPath),
|
||||
..add(name: 'foo', rootFolder: getFolder(fooPackageRootPath)),
|
||||
meta: true,
|
||||
);
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../dart/resolution/context_collection_resolution.dart';
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../dart/resolution/context_collection_resolution.dart';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../dart/resolution/context_collection_resolution.dart';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../dart/resolution/context_collection_resolution.dart';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../dart/resolution/context_collection_resolution.dart';
|
||||
@@ -25,7 +25,7 @@ class MixinOnSealedClassTest extends PubPackageResolutionTest {
|
||||
test_mixinOnSealedClass() async {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
meta: true,
|
||||
);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../dart/resolution/context_collection_resolution.dart';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../dart/resolution/context_collection_resolution.dart';
|
||||
@@ -25,7 +25,7 @@ class SubtypeOfSealedClassTest extends PubPackageResolutionTest {
|
||||
test_extendingSealedClass() async {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
meta: true,
|
||||
);
|
||||
|
||||
@@ -46,7 +46,7 @@ class Bar extends Foo {}
|
||||
test_implementingSealedClass() async {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
meta: true,
|
||||
);
|
||||
|
||||
@@ -67,7 +67,7 @@ class Bar implements Foo {}
|
||||
test_mixinApplicationOfSealedClass() async {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
meta: true,
|
||||
);
|
||||
|
||||
@@ -90,7 +90,7 @@ class Bar2 = Bar1 with Foo;
|
||||
test_mixinApplicationOfSealedMixin() async {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
meta: true,
|
||||
);
|
||||
|
||||
@@ -112,7 +112,7 @@ class Bar2 = Bar1 with Foo;
|
||||
test_mixingInWithSealedMixin() async {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
meta: true,
|
||||
);
|
||||
|
||||
@@ -133,7 +133,7 @@ class Bar extends Object with Foo {}
|
||||
test_mixinImplementsSealedClass() async {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'foo', rootPath: '$workspaceRootPath/foo'),
|
||||
..add(name: 'foo', rootFolder: getFolder('$workspaceRootPath/foo')),
|
||||
meta: true,
|
||||
);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/expect.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -140,7 +140,7 @@ void f(Object p) {
|
||||
test_class_isUsed_jsAnnotation() async {
|
||||
writeTestPackageConfig(
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'js', rootPath: '$workspaceRootPath/js'),
|
||||
..add(name: 'js', rootFolder: getFolder('$workspaceRootPath/js')),
|
||||
);
|
||||
|
||||
newFile('$workspaceRootPath/js/lib/js.dart', r'''
|
||||
|
||||
@@ -10,7 +10,7 @@ import 'package:analyzer/src/generated/source.dart' show UriResolver;
|
||||
import 'package:analyzer/src/workspace/basic.dart';
|
||||
import 'package:analyzer/src/workspace/pub.dart';
|
||||
import 'package:analyzer/src/workspace/workspace.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/resource_provider_mixin.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
@@ -73,11 +73,8 @@ class PackageBuildFileUriResolverTest with ResourceProviderMixin {
|
||||
newFolder(testPackageGeneratedLibPath);
|
||||
newPubspecYamlFile(testPackageRootPath, 'name: test');
|
||||
var config = PackageConfigFileBuilder();
|
||||
config.add(name: 'test', rootPath: convertPath(testPackageRootPath));
|
||||
newPackageConfigJsonFile(
|
||||
testPackageRootPath,
|
||||
config.toContent(pathContext: pathContext),
|
||||
);
|
||||
config.add(name: 'test', rootFolder: getFolder(testPackageRootPath));
|
||||
newPackageConfigJsonFile(testPackageRootPath, config.toContent());
|
||||
|
||||
workspace = PackageConfigWorkspace.find(
|
||||
resourceProvider,
|
||||
@@ -225,11 +222,8 @@ class PackageBuildPackageUriResolverTest with ResourceProviderMixin {
|
||||
}
|
||||
}
|
||||
var config = PackageConfigFileBuilder();
|
||||
config.add(name: 'project', rootPath: '/workspace');
|
||||
newPackageConfigJsonFile(
|
||||
workspacePath,
|
||||
config.toContent(pathContext: pathContext),
|
||||
);
|
||||
config.add(name: 'project', rootFolder: getFolder('/workspace'));
|
||||
newPackageConfigJsonFile(workspacePath, config.toContent());
|
||||
workspace = PackageConfigWorkspace.find(
|
||||
resourceProvider,
|
||||
Packages.empty,
|
||||
@@ -603,9 +597,9 @@ workspace:
|
||||
) {
|
||||
var config = PackageConfigFileBuilder();
|
||||
for (var name in packageNames) {
|
||||
config.add(name: name, rootPath: convertPath('/packages/$name'));
|
||||
config.add(name: name, rootFolder: getFolder('/packages/$name'));
|
||||
}
|
||||
newPackageConfigJsonFile(root, config.toContent(pathContext: pathContext));
|
||||
newPackageConfigJsonFile(root, config.toContent());
|
||||
return PackageConfigWorkspace.find(
|
||||
resourceProvider,
|
||||
Packages.empty,
|
||||
@@ -641,12 +635,9 @@ class PubPackageTest extends WorkspacePackageTest {
|
||||
// workspace 1 with packages 'p1' and 'workspace'
|
||||
newPubspecYamlFile('/workspace', 'name: project');
|
||||
var config = PackageConfigFileBuilder();
|
||||
config.add(name: 'p1', rootPath: '/.pubcache/p1');
|
||||
config.add(name: 'workspace', rootPath: '/workspace');
|
||||
newPackageConfigJsonFile(
|
||||
'/workspace',
|
||||
config.toContent(pathContext: pathContext),
|
||||
);
|
||||
config.add(name: 'p1', rootFolder: getFolder('/.pubcache/p1'));
|
||||
config.add(name: 'workspace', rootFolder: getFolder('/workspace'));
|
||||
newPackageConfigJsonFile('/workspace', config.toContent());
|
||||
workspace = PackageConfigWorkspace.find(
|
||||
resourceProvider,
|
||||
Packages.empty,
|
||||
@@ -657,12 +648,9 @@ class PubPackageTest extends WorkspacePackageTest {
|
||||
// workspace 2 with packages 'my' and 'foo'
|
||||
newPubspecYamlFile(myPackageRootPath, 'name: my');
|
||||
config = PackageConfigFileBuilder();
|
||||
config.add(name: 'my', rootPath: myPackageRootPath);
|
||||
config.add(name: 'foo', rootPath: fooPackageRootPath);
|
||||
newPackageConfigJsonFile(
|
||||
myPackageRootPath,
|
||||
config.toContent(pathContext: pathContext),
|
||||
);
|
||||
config.add(name: 'my', rootFolder: getFolder(myPackageRootPath));
|
||||
config.add(name: 'foo', rootFolder: getFolder(fooPackageRootPath));
|
||||
newPackageConfigJsonFile(myPackageRootPath, config.toContent());
|
||||
newFolder(myPackageGeneratedPath);
|
||||
myWorkspace = PackageConfigWorkspace.find(
|
||||
resourceProvider,
|
||||
@@ -716,21 +704,15 @@ class PubPackageTest extends WorkspacePackageTest {
|
||||
|
||||
var package = findPackage('/workspace/project/lib/code.dart')!;
|
||||
expect(
|
||||
package.contains(
|
||||
TestSource(convertPath('/workspace/project/lib/file2.dart')),
|
||||
),
|
||||
package.contains(_sourceWithFileUri('/workspace/project/lib/file2.dart')),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
package.contains(
|
||||
TestSource(convertPath('/workspace/project/bin/bin.dart')),
|
||||
),
|
||||
package.contains(_sourceWithFileUri('/workspace/project/bin/bin.dart')),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
package.contains(
|
||||
TestSource(convertPath('/workspace/project/test/test.dart')),
|
||||
),
|
||||
package.contains(_sourceWithFileUri('/workspace/project/test/test.dart')),
|
||||
isTrue,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import 'package:analyzer/diagnostic/diagnostic.dart';
|
||||
import 'package:analyzer/error/error.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/utilities/utilities.dart';
|
||||
import 'package:analyzer_utilities/analyzer_messages.dart';
|
||||
import 'package:analyzer_utilities/lint_messages.dart';
|
||||
@@ -647,7 +647,10 @@ class _SnippetTest extends PubPackageResolutionTest {
|
||||
|
||||
String packageName = uri.pathSegments[0];
|
||||
String packageRootPath = '/packages/$packageName';
|
||||
packageConfigBuilder.add(name: packageName, rootPath: packageRootPath);
|
||||
packageConfigBuilder.add(
|
||||
name: packageName,
|
||||
rootFolder: getFolder(packageRootPath),
|
||||
);
|
||||
|
||||
String pathInLib = uri.pathSegments.skip(1).join('/');
|
||||
newFile('$packageRootPath/lib/$pathInLib', auxiliaryFiles[uriStr]!);
|
||||
|
||||
@@ -10,10 +10,10 @@ import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/source/source_range.dart';
|
||||
import 'package:analyzer/src/test_utilities/find_node.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart' hide Element;
|
||||
import 'package:analyzer_plugin/src/utilities/change_builder/change_builder_dart.dart'
|
||||
show DartFileEditBuilderImpl, DartLinkedEditBuilderImpl;
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
|
||||
import 'package:analyzer/src/dart/analysis/byte_store.dart';
|
||||
import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine;
|
||||
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/experiments/experiments.dart';
|
||||
import 'package:analyzer_testing/mock_packages/mock_packages.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/resource_provider_mixin.dart';
|
||||
import 'package:linter/src/rules.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
@@ -113,7 +113,7 @@ class AbstractContextTest with MockPackagesMixin, ResourceProviderMixin {
|
||||
}
|
||||
|
||||
void writePackageConfig(String path, PackageConfigFileBuilder config) {
|
||||
newFile(path, config.toContent(pathContext: pathContext));
|
||||
newFile(path, config.toContent());
|
||||
}
|
||||
|
||||
/// Write an analysis options file based on the given arguments.
|
||||
@@ -146,13 +146,13 @@ class AbstractContextTest with MockPackagesMixin, ResourceProviderMixin {
|
||||
|
||||
config.add(
|
||||
name: 'test',
|
||||
rootPath: testPackageRootPath,
|
||||
rootFolder: getFolder(testPackageRootPath),
|
||||
languageVersion: languageVersion ?? testPackageLanguageVersion,
|
||||
);
|
||||
|
||||
if (meta) {
|
||||
var metaPath = addMeta().parent.path;
|
||||
config.add(name: 'meta', rootPath: metaPath);
|
||||
var metaRoot = addMeta().parent;
|
||||
config.add(name: 'meta', rootFolder: metaRoot);
|
||||
}
|
||||
|
||||
var path = '$testPackageRootPath/.dart_tool/package_config.json';
|
||||
|
||||
+1
-1
@@ -2,9 +2,9 @@
|
||||
// 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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/utilities/completion/completion_core.dart';
|
||||
import 'package:analyzer_plugin/utilities/completion/inherited_reference_contributor.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// 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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
import 'package:analyzer_plugin/utilities/completion/completion_core.dart';
|
||||
import 'package:analyzer_plugin/utilities/completion/relevance.dart';
|
||||
import 'package:analyzer_plugin/utilities/completion/type_member_contributor.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -62,7 +62,7 @@ void f(Derived d) {
|
||||
super.setUp();
|
||||
writeTestPackageConfig(
|
||||
config: PackageConfigFileBuilder()
|
||||
..add(name: 'myBar', rootPath: '$workspaceRootPath/myBar'),
|
||||
..add(name: 'myBar', rootFolder: getFolder('$workspaceRootPath/myBar')),
|
||||
meta: true,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
## 0.2.7-dev
|
||||
## 0.3.0-dev
|
||||
|
||||
- Add `PackageConfigFileBuilder` to the public API.
|
||||
- Breaking change: `ResourceProviderMixin.newPackageConfigJsonFileFromBuilder`
|
||||
now takes the `PackageConfigFileBuilder` from `package:analyzer_testing`.
|
||||
- Require version `13.1.0-dev` of the `analyzer` package.
|
||||
|
||||
## 0.2.6
|
||||
|
||||
@@ -33,6 +33,12 @@ package:analyzer_testing/mock_packages/mock_packages.dart:
|
||||
addSkyEngine (method: Folder Function({required String sdkPath}))
|
||||
addTestReflectiveLoader (method: Folder Function())
|
||||
addVectorMath (method: Folder Function())
|
||||
package:analyzer_testing/package_config_file_builder.dart:
|
||||
PackageConfigFileBuilder (class extends Object):
|
||||
new (constructor: PackageConfigFileBuilder Function())
|
||||
add (method: void Function({String? languageVersion, required String name, String packageUriStr, required Folder rootFolder}))
|
||||
copy (method: PackageConfigFileBuilder Function())
|
||||
toContent (method: String Function())
|
||||
package:analyzer_testing/package_root.dart:
|
||||
packageRoot (static getter: String)
|
||||
package:analyzer_testing/resource_provider_mixin.dart:
|
||||
@@ -100,7 +106,5 @@ package:analyzer/file_system/file_system.dart:
|
||||
ResourceProvider (referenced)
|
||||
package:analyzer/src/analysis_rule/analysis_rule.dart:
|
||||
AbstractAnalysisRule (referenced)
|
||||
package:analyzer/utilities/package_config_file_builder.dart:
|
||||
PackageConfigFileBuilder (referenced)
|
||||
package:path/src/context.dart:
|
||||
Context (referenced)
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
// Copyright (c) 2026, 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.
|
||||
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
|
||||
/// Helper for building `.dart_tool/package_config.json` files.
|
||||
///
|
||||
/// See accepted/future-releases/language-versioning/package-config-file-v2.md
|
||||
/// in https://github.com/dart-lang/language/.
|
||||
///
|
||||
/// Use the [add] method to add package configurations. These configurations
|
||||
/// will accumulate into one package config file with the [toContent] method.
|
||||
class PackageConfigFileBuilder {
|
||||
final List<_PackageDescription> _packages = [];
|
||||
|
||||
/// Adds a package configuration.
|
||||
///
|
||||
/// The [rootFolder] is used to produce the package root URI.
|
||||
///
|
||||
/// The [packageUriStr] is optional (defaults to `'lib/'`), a relative path
|
||||
/// resolved against the root URI. The result must be inside the root URI.
|
||||
///
|
||||
/// The [languageVersion] specifies the package's Dart language version, in
|
||||
/// the form of 'X.Y', such as '3.9'.
|
||||
void add({
|
||||
required String name,
|
||||
required Folder rootFolder,
|
||||
String packageUriStr = 'lib/',
|
||||
String? languageVersion,
|
||||
}) {
|
||||
if (_packages.any((e) => e.name == name)) {
|
||||
throw StateError('Already added: $name');
|
||||
}
|
||||
_packages.add(
|
||||
_PackageDescription(
|
||||
name: name,
|
||||
rootFolder: rootFolder,
|
||||
packageUriStr: packageUriStr,
|
||||
languageVersion: languageVersion,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Copies this [PackageConfigFileBuilder] into a new instance.
|
||||
PackageConfigFileBuilder copy() {
|
||||
var copy = PackageConfigFileBuilder();
|
||||
copy._packages.addAll(_packages);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/// Returns the contents of the built package config file.
|
||||
String toContent() {
|
||||
var buffer = StringBuffer();
|
||||
|
||||
buffer.writeln('{');
|
||||
|
||||
var prefix = ' ' * 2;
|
||||
buffer.writeln('$prefix"configVersion": 2,');
|
||||
buffer.writeln('$prefix"packages": [');
|
||||
|
||||
for (var i = 0; i < _packages.length; i++) {
|
||||
var package = _packages[i];
|
||||
|
||||
var prefix = ' ' * 4;
|
||||
buffer.writeln('$prefix{');
|
||||
|
||||
prefix = ' ' * 6;
|
||||
buffer.writeln('$prefix"name": "${package.name}",');
|
||||
|
||||
buffer.write('$prefix"rootUri": "${package.rootFolder.toUri()}"');
|
||||
|
||||
buffer.writeln(',');
|
||||
buffer.write('$prefix"packageUri": "${package.packageUriStr}"');
|
||||
|
||||
if (package.languageVersion != null) {
|
||||
buffer.writeln(',');
|
||||
buffer.write('$prefix"languageVersion": "${package.languageVersion}"');
|
||||
}
|
||||
|
||||
buffer.writeln();
|
||||
|
||||
prefix = ' ' * 4;
|
||||
buffer.write(prefix);
|
||||
buffer.writeln(i < _packages.length - 1 ? '},' : '}');
|
||||
}
|
||||
|
||||
buffer.writeln(' ]');
|
||||
buffer.writeln('}');
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class _PackageDescription {
|
||||
final String name;
|
||||
final Folder rootFolder;
|
||||
final String packageUriStr;
|
||||
final String? languageVersion;
|
||||
|
||||
_PackageDescription({
|
||||
required this.name,
|
||||
required this.rootFolder,
|
||||
required this.packageUriStr,
|
||||
required this.languageVersion,
|
||||
});
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import 'package:analyzer/file_system/memory_file_system.dart';
|
||||
// TODO(srawlins): Move this into public API.
|
||||
// ignore: implementation_imports
|
||||
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/utilities/extensions/resource_provider.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
@@ -147,7 +147,7 @@ mixin ResourceProviderMixin {
|
||||
String directoryPath,
|
||||
PackageConfigFileBuilder builder,
|
||||
) {
|
||||
var content = builder.toContent(pathContext: pathContext);
|
||||
var content = builder.toContent();
|
||||
return newPackageConfigJsonFile(directoryPath, content);
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ mixin ResourceProviderMixin {
|
||||
required String name,
|
||||
}) {
|
||||
var builder = PackageConfigFileBuilder()
|
||||
..add(name: name, rootPath: packagePath);
|
||||
..add(name: name, rootFolder: getFolder(packagePath));
|
||||
newPackageConfigJsonFileFromBuilder(packagePath, builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import 'package:analyzer/src/dart/analysis/experiments.dart'; // ignore: impleme
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' // ignore: implementation_imports
|
||||
as diag;
|
||||
import 'package:analyzer/src/test_utilities/mock_sdk.dart'; // ignore: implementation_imports
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/experiments/experiments.dart';
|
||||
import 'package:analyzer_testing/mock_packages/mock_packages.dart';
|
||||
import 'package:analyzer_testing/resource_provider_mixin.dart';
|
||||
@@ -642,7 +642,7 @@ class PubPackageResolutionTest with MockPackagesMixin, ResourceProviderMixin {
|
||||
}
|
||||
|
||||
void writePackageConfig(String path, PackageConfigFileBuilder config) {
|
||||
newFile(path, config.toContent(pathContext: pathContext));
|
||||
newFile(path, config.toContent());
|
||||
}
|
||||
|
||||
/// Writes a `package_config.json` file from [config], and for packages that
|
||||
@@ -652,39 +652,39 @@ class PubPackageResolutionTest with MockPackagesMixin, ResourceProviderMixin {
|
||||
|
||||
configCopy.add(
|
||||
name: 'test',
|
||||
rootPath: testPackageRootPath,
|
||||
rootFolder: getFolder(testPackageRootPath),
|
||||
languageVersion: testPackageLanguageVersion,
|
||||
);
|
||||
|
||||
if (addFixnumPackageDep) {
|
||||
var fixnumPath = addFixnum().parent.path;
|
||||
configCopy.add(name: 'fixnum', rootPath: fixnumPath);
|
||||
configCopy.add(name: 'fixnum', rootFolder: getFolder(fixnumPath));
|
||||
}
|
||||
|
||||
if (addFlutterPackageDep) {
|
||||
var skyEnginePath = addSkyEngine(sdkPath: _sdkRoot.path).parent.path;
|
||||
configCopy.add(name: 'sky_engine', rootPath: skyEnginePath);
|
||||
configCopy.add(name: 'sky_engine', rootFolder: getFolder(skyEnginePath));
|
||||
|
||||
var flutterPath = addFlutter().parent.path;
|
||||
configCopy.add(name: 'flutter', rootPath: flutterPath);
|
||||
configCopy.add(name: 'flutter', rootFolder: getFolder(flutterPath));
|
||||
}
|
||||
|
||||
if (addMetaPackageDep) {
|
||||
var metaPath = addMeta().parent.path;
|
||||
configCopy.add(name: 'meta', rootPath: metaPath);
|
||||
configCopy.add(name: 'meta', rootFolder: getFolder(metaPath));
|
||||
}
|
||||
|
||||
if (addTestReflectiveLoaderPackageDep) {
|
||||
var testReflectiveLoaderPath = addTestReflectiveLoader().parent.path;
|
||||
configCopy.add(
|
||||
name: 'test_reflective_loader',
|
||||
rootPath: testReflectiveLoaderPath,
|
||||
rootFolder: getFolder(testReflectiveLoaderPath),
|
||||
);
|
||||
}
|
||||
|
||||
for (var packageName in _packagesToAdd) {
|
||||
var packagePath = convertPath('/package/$packageName');
|
||||
configCopy.add(name: packageName, rootPath: packagePath);
|
||||
configCopy.add(name: packageName, rootFolder: getFolder(packagePath));
|
||||
}
|
||||
|
||||
var path = '$testPackageRootPath/.dart_tool/package_config.json';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: analyzer_testing
|
||||
description: Testing utilities related to the analyzer and analysis_server_plugin packages.
|
||||
version: 0.2.7-dev
|
||||
version: 0.3.0-dev
|
||||
repository: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer_testing
|
||||
|
||||
environment:
|
||||
|
||||
@@ -12,7 +12,6 @@ import 'package:analyzer/dart/ast/token.dart';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
import 'package:analyzer/workspace/workspace.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
/// Return the compilation unit of a node
|
||||
CompilationUnit? getCompilationUnit(AstNode node) =>
|
||||
@@ -120,13 +119,14 @@ bool isInPublicDir(CompilationUnit node, WorkspacePackage? package) {
|
||||
if (package == null) return false;
|
||||
var cuPath = node.declaredFragment?.element.firstFragment.source.fullName;
|
||||
if (cuPath == null) return false;
|
||||
var libDir = path.join(package.root.path, 'lib');
|
||||
var binDir = path.join(package.root.path, 'bin');
|
||||
var pathContext = package.root.provider.pathContext;
|
||||
var libDir = pathContext.join(package.root.path, 'lib');
|
||||
var binDir = pathContext.join(package.root.path, 'bin');
|
||||
// Hook directory: https://github.com/dart-lang/sdk/issues/54334,
|
||||
var buildHookFile = path.join(package.root.path, 'hook', 'build.dart');
|
||||
var linkHookFile = path.join(package.root.path, 'hook', 'link.dart');
|
||||
return path.isWithin(libDir, cuPath) ||
|
||||
path.isWithin(binDir, cuPath) ||
|
||||
var buildHookFile = pathContext.join(package.root.path, 'hook', 'build.dart');
|
||||
var linkHookFile = pathContext.join(package.root.path, 'hook', 'link.dart');
|
||||
return pathContext.isWithin(libDir, cuPath) ||
|
||||
pathContext.isWithin(binDir, cuPath) ||
|
||||
cuPath == buildHookFile ||
|
||||
cuPath == linkHookFile;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../rule_test_support.dart';
|
||||
@@ -22,7 +22,7 @@ class AlwaysUsePackageImportsTest extends LintRuleTest {
|
||||
var packageConfigBuilder = PackageConfigFileBuilder();
|
||||
packageConfigBuilder.add(
|
||||
name: 'internal_package',
|
||||
rootPath: '$testPackageRootPath/vendor/internal_package',
|
||||
rootFolder: getFolder('$testPackageRootPath/vendor/internal_package'),
|
||||
);
|
||||
writeTestPackageConfig(packageConfigBuilder);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_root.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -37,7 +37,7 @@ class AnalyzerElementModelTrackingTest extends LintRuleTest {
|
||||
newPackageConfigJsonFileFromBuilder(
|
||||
testPackageRootPath,
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'analyzer', rootPath: analyzerFolder.path),
|
||||
..add(name: 'analyzer', rootFolder: analyzerFolder),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:linter/src/diagnostic.dart' as diag;
|
||||
import 'package:linter/src/rules/analyzer_public_api.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
@@ -58,9 +58,12 @@ class AnalyzerPublicApiTest extends LintRuleTest {
|
||||
super.setUp();
|
||||
|
||||
var builder = PackageConfigFileBuilder()
|
||||
..add(name: 'analyzer', rootPath: testPackageRootPath)
|
||||
..add(name: 'nonAnalyzer', rootPath: nonAnalyzerPackageRootPath)
|
||||
..add(name: 'meta', rootPath: addMeta().parent.path);
|
||||
..add(name: 'analyzer', rootFolder: getFolder(testPackageRootPath))
|
||||
..add(
|
||||
name: 'nonAnalyzer',
|
||||
rootFolder: getFolder(nonAnalyzerPackageRootPath),
|
||||
)
|
||||
..add(name: 'meta', rootFolder: addMeta().parent);
|
||||
newPackageConfigJsonFileFromBuilder(testPackageRootPath, builder);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../rule_test_support.dart';
|
||||
@@ -89,7 +89,7 @@ version: 1.1.1
|
||||
var packageConfigBuilder = PackageConfigFileBuilder();
|
||||
packageConfigBuilder.add(
|
||||
name: 'flutter_gen',
|
||||
rootPath: '$workspaceRootPath/flutter_gen',
|
||||
rootFolder: getFolder('$workspaceRootPath/flutter_gen'),
|
||||
);
|
||||
writeTestPackageConfig(packageConfigBuilder);
|
||||
newFile(testPackagePubspecPath, r'''
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../rule_test_support.dart';
|
||||
@@ -37,7 +37,7 @@ import 'package:foo/foo.dart';
|
||||
var packageConfigBuilder = PackageConfigFileBuilder();
|
||||
packageConfigBuilder.add(
|
||||
name: 'internal_package',
|
||||
rootPath: '$testPackageRootPath/vendor/internal_package',
|
||||
rootFolder: getFolder('$testPackageRootPath/vendor/internal_package'),
|
||||
);
|
||||
writeTestPackageConfig(packageConfigBuilder);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag;
|
||||
import 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/utilities/utilities.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
@@ -500,7 +500,8 @@ class PublicMemberApiDocsTestPackageTest extends LintRuleTest {
|
||||
newFolder(fixturePackageLibPath);
|
||||
writePackageConfig(
|
||||
'$myPackageRootPath/test/fixture/.dart_tool/package_config.json',
|
||||
PackageConfigFileBuilder()..add(name: 'fixture', rootPath: '../lib'),
|
||||
PackageConfigFileBuilder()
|
||||
..add(name: 'fixture', rootFolder: getFolder(fixturePackageLibPath)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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 'package:analyzer/utilities/package_config_file_builder.dart';
|
||||
import 'package:analyzer_testing/package_config_file_builder.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import '../rule_test_support.dart';
|
||||
@@ -23,7 +23,10 @@ class UseTestThrowsMatchersTest extends LintRuleTest {
|
||||
super.setUp();
|
||||
var testApiPath = '$workspaceRootPath/test_api';
|
||||
var packageConfigBuilder = PackageConfigFileBuilder();
|
||||
packageConfigBuilder.add(name: 'test_api', rootPath: testApiPath);
|
||||
packageConfigBuilder.add(
|
||||
name: 'test_api',
|
||||
rootFolder: getFolder(testApiPath),
|
||||
);
|
||||
writeTestPackageConfig(packageConfigBuilder);
|
||||
newFile('$testApiPath/lib/src/frontend/expect.dart', r'''
|
||||
void expect(dynamic actual, dynamic matcher) {}
|
||||
|
||||
Reference in New Issue
Block a user