diff --git a/pkg/dev_compiler/pubspec.yaml b/pkg/dev_compiler/pubspec.yaml index 7aaa569e668..c40b07a89a8 100644 --- a/pkg/dev_compiler/pubspec.yaml +++ b/pkg/dev_compiler/pubspec.yaml @@ -3,7 +3,7 @@ name: dev_compiler publish_to: none environment: - sdk: '>=3.6.0 <4.0.0' + sdk: ^3.6.0 resolution: workspace diff --git a/pkg/reload_test/pubspec.yaml b/pkg/reload_test/pubspec.yaml index c89da30d872..9151b571a52 100644 --- a/pkg/reload_test/pubspec.yaml +++ b/pkg/reload_test/pubspec.yaml @@ -5,7 +5,7 @@ description: > Small framework for testing hot reload and hot restart across Dart backends. environment: - sdk: '>=3.6.0 <4.0.0' + sdk: ^3.6.0 resolution: workspace diff --git a/pkg/vm/pubspec.yaml b/pkg/vm/pubspec.yaml index 7651c3e6f8a..77047d45e94 100644 --- a/pkg/vm/pubspec.yaml +++ b/pkg/vm/pubspec.yaml @@ -4,7 +4,7 @@ description: VM specific Dart code and helper scripts publish_to: none environment: - sdk: '>=3.7.0 <4.0.0' + sdk: ^3.7.0 resolution: workspace diff --git a/pubspec.yaml b/pubspec.yaml index 94add8156b0..6ca634284ab 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ name: _ publish_to: none environment: - # This constraint decides the langage-version for all dart code in the + # This constraint decides the language-version for all dart code in the # repository that doesn't have its own package. Mainly the code in `tests/`. # # It needs to be updated before testing language features introduced in the @@ -77,12 +77,14 @@ workspace: - pkg/vm_service_protos - pkg/vm_snapshot_analysis - pkg/wasm_builder + - runtime/tools/profiling - samples/ffi/http # dap and language_server_protocol are checked in to and - # developed in the sdk repo, though they are located in `third_party/`. + # developed in the SDK repo, though they are located in `third_party/`. - third_party/pkg/dap - third_party/pkg/language_server_protocol - tools/package_deps + - tools/verify_docs - tools # All third_party packages here are retrieved via the DEPS-file and overridden diff --git a/runtime/observatory/pubspec.yaml b/runtime/observatory/pubspec.yaml index 492e1cb8a01..08505da7dad 100644 --- a/runtime/observatory/pubspec.yaml +++ b/runtime/observatory/pubspec.yaml @@ -1,7 +1,7 @@ name: observatory environment: - sdk: '>=2.19.0 <3.0.0' + sdk: ^2.19.0 # dependencies: diff --git a/runtime/observatory/tests/service/observatory_test_package/pubspec.yaml b/runtime/observatory/tests/service/observatory_test_package/pubspec.yaml index fbfb764ecc2..6d1eecf7437 100644 --- a/runtime/observatory/tests/service/observatory_test_package/pubspec.yaml +++ b/runtime/observatory/tests/service/observatory_test_package/pubspec.yaml @@ -1,4 +1,4 @@ name: observatory_test_package publish_to: none environment: - sdk: '>=2.19.0 <3.0.0' + sdk: ^2.19.0 diff --git a/runtime/tools/profiling/pubspec.yaml b/runtime/tools/profiling/pubspec.yaml index fc0ba9cfbf7..e585ecc60e8 100644 --- a/runtime/tools/profiling/pubspec.yaml +++ b/runtime/tools/profiling/pubspec.yaml @@ -4,7 +4,9 @@ version: 0.1.0 publish_to: none environment: - sdk: '>=3.6.0 <4.0.0' + sdk: ^3.6.0 + +resolution: workspace dependencies: protobuf: ^3.1.0 diff --git a/tools/bisect.dart b/tools/bisect.dart index 9cbd869eedd..2335c188c5f 100755 --- a/tools/bisect.dart +++ b/tools/bisect.dart @@ -3,6 +3,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. +// ignore: implementation_imports import 'package:bisect_dart/src/run_bisection.dart'; Future main(List args) async { diff --git a/tools/generate_package_config.dart b/tools/generate_package_config.dart index 9dbe707fbe0..32730584b06 100644 --- a/tools/generate_package_config.dart +++ b/tools/generate_package_config.dart @@ -12,7 +12,7 @@ import 'dart:io'; final repoRoot = File(Platform.script.toFilePath()).parent.parent.uri; -void main(List args) { +void main() { final fluteExists = Directory.fromUri(repoRoot.resolve('third_party/flute')).existsSync(); final overridesFile = File.fromUri( @@ -24,9 +24,9 @@ void main(List args) { final pubspec = File.fromUri(repoRoot.resolve('pubspec.yaml')).readAsStringSync(); final overrides = RegExp( - 'dependency_overrides:\n([\\S\\s]*?)^\$', + r'^dependency_overrides:\n([^]*?)^$', multiLine: true, - ).firstMatch(pubspec)![1]; + ).firstMatch(pubspec)![1]!; overridesFile.writeAsStringSync(''' # Created by tools/generate_package_config.dart to support flute. @@ -48,9 +48,7 @@ $overrides } else { // Delete the overrides file if it exists. if (overridesFile.existsSync()) { - File.fromUri( - repoRoot.resolve('pubspec_overrides.yaml'), - ).deleteSync(recursive: true); + overridesFile.deleteSync(); } } @@ -59,7 +57,7 @@ $overrides Platform.resolvedExecutable, ['pub', 'get'], workingDirectory: repoRoot.toFilePath(), - environment: {}, // Prevent overriding eg. PUB_CACHE + environment: {}, // Prevent overriding, e.g., PUB_CACHE ); if (result.exitCode != 0) { print('`pub get` failed'); @@ -71,21 +69,22 @@ $overrides File.fromUri( repoRoot.resolve('.dart_tool/package_config.json'), ).readAsStringSync(), - ); + ) as Map; if (!fluteExists) { - for (final package in packageConfig['packages']) { - final rootUri = package['rootUri']; + final packages = packageConfig['packages'] as List; + for (final (package as Map) in packages) { + final rootUri = package['rootUri'] as String; if (!(rootUri.startsWith('../third_party/') || // Third-party package rootUri.startsWith('../pkg/') || // SDK package rootUri.startsWith('../samples/') || // sample package rootUri.startsWith('../runtime/') || // VM package rootUri.startsWith( '../tools', - ) || // A tool package for developing the sdk. + ) || // A tool package for developing the SDK. rootUri == '../' // The main workspace package )) { - print('Package ${package['name']} is imported from outside the sdk.'); + print('Package ${package['name']} is imported from outside the SDK.'); print('It has rootUri $rootUri.'); print( 'See https://github.com/dart-lang/sdk/blob/main/docs/Adding-and-Updating-Dependencies.md', diff --git a/tools/lib/README.md b/tools/lib/README.md new file mode 100644 index 00000000000..9f003d03946 --- /dev/null +++ b/tools/lib/README.md @@ -0,0 +1,3 @@ +A lib/ directory for the synthetic package introduced by ../pubspec.yaml. +Avoids files in nested packages, like ../verify_docs/, having package: URIS +in the parent directory package. \ No newline at end of file diff --git a/tools/verify_docs/bin/verify_docs.dart b/tools/verify_docs/bin/verify_docs.dart index 0a478f927ee..28d57c7ce0e 100755 --- a/tools/verify_docs/bin/verify_docs.dart +++ b/tools/verify_docs/bin/verify_docs.dart @@ -7,7 +7,7 @@ import 'dart:collection'; import 'dart:io'; -import 'package:_fe_analyzer_shared/src/sdk/allowed_experiments.dart'; +import 'package:_fe_analyzer_shared/src/sdk/allowed_experiments.dart'; // ignore: implementation_imports import 'package:analyzer/dart/analysis/analysis_context_collection.dart'; import 'package:analyzer/dart/analysis/features.dart'; import 'package:analyzer/dart/analysis/results.dart'; @@ -19,9 +19,9 @@ import 'package:analyzer/error/error.dart'; import 'package:analyzer/file_system/overlay_file_system.dart'; import 'package:analyzer/file_system/physical_file_system.dart'; import 'package:analyzer/source/line_info.dart'; -import 'package:analyzer/src/dart/analysis/experiments.dart'; -import 'package:analyzer/src/error/codes.dart'; -import 'package:analyzer/src/util/comment.dart'; +import 'package:analyzer/src/dart/analysis/experiments.dart'; // ignore: implementation_imports +import 'package:analyzer/src/error/codes.dart'; // ignore: implementation_imports +import 'package:analyzer/src/util/comment.dart'; // ignore: implementation_imports import 'package:path/path.dart' as path; final libDir = Directory(path.join('sdk', 'lib')); @@ -35,8 +35,10 @@ void main(List args) async { print(''); print('To run this tool, run `dart tools/verify_docs/bin/verify_docs.dart`.'); print(''); - print('For documentation about how to author dart: code samples,' - ' see tools/verify_docs/README.md.'); + print( + 'For documentation about how to author dart: code samples,' + ' see tools/verify_docs/README.md.', + ); print(''); final coreLibraries = args.isEmpty @@ -52,7 +54,7 @@ void main(List args) async { 'vmservice', 'web_audio', 'web_gl', - 'web_sql' + 'web_sql', }; coreLibraries.removeWhere( (lib) => skipLibraries.contains(path.basename(lib.path)), @@ -87,8 +89,9 @@ Future validateLibrary(Directory dir) async { } final Future allowedExperiments = () async { - final allowedExperimentsFile = - File('sdk/lib/_internal/allowed_experiments.json'); + final allowedExperimentsFile = File( + 'sdk/lib/_internal/allowed_experiments.json', + ); final contents = await allowedExperimentsFile.readAsString(); return parseAllowedExperiments(contents); }(); @@ -187,7 +190,10 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor { while (offset != -1) { // Collect template directives, like "```dart import:async". final codeFenceSuffix = text - .substring(offset + sampleStart.length, text.indexOf('\n', offset)) + .substring( + offset + sampleStart.length, + text.indexOf('\n', offset), + ) .trim(); offset = text.indexOf('\n', offset) + 1; @@ -236,11 +242,13 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor { // 1/libdecl: Non-null if matching a `library` declaration. // 2: Internal use, quote around import URI. // 3/importuri: Import URI. - final _toplevelDeclarationRE = RegExp(r'^\s*(?:' - r'library\b(?)|' - r'''import (['"])(?.*?)\2|''' - r'final class\b|class\b|mixin\b|enum\b|extension\b|typedef\b|.*\bmain\(' - r')'); + final _toplevelDeclarationRE = RegExp( + r'^\s*(?:' + r'library\b(?)|' + r'''import (['"])(?.*?)\2|''' + r'final class\b|class\b|mixin\b|enum\b|extension\b|typedef\b|.*\bmain\(' + r')', + ); Future validateCodeSample(CodeSample sample) async { final lines = sample.lines; @@ -323,22 +331,17 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor { final result = await analysisHelper.resolveFile(text); if (result is ResolvedUnitResult) { - var errors = SplayTreeSet.from( - result.errors, - (a, b) { - var value = a.offset.compareTo(b.offset); - if (value == 0) { - value = a.message.compareTo(b.message); - } - return value; - }, - ); + var errors = SplayTreeSet.from(result.errors, (a, b) { + var value = a.offset.compareTo(b.offset); + if (value == 0) { + value = a.message.compareTo(b.message); + } + return value; + }); // Filter out unused imports, since we speculatively add imports to some // samples. - errors.removeWhere( - (e) => e.errorCode == WarningCode.UNUSED_IMPORT, - ); + errors.removeWhere((e) => e.errorCode == WarningCode.UNUSED_IMPORT); // Also, don't worry about 'unused_local_variable' and related; this may // be intentional in samples. @@ -372,10 +375,14 @@ class ValidateCommentCodeSamplesVisitor extends GeneralizingAstVisitor { print(''); // Print out the code sample. - print(sample.lines - .map((line) => - ' >${line.length >= 5 ? line.substring(5) : line.trimLeft()}') - .join('\n')); + print( + sample.lines + .map( + (line) => + ' >${line.length >= 5 ? line.substring(5) : line.trimLeft()}', + ) + .join('\n'), + ); print(''); } } else { @@ -437,7 +444,7 @@ class CodeSample { if (coreLibName != 'internal' && coreLibName != 'core') coreLibName, for (var directive in directives) if (directive.startsWith('import:')) - directive.substring('import:'.length) + directive.substring('import:'.length), }; /// Creates a new code sample by appending [lines] to this sample. @@ -448,10 +455,11 @@ class CodeSample { CodeSample append(List lines, int lineStartOffset) { var gapSize = lineStartOffset - (this.lineStartOffset + this.lines.length); return CodeSample( - [...this.lines, for (var i = 0; i < gapSize; i++) " //", ...lines], - coreLibName: coreLibName, - directives: directives, - lineStartOffset: this.lineStartOffset); + [...this.lines, for (var i = 0; i < gapSize; i++) " //", ...lines], + coreLibName: coreLibName, + directives: directives, + lineStartOffset: this.lineStartOffset, + ); } } @@ -486,8 +494,9 @@ String _severity(Severity severity) { class AnalysisHelper { final String libraryName; - final resourceProvider = - OverlayResourceProvider(PhysicalResourceProvider.INSTANCE); + final resourceProvider = OverlayResourceProvider( + PhysicalResourceProvider.INSTANCE, + ); late final String separator = resourceProvider.pathContext.separator; late final pathRoot = Directory('sdk${separator}lib$separator').absolute.path; late AnalysisContextCollection collection; diff --git a/tools/verify_docs/pubspec.yaml b/tools/verify_docs/pubspec.yaml index c17649cc3f9..d505491109b 100644 --- a/tools/verify_docs/pubspec.yaml +++ b/tools/verify_docs/pubspec.yaml @@ -5,7 +5,9 @@ description: A tool to validate the documentation comments for the `dart:` libra publish_to: none environment: - sdk: '>=2.12.0 <3.0.0' + sdk: ^3.5.0 + +resolution: workspace dependencies: _fe_analyzer_shared: any