diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df4736a9..0a60def1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,8 +22,7 @@ jobs: channel: - master pub: - # TODO - uncomment this after the SDK bumps its dependencies - # - get + - get - upgrade steps: @@ -36,16 +35,16 @@ jobs: - name: Add pub cache bin to PATH run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH - - name: Add pub cache to PATH - run: echo "PUB_CACHE="$HOME/.pub-cache"" >> $GITHUB_ENV - - - name: Add pubspec_overrides to the analyzer_plugin starter - run: "echo \"dependency_overrides:\n custom_lint:\n path: ${{github.workspace}}/packages/custom_lint\" > packages/custom_lint/tools/analyzer_plugin/pubspec_overrides.yaml" + - name: Add pub cache to env + run: echo "PUB_CACHE=\"$HOME/.pub-cache\"" >> $GITHUB_ENV - run: dart pub global activate melos - name: Install dependencies - run: melos exec -- "dart pub ${{ matrix.pub }}" + run: | + dart pub ${{ matrix.pub }} + cd packages/custom_lint/example/example_lint/ dart pub ${{ matrix.pub }} + cd ../../../custom_lint_builder/example/example_lint/ dart pub ${{ matrix.pub }} - name: Check format run: dart format --set-exit-if-changed . diff --git a/README.md b/README.md index a10ee05c..98c7959e 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ To create a custom lint, you will need two things: ```dart import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; - + // This is the entrypoint of our custom linter PluginBase createPlugin() => _ExampleLinter(); @@ -123,7 +123,7 @@ To create a custom lint, you will need two things: @override void run( CustomLintResolver resolver, - ErrorReporter reporter, + DiagnosticReporter reporter, CustomLintContext context, ) { // Our lint will highlight all variable declarations with our custom warning. diff --git a/melos.yaml b/melos.yaml deleted file mode 100644 index b087ccfa..00000000 --- a/melos.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: custom_lint_workspace - -packages: - - packages/custom_lint* - - packages/custom_lint*/example** - - packages/lint_visitor_generator diff --git a/packages/custom_lint/example/example_lint/lib/custom_lint_example_lint.dart b/packages/custom_lint/example/example_lint/lib/custom_lint_example_lint.dart index 85582800..493b0678 100644 --- a/packages/custom_lint/example/example_lint/lib/custom_lint_example_lint.dart +++ b/packages/custom_lint/example/example_lint/lib/custom_lint_example_lint.dart @@ -52,7 +52,7 @@ class PreferFinalProviders extends DartLintRule { void run( // This object contains metadata about the analyzed file CustomLintResolver resolver, - // ErrorReporter is for submitting lints. It contains utilities to specify + // DiagnosticReporter is for submitting lints. It contains utilities to specify // where the lint should show-up. ErrorReporter reporter, // This contains various utilities, including tools for inspecting the content @@ -93,7 +93,7 @@ class _MakeProviderFinalFix extends DartFix { @override void run( CustomLintResolver resolver, - // Similar to ErrorReporter, ChangeReporter is an object used for submitting + // Similar to DiagnosticReporter, ChangeReporter is an object used for submitting // edits within a Dart file. ChangeReporter reporter, CustomLintContext context, diff --git a/packages/custom_lint/example/example_lint/pubspec.yaml b/packages/custom_lint/example/example_lint/pubspec.yaml index 081bec23..8e2ba810 100644 --- a/packages/custom_lint/example/example_lint/pubspec.yaml +++ b/packages/custom_lint/example/example_lint/pubspec.yaml @@ -2,10 +2,10 @@ name: custom_lint_example_lint publish_to: none environment: - sdk: '>=3.0.0 <4.0.0' + sdk: ">=3.5.0 <4.0.0" dependencies: - analyzer: ^7.5.0 + analyzer: ^8.1.0 analyzer_plugin: ^0.13.0 custom_lint_builder: path: ../../../custom_lint_builder diff --git a/packages/custom_lint/example/example_lint/pubspec_overrides.yaml b/packages/custom_lint/example/example_lint/pubspec_overrides.yaml deleted file mode 100644 index dc7d23ca..00000000 --- a/packages/custom_lint/example/example_lint/pubspec_overrides.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# melos_managed_dependency_overrides: custom_lint,custom_lint_builder,custom_lint_core,custom_lint_visitor -dependency_overrides: - custom_lint: - path: ../.. - custom_lint_builder: - path: ../../../custom_lint_builder - custom_lint_core: - path: ../../../custom_lint_core diff --git a/packages/custom_lint/example/pubspec.yaml b/packages/custom_lint/example/pubspec.yaml index 47fac126..8458aa4d 100644 --- a/packages/custom_lint/example/pubspec.yaml +++ b/packages/custom_lint/example/pubspec.yaml @@ -2,7 +2,9 @@ name: custom_lint_example_app publish_to: none environment: - sdk: '>=3.0.0 <4.0.0' + sdk: ">=3.5.0 <4.0.0" + +resolution: workspace dependencies: riverpod: ^2.0.0 diff --git a/packages/custom_lint/example/pubspec_overrides.yaml b/packages/custom_lint/example/pubspec_overrides.yaml deleted file mode 100644 index 53aa5353..00000000 --- a/packages/custom_lint/example/pubspec_overrides.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# melos_managed_dependency_overrides: custom_lint,custom_lint_builder,custom_lint_core,custom_lint_example_lint,custom_lint_visitor -dependency_overrides: - custom_lint: - path: .. - custom_lint_builder: - path: ../../custom_lint_builder - custom_lint_core: - path: ../../custom_lint_core - custom_lint_example_lint: - path: example_lint diff --git a/packages/custom_lint/pubspec.yaml b/packages/custom_lint/pubspec.yaml index ab79f28c..a34475e4 100644 --- a/packages/custom_lint/pubspec.yaml +++ b/packages/custom_lint/pubspec.yaml @@ -5,10 +5,12 @@ repository: https://github.com/invertase/dart_custom_lint issue_tracker: https://github.com/invertase/dart_custom_lint/issues environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.5.0 <4.0.0" + +resolution: workspace dependencies: - analyzer: ^7.5.0 + analyzer: ^8.1.0 analyzer_plugin: ^0.13.0 args: ^2.3.1 async: ^2.9.0 diff --git a/packages/custom_lint/pubspec_overrides.yaml b/packages/custom_lint/pubspec_overrides.yaml deleted file mode 100644 index e5ecc242..00000000 --- a/packages/custom_lint/pubspec_overrides.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# melos_managed_dependency_overrides: custom_lint_core,custom_lint_visitor -dependency_overrides: - custom_lint_core: - path: ../custom_lint_core diff --git a/packages/custom_lint/test/cli_test.dart b/packages/custom_lint/test/cli_test.dart index 86ea9290..4f7e5b17 100644 --- a/packages/custom_lint/test/cli_test.dart +++ b/packages/custom_lint/test/cli_test.dart @@ -1,10 +1,7 @@ import 'dart:convert'; import 'dart:io'; -import 'package:analyzer/error/error.dart' - hide - // ignore: undefined_hidden_name, Needed to support lower analyzer versions - LintCode; +import 'package:analyzer/error/error.dart'; import 'package:custom_lint/src/output/output_format.dart'; import 'package:test/test.dart'; @@ -315,7 +312,7 @@ Analyzing... TestLintRule( code: 'hello_world', message: 'Hello world', - errorSeverity: ErrorSeverity.WARNING, + severity: DiagnosticSeverity.WARNING, ), ]), ); @@ -439,7 +436,7 @@ lib/custom_lint_client.dart:18:26: Error: Undefined name 'createPlugin'. allOf( contains(''' [hello_world] -[hello_world] +[hello_world] [hello_world] Hello [hello_world] world '''), @@ -490,47 +487,47 @@ class _Lint extends DartLintRule { @override void run( CustomLintResolver resolver, - ErrorReporter reporter, + DiagnosticReporter reporter, CustomLintContext context, ) { final line2 = resolver.lineInfo.getOffsetOfLine(1); reporter.atOffset( - errorCode: const LintCode(name: 'x2', problemMessage: 'x2'), + diagnosticCode: const LintCode(name: 'x2', problemMessage: 'x2'), offset: line2 + 1, length: 1, ); reporter.atOffset( - errorCode: const LintCode(name: 'a', problemMessage: 'a'), + diagnosticCode: const LintCode(name: 'a', problemMessage: 'a'), offset: line2 + 1, length: 1, ); reporter.atOffset( - errorCode: const LintCode(name: 'x', problemMessage: 'x'), + diagnosticCode: const LintCode(name: 'x', problemMessage: 'x'), offset: line2 + 1, length: 1, ); reporter.atOffset( - errorCode: const LintCode(name: 'y', problemMessage: 'y'), + diagnosticCode: const LintCode(name: 'y', problemMessage: 'y'), offset: line2, length: 1, ); reporter.atOffset( - errorCode: const LintCode(name: 'z', problemMessage: 'z'), + diagnosticCode: const LintCode(name: 'z', problemMessage: 'z'), offset: 0, length: 1, ); reporter.atOffset( - errorCode: const LintCode(name: 'w', problemMessage: 'w', errorSeverity: ErrorSeverity.WARNING), + diagnosticCode: const LintCode(name: 'w', problemMessage: 'w', severity: DiagnosticSeverity.WARNING), offset: 0, length: 1, ); reporter.atOffset( - errorCode: const LintCode(name: 'e', problemMessage: 'e', errorSeverity: ErrorSeverity.ERROR), + diagnosticCode: const LintCode(name: 'e', problemMessage: 'e', severity: DiagnosticSeverity.ERROR), offset: 0, length: 1, ); reporter.atOffset( - errorCode: const LintCode(name: 's', problemMessage: 's', errorSeverity: ErrorSeverity.ERROR), + diagnosticCode: const LintCode(name: 's', problemMessage: 's', severity: DiagnosticSeverity.ERROR), offset: 1, length: 2, ); diff --git a/packages/custom_lint/test/create_project.dart b/packages/custom_lint/test/create_project.dart index f1478097..48341726 100644 --- a/packages/custom_lint/test/create_project.dart +++ b/packages/custom_lint/test/create_project.dart @@ -34,7 +34,7 @@ class TestLintRule { this.onVariable = '', this.ruleMembers = '', this.fixes = const [], - this.errorSeverity = ErrorSeverity.INFO, + this.severity = DiagnosticSeverity.INFO, }); final String code; @@ -44,7 +44,7 @@ class TestLintRule { final String onVariable; final String ruleMembers; final List fixes; - final ErrorSeverity errorSeverity; + final DiagnosticSeverity severity; void run(StringBuffer buffer) { final fixesCode = fixes.isEmpty @@ -64,7 +64,7 @@ class $code extends DartLintRule { : super( code: LintCode(name: '$code', problemMessage: '$message', - errorSeverity: ErrorSeverity.${errorSeverity.displayName.toUpperCase()}), + severity: DiagnosticSeverity.${severity.displayName.toUpperCase()}), ); $fixesCode @@ -86,7 +86,7 @@ $ruleMembers buffer.write( ''' @override - void run(CustomLintResolver resolver, ErrorReporter reporter, CustomLintContext context) { + void run(CustomLintResolver resolver, DiagnosticReporter reporter, CustomLintContext context) { $onRun context.registry.addFunctionDeclaration((node) { $onVariable @@ -119,8 +119,8 @@ class $name extends DartFix { CustomLintResolver resolver, ChangeReporter reporter, CustomLintContext context, - AnalysisError analysisError, - List others, + Diagnostic analysisError, + List others, ) { context.registry.addFunctionDeclaration((node) { if (!analysisError.sourceRange.intersects(node.sourceRange)) return; diff --git a/packages/custom_lint/test/goldens.dart b/packages/custom_lint/test/goldens.dart index cf2d026d..5b7c73af 100644 --- a/packages/custom_lint/test/goldens.dart +++ b/packages/custom_lint/test/goldens.dart @@ -86,7 +86,8 @@ String _encodePrioritizedSourceChanges( final output = SourceEdit.applySequence( source, prioritizedSourceChange.change.edits - .expand((element) => element.edits), + .expand((element) => element.edits) + .toList(), ); final outputLineInfo = LineInfo.fromContent(output); diff --git a/packages/custom_lint/tools/analyzer_plugin/pubspec.yaml b/packages/custom_lint/tools/analyzer_plugin/pubspec.yaml index f632453b..571200bb 100644 --- a/packages/custom_lint/tools/analyzer_plugin/pubspec.yaml +++ b/packages/custom_lint/tools/analyzer_plugin/pubspec.yaml @@ -4,13 +4,9 @@ version: 0.8.0 publish_to: none environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.5.0 <4.0.0" + +resolution: workspace dependencies: custom_lint: 0.8.0 - -# TODO: If you want to contribute to custom_lint, add a pubspec_overrides.yaml file -# in this folder, containing the following: -# dependency_overrides: -# custom_lint: -# path: /absolute/path/to/custom_lint/folder diff --git a/packages/custom_lint_builder/example/example_lint/lib/custom_lint_builder_example_lint.dart b/packages/custom_lint_builder/example/example_lint/lib/custom_lint_builder_example_lint.dart index 718e9bc3..84538824 100644 --- a/packages/custom_lint_builder/example/example_lint/lib/custom_lint_builder_example_lint.dart +++ b/packages/custom_lint_builder/example/example_lint/lib/custom_lint_builder_example_lint.dart @@ -1,7 +1,4 @@ -import 'package:analyzer/error/error.dart' - hide - // ignore: undefined_hidden_name, Needed to support lower analyzer versions - LintCode; +import 'package:analyzer/diagnostic/diagnostic.dart'; import 'package:analyzer/error/listener.dart'; import 'package:analyzer/source/source_range.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; @@ -52,9 +49,9 @@ class PreferFinalProviders extends DartLintRule { void run( // This object contains metadata about the analyzed file CustomLintResolver resolver, - // ErrorReporter is for submitting lints. It contains utilities to specify + // DiagnosticReporter is for submitting lints. It contains utilities to specify // where the lint should show-up. - ErrorReporter reporter, + DiagnosticReporter reporter, // This contains various utilities, including tools for inspecting the content // of Dart files in an efficient manner. CustomLintContext context, @@ -93,16 +90,16 @@ class _MakeProviderFinalFix extends DartFix { @override void run( CustomLintResolver resolver, - // Similar to ErrorReporter, ChangeReporter is an object used for submitting + // Similar to DiagnosticReporter, ChangeReporter is an object used for submitting // edits within a Dart file. ChangeReporter reporter, CustomLintContext context, // This is the warning that was emitted by our [LintRule] and which we are // trying to fix. - AnalysisError analysisError, + Diagnostic analysisError, // This is the other warnings in the same file defined by our [LintRule]. // Useful in case we want to offer a "fix all" option. - List others, + List others, ) { // Using similar logic as in "PreferFinalProviders", we inspect the Dart file // to search for variable declarations. diff --git a/packages/custom_lint_builder/example/example_lint/pubspec.yaml b/packages/custom_lint_builder/example/example_lint/pubspec.yaml index 51a1f789..197d9958 100644 --- a/packages/custom_lint_builder/example/example_lint/pubspec.yaml +++ b/packages/custom_lint_builder/example/example_lint/pubspec.yaml @@ -2,10 +2,12 @@ name: custom_lint_builder_example_lint publish_to: none environment: - sdk: '>=3.0.0 <4.0.0' + sdk: ">=3.5.0 <4.0.0" + +resolution: workspace dependencies: - analyzer: ^7.5.0 + analyzer: ^8.1.0 analyzer_plugin: ^0.13.0 custom_lint_builder: path: ../../../custom_lint_builder diff --git a/packages/custom_lint_builder/example/example_lint/pubspec_overrides.yaml b/packages/custom_lint_builder/example/example_lint/pubspec_overrides.yaml deleted file mode 100644 index ee6fd0f4..00000000 --- a/packages/custom_lint_builder/example/example_lint/pubspec_overrides.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# melos_managed_dependency_overrides: custom_lint,custom_lint_builder,custom_lint_core,custom_lint_visitor -dependency_overrides: - custom_lint: - path: ../../../custom_lint - custom_lint_builder: - path: ../.. - custom_lint_core: - path: ../../../custom_lint_core diff --git a/packages/custom_lint_builder/example/pubspec.yaml b/packages/custom_lint_builder/example/pubspec.yaml index 2113819e..8d596b21 100644 --- a/packages/custom_lint_builder/example/pubspec.yaml +++ b/packages/custom_lint_builder/example/pubspec.yaml @@ -2,7 +2,9 @@ name: custom_lint_builder_example_app publish_to: none environment: - sdk: '>=3.0.0 <4.0.0' + sdk: ">=3.5.0 <4.0.0" + +resolution: workspace dependencies: riverpod: ^2.0.0 diff --git a/packages/custom_lint_builder/example/pubspec_overrides.yaml b/packages/custom_lint_builder/example/pubspec_overrides.yaml deleted file mode 100644 index 091a138f..00000000 --- a/packages/custom_lint_builder/example/pubspec_overrides.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# melos_managed_dependency_overrides: custom_lint,custom_lint_builder,custom_lint_builder_example_lint,custom_lint_core,custom_lint_visitor -dependency_overrides: - custom_lint: - path: ../../custom_lint - custom_lint_builder: - path: .. - custom_lint_builder_example_lint: - path: example_lint - custom_lint_core: - path: ../../custom_lint_core diff --git a/packages/custom_lint_builder/lib/src/client.dart b/packages/custom_lint_builder/lib/src/client.dart index 74de8a86..d8e2f5b8 100644 --- a/packages/custom_lint_builder/lib/src/client.dart +++ b/packages/custom_lint_builder/lib/src/client.dart @@ -9,6 +9,7 @@ import 'package:analyzer/dart/analysis/analysis_context_collection.dart'; import 'package:analyzer/dart/analysis/context_root.dart'; import 'package:analyzer/dart/analysis/results.dart'; import 'package:analyzer/dart/analysis/session.dart'; +import 'package:analyzer/diagnostic/diagnostic.dart'; import 'package:analyzer/error/error.dart' hide // ignore: undefined_hidden_name, Needed to support lower analyzer versions @@ -413,7 +414,7 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { var _customLintConfigsForAnalysisContexts = {}; final _analysisErrorsForAnalysisContexts = - <_AnalysisErrorsKey, List>{}; + <_AnalysisErrorsKey, List>{}; @override List get fileGlobsToAnalyze => ['*']; @@ -631,14 +632,14 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { analyzer_plugin.AnalysisErrorFixes? batchFixes, analyzer_plugin.AnalysisErrorFixes fix })>> _computeFixes( - List errorsToFix, + List errorsToFix, _FileContext context, - List analysisErrorsForContext, + List analysisErrorsForContext, ) async { return Future.wait( errorsToFix.map((error) async { final toBatch = analysisErrorsForContext - .where((e) => e.errorCode == error.errorCode) + .where((e) => e.diagnosticCode == error.diagnosticCode) .toList(); final changeReporterBuilder = ChangeReporterBuilderImpl( @@ -672,7 +673,7 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { final batchReporterBuilder = BatchChangeReporterBuilder( batchReporter.createChangeBuilder( - message: 'Fix all "${error.errorCode}"', + message: 'Fix all "${error.diagnosticCode}"', priority: batchFix.priority - 1, ), ); @@ -702,14 +703,14 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { Future _runFixes( _FileContext context, - AnalysisError analysisError, - List allErrors, { + Diagnostic analysisError, + List allErrors, { required ChangeReporterBuilder changeReporterBuilder, bool sequential = false, bool Function(Fix fix)? where, }) async { Iterable? fixesForError = - context.configs.fixes[analysisError.errorCode]; + context.configs.fixes[analysisError.diagnosticCode]; if (fixesForError == null) return; if (where != null) { @@ -720,7 +721,7 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { .where( (element) => element != analysisError && - element.errorCode == analysisError.errorCode, + element.diagnosticCode == analysisError.diagnosticCode, ) .toList(); @@ -912,15 +913,15 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { final resolver = analysisContext.createResolverForFile(file); if (resolver == null) return; - final lintsBeforeExpectLint = []; - final reporterBeforeExpectLint = ErrorReporter( + final lintsBeforeExpectLint = []; + final reporterBeforeExpectLint = DiagnosticReporter( // TODO assert that a LintRule only emits lints with a code matching LintRule.code // TODO asserts lintRules can only emit lints in the analyzed file _AnalysisErrorListenerDelegate((analysisError) async { final ignoreForLine = parseIgnoreForLine(analysisError.offset, resolver); - if (!ignoreForLine.isIgnored(analysisError.errorCode.name)) { + if (!ignoreForLine.isIgnored(analysisError.diagnosticCode.name)) { lintsBeforeExpectLint.add(analysisError); } }), @@ -966,8 +967,8 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { runPostRunCallbacks(postRunCallbacks); - final allAnalysisErrors = []; - final analyzerPluginReporter = ErrorReporter( + final allAnalysisErrors = []; + final analyzerPluginReporter = DiagnosticReporter( // TODO assert that a LintRule only emits lints with a code matching LintRule.code // TODO asserts lintRules can only emit lints in the analyzed file _AnalysisErrorListenerDelegate(allAnalysisErrors.add), @@ -1003,7 +1004,7 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { } Future _applyFixes( - List allAnalysisErrors, + List allAnalysisErrors, CustomLintResolver resolver, _CustomLintAnalysisConfigs configs, { required String path, @@ -1033,7 +1034,8 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { allFixes .expand((e) => e.fixes) .expand((e) => e.change.edits) - .expand((e) => e.edits), + .expand((e) => e.edits) + .toList(), ); io.File(path).writeAsStringSync(editedSource); @@ -1064,7 +1066,7 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { } Future> _computeFistBatchFixes( - List allAnalysisErrors, + List allAnalysisErrors, _FileContext context, Set fixedCodes, { required String path, @@ -1072,7 +1074,7 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { if (!_client.fix) return []; final errorToFix = allAnalysisErrors - .where((e) => !fixedCodes.contains(e.errorCode.name)) + .where((e) => !fixedCodes.contains(e.diagnosticCode.name)) .firstOrNull; if (errorToFix == null) return []; @@ -1112,7 +1114,7 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { Future _runLintZoned( CustomLintResolver resolver, FutureOr Function() cb, { - ErrorReporter? reporter, + DiagnosticReporter? reporter, required String name, }) { void onLog(String message) { @@ -1143,7 +1145,7 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { Future _startUpLintRule( LintRule lintRule, CustomLintResolver resolver, - ErrorReporter reporter, + DiagnosticReporter reporter, CustomLintContext lintContext, ) async { await _runLintZoned( @@ -1157,7 +1159,7 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { Future _runLintRule( LintRule lintRule, CustomLintResolver resolver, - ErrorReporter reporter, + DiagnosticReporter reporter, CustomLintContext lintContext, ) async { await _runLintZoned( @@ -1174,7 +1176,7 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { CustomLintResolver resolver, Object error, StackTrace stackTrace, { - ErrorReporter? reporter, + DiagnosticReporter? reporter, required String pluginName, }) { _channel.sendEvent( @@ -1190,7 +1192,7 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { const code = LintCode( name: 'custom_lint_get_lint_fail', problemMessage: 'A lint plugin threw an exception', - errorSeverity: ErrorSeverity.ERROR, + severity: DiagnosticSeverity.ERROR, ); // TODO add context message that points to the fir line of the stacktrace @@ -1201,7 +1203,7 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { resolver.lineInfo.lineStarts.elementAtOrNull(1) ?? startOffset; reporter.atOffset( - errorCode: code, + diagnosticCode: code, offset: startOffset, length: endOffset - startOffset, ); @@ -1216,25 +1218,25 @@ class _ClientAnalyzerPlugin extends analyzer_plugin.ServerPlugin { } } -class _AnalysisErrorListenerDelegate implements AnalysisErrorListener { +class _AnalysisErrorListenerDelegate implements DiagnosticListener { _AnalysisErrorListenerDelegate(this._onError); - final void Function(AnalysisError error) _onError; + final void Function(Diagnostic error) _onError; @override - void onError(AnalysisError error) => _onError(error); + void onDiagnostic(Diagnostic error) => _onError(error); } extension on ChangeReporterBuilder { Future completeAsFixes( - AnalysisError analysisError, + Diagnostic analysisError, _FileContext context, ) async { return analyzer_plugin.AnalysisErrorFixes( CustomAnalyzerConverter().convertAnalysisError( analysisError, lineInfo: context.resolver.lineInfo, - severity: analysisError.errorCode.errorSeverity, + severity: analysisError.diagnosticCode.severity, ), fixes: await complete(), ); diff --git a/packages/custom_lint_builder/lib/src/custom_analyzer_converter.dart b/packages/custom_lint_builder/lib/src/custom_analyzer_converter.dart index 75920398..eea0d946 100644 --- a/packages/custom_lint_builder/lib/src/custom_analyzer_converter.dart +++ b/packages/custom_lint_builder/lib/src/custom_analyzer_converter.dart @@ -22,12 +22,12 @@ class CustomAnalyzerConverter { /// error's location will have a start line and start column. If a [severity] /// is provided, then it will override the severity defined by the error. plugin.AnalysisError convertAnalysisError( - analyzer.AnalysisError error, { + analyzer.Diagnostic error, { analyzer.LineInfo? lineInfo, - analyzer.ErrorSeverity? severity, + analyzer.DiagnosticSeverity? severity, }) { - var errorCode = error.errorCode; - severity ??= errorCode.errorSeverity; + var diagnosticCode = error.diagnosticCode; + severity ??= diagnosticCode.severity; var offset = error.offset; var startLine = -1; var startColumn = -1; @@ -50,16 +50,16 @@ class CustomAnalyzerConverter { } return plugin.AnalysisError( convertErrorSeverity(severity), - convertErrorType(errorCode.type), + convertErrorType(diagnosticCode.type), plugin.Location( error.source.fullName, offset, error.length, startLine, startColumn, endLine: endLine, endColumn: endColumn), error.message, - errorCode.name.toLowerCase(), + diagnosticCode.name.toLowerCase(), contextMessages: contextMessages, - correction: error.correction, + correction: error.correctionMessage, hasFix: null, - url: errorCode.url, + url: diagnosticCode.url, ); } @@ -69,7 +69,7 @@ class CustomAnalyzerConverter { /// start column. If an analysis [options] is provided then the severities of /// the errors will be altered based on those options. List convertAnalysisErrors( - List errors, + List errors, {analyzer.LineInfo? lineInfo, analyzer.AnalysisOptions? options}) { var serverErrors = []; @@ -120,11 +120,11 @@ class CustomAnalyzerConverter { /// Convert the error [severity] from the 'analyzer' package to an analysis /// error severity defined by the plugin API. plugin.AnalysisErrorSeverity convertErrorSeverity( - analyzer.ErrorSeverity severity) => + analyzer.DiagnosticSeverity severity) => plugin.AnalysisErrorSeverity.values.byName(severity.name); /// Convert the error [type] from the 'analyzer' package to an analysis error /// type defined by the plugin API. - plugin.AnalysisErrorType convertErrorType(analyzer.ErrorType type) => + plugin.AnalysisErrorType convertErrorType(analyzer.DiagnosticType type) => plugin.AnalysisErrorType.values.byName(type.name); } diff --git a/packages/custom_lint_builder/lib/src/expect_lint.dart b/packages/custom_lint_builder/lib/src/expect_lint.dart index f110f371..55586ff1 100644 --- a/packages/custom_lint_builder/lib/src/expect_lint.dart +++ b/packages/custom_lint_builder/lib/src/expect_lint.dart @@ -1,7 +1,5 @@ -import 'package:analyzer/error/error.dart' - hide - // ignore: undefined_hidden_name, Needed to support lower analyzer versions - LintCode; +import 'package:analyzer/diagnostic/diagnostic.dart'; +import 'package:analyzer/error/error.dart' hide LintCode; import 'package:analyzer/error/listener.dart'; import 'package:analyzer/source/line_info.dart'; import 'package:meta/meta.dart'; @@ -22,16 +20,16 @@ class ExpectLint { 'Expected to find the lint {0} on next line but none found.', correctionMessage: 'Either update the code such that it emits the lint {0} ' 'or update the expect_lint clause to not include the code {0}.', - errorSeverity: ErrorSeverity.ERROR, + severity: DiagnosticSeverity.ERROR, ); /// The list of lints emitted in the file. - final List analysisErrors; + final List analysisErrors; /// Emits expect_lints void run( CustomLintResolver resolver, - ErrorReporter reporter, + DiagnosticReporter reporter, ) { final expectLints = _getAllExpectedLints( resolver.source.contents.data, @@ -54,7 +52,7 @@ class ExpectLint { // we remove 1 to have them on the same unit. Then we remove 1 again // to access the line before the lint. lintLine.lineNumber - 2, - lint.errorCode.name, + lint.diagnosticCode.name, ); if (allExpectedLints.contains(matchingExpectLintMeta)) { @@ -74,7 +72,7 @@ class ExpectLint { // Some expect_lint clauses where not respected for (final unfulfilledExpectedLint in unfulfilledExpectedLints) { reporter.atOffset( - errorCode: _code, + diagnosticCode: _code, offset: unfulfilledExpectedLint.offset, length: unfulfilledExpectedLint.code.length, arguments: [unfulfilledExpectedLint.code], diff --git a/packages/custom_lint_builder/lib/src/ignore.dart b/packages/custom_lint_builder/lib/src/ignore.dart index b5d57b25..d909c6f5 100644 --- a/packages/custom_lint_builder/lib/src/ignore.dart +++ b/packages/custom_lint_builder/lib/src/ignore.dart @@ -1,7 +1,4 @@ -import 'package:analyzer/error/error.dart' - hide - // ignore: undefined_hidden_name, Needed to support lower analyzer versions - LintCode; +import 'package:analyzer/diagnostic/diagnostic.dart'; import 'package:collection/collection.dart'; import 'package:custom_lint_core/custom_lint_core.dart'; @@ -114,14 +111,14 @@ class IgnoreCode extends DartFix { CustomLintResolver resolver, ChangeReporter reporter, CustomLintContext context, - AnalysisError analysisError, - List others, + Diagnostic analysisError, + List others, ) { final ignoreForLine = parseIgnoreForLine(analysisError.offset, resolver); final ignoreForFile = parseIgnoreForFile(resolver.source.contents.data); final ignoreForLineChangeBuilder = reporter.createChangeBuilder( - message: 'Ignore "${analysisError.errorCode.name}" for line', + message: 'Ignore "${analysisError.diagnosticCode.name}" for line', priority: 1, ); @@ -129,7 +126,7 @@ class IgnoreCode extends DartFix { if (ignoreForLine.hasIgnore) { builder.addSimpleInsertion( ignoreForLine.endOffset, - ', ${analysisError.errorCode.name}', + ', ${analysisError.diagnosticCode.name}', ); } else { final offsetLine = @@ -143,13 +140,13 @@ class IgnoreCode extends DartFix { builder.addSimpleInsertion( startLineOffset, - '${' ' * indentLength}// ignore: ${analysisError.errorCode.name}\n', + '${' ' * indentLength}// ignore: ${analysisError.diagnosticCode.name}\n', ); } }); final ignoreForFileChangeBuilder = reporter.createChangeBuilder( - message: 'Ignore "${analysisError.errorCode.name}" for file', + message: 'Ignore "${analysisError.diagnosticCode.name}" for file', priority: 0, ); @@ -158,12 +155,12 @@ class IgnoreCode extends DartFix { if (firstIgnore == null) { builder.addSimpleInsertion( 0, - '// ignore_for_file: ${analysisError.errorCode.name}\n', + '// ignore_for_file: ${analysisError.diagnosticCode.name}\n', ); } else { builder.addSimpleInsertion( firstIgnore.endOffset, - ', ${analysisError.errorCode.name}', + ', ${analysisError.diagnosticCode.name}', ); } }); diff --git a/packages/custom_lint_builder/pubspec.yaml b/packages/custom_lint_builder/pubspec.yaml index a052862c..a3513f93 100644 --- a/packages/custom_lint_builder/pubspec.yaml +++ b/packages/custom_lint_builder/pubspec.yaml @@ -4,10 +4,12 @@ description: A package to help writing custom linters repository: https://github.com/invertase/dart_custom_lint environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.5.0 <4.0.0" + +resolution: workspace dependencies: - analyzer: ^7.5.0 + analyzer: ^8.1.0 analyzer_plugin: ^0.13.0 collection: ^1.16.0 # Using tight constraints as custom_lint_builder communicate with each-other diff --git a/packages/custom_lint_builder/pubspec_overrides.yaml b/packages/custom_lint_builder/pubspec_overrides.yaml deleted file mode 100644 index aac3d839..00000000 --- a/packages/custom_lint_builder/pubspec_overrides.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# melos_managed_dependency_overrides: custom_lint_visitor -dependency_overrides: - custom_lint: - path: ../custom_lint - custom_lint_core: - path: ../custom_lint_core - lint_visitor_generator: - path: ../lint_visitor_generator diff --git a/packages/custom_lint_builder/test/analyzer_converter_test.dart b/packages/custom_lint_builder/test/analyzer_converter_test.dart index 654c7cb5..38da1f3d 100644 --- a/packages/custom_lint_builder/test/analyzer_converter_test.dart +++ b/packages/custom_lint_builder/test/analyzer_converter_test.dart @@ -1,7 +1,4 @@ -import 'package:analyzer/error/error.dart' - hide - // ignore: undefined_hidden_name, Needed to support lower analyzer versions - LintCode; +import 'package:analyzer/diagnostic/diagnostic.dart'; import 'package:analyzer/file_system/memory_file_system.dart'; import 'package:analyzer/source/file_source.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; @@ -24,11 +21,11 @@ void main() { ), ); - final another = AnalysisError.tmp( + final another = Diagnostic.tmp( source: source, offset: 11, length: 12, - errorCode: const LintCode( + diagnosticCode: const LintCode( name: 'another', problemMessage: 'another message', url: 'https://dart.dev/diagnostics/another', @@ -38,11 +35,11 @@ void main() { expect( CustomAnalyzerConverter() .convertAnalysisError( - AnalysisError.tmp( + Diagnostic.tmp( source: source2, offset: 13, length: 14, - errorCode: const LintCode( + diagnosticCode: const LintCode( name: 'foo', problemMessage: 'bar', url: 'https://google.com/diagnostics/foo', diff --git a/packages/custom_lint_core/lib/src/assist.dart b/packages/custom_lint_core/lib/src/assist.dart index 76724240..dc036a0a 100644 --- a/packages/custom_lint_core/lib/src/assist.dart +++ b/packages/custom_lint_core/lib/src/assist.dart @@ -110,7 +110,7 @@ abstract class DartAssist extends Assist { () => Future.value(result), lineInfo: result.lineInfo, path: result.path, - source: result.libraryElement2.firstFragment.source, + source: result.libraryElement.firstFragment.source, ); final reporter = ChangeReporterImpl(result.session, resolver); @@ -134,7 +134,7 @@ abstract class DartAssist extends Assist { io.File file, SourceRange target, ) async { - final result = await resolveFile2(path: file.path); + final result = await resolveFile(path: file.path); result as ResolvedUnitResult; return testRun(result, target); } diff --git a/packages/custom_lint_core/lib/src/fixes.dart b/packages/custom_lint_core/lib/src/fixes.dart index bf9e045c..f6b9f1cb 100644 --- a/packages/custom_lint_core/lib/src/fixes.dart +++ b/packages/custom_lint_core/lib/src/fixes.dart @@ -2,10 +2,7 @@ import 'dart:io'; import 'package:analyzer/dart/analysis/results.dart'; import 'package:analyzer/dart/analysis/utilities.dart'; -import 'package:analyzer/error/error.dart' - hide - // ignore: undefined_hidden_name, Needed to support lower analyzer versions - LintCode; +import 'package:analyzer/diagnostic/diagnostic.dart'; import 'package:analyzer_plugin/protocol/protocol_generated.dart'; import 'package:custom_lint_visitor/custom_lint_visitor.dart'; import 'package:meta/meta.dart'; @@ -22,8 +19,8 @@ import 'runnable.dart'; @internal typedef FixArgs = ({ ChangeReporter reporter, - AnalysisError analysisError, - List others, + Diagnostic analysisError, + List others, }); const _uid = Uuid(); @@ -86,8 +83,8 @@ abstract class Fix extends Runnable { CustomLintResolver resolver, ChangeReporter reporter, CustomLintContext context, - AnalysisError analysisError, - List others, + Diagnostic analysisError, + List others, ); } @@ -129,8 +126,8 @@ abstract class DartFix extends Fix { @visibleForTesting Future> testRun( ResolvedUnitResult result, - AnalysisError analysisError, - List others, { + Diagnostic analysisError, + List others, { Pubspec? pubspec, }) async { final registry = LintRuleNodeRegistry( @@ -148,7 +145,7 @@ abstract class DartFix extends Fix { () => Future.value(result), lineInfo: result.lineInfo, path: result.path, - source: result.libraryElement2.firstFragment.source, + source: result.libraryElement.firstFragment.source, ); final reporter = ChangeReporterImpl(result.session, resolver); @@ -165,10 +162,10 @@ abstract class DartFix extends Fix { @visibleForTesting Future> testAnalyzeAndRun( File file, - AnalysisError analysisError, - List others, + Diagnostic analysisError, + List others, ) async { - final result = await resolveFile2(path: file.path); + final result = await resolveFile(path: file.path); result as ResolvedUnitResult; return testRun(result, analysisError, others); } diff --git a/packages/custom_lint_core/lib/src/lint_codes.dart b/packages/custom_lint_core/lib/src/lint_codes.dart index c1c60cf5..2dfdad87 100644 --- a/packages/custom_lint_core/lib/src/lint_codes.dart +++ b/packages/custom_lint_core/lib/src/lint_codes.dart @@ -4,37 +4,34 @@ // 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/error/error.dart' - hide - // ignore: undefined_hidden_name, Needed to support lower analyzer versions - LintCode; +import 'package:analyzer/error/error.dart' hide LintCode; import 'package:meta/meta.dart'; import '../custom_lint_core.dart'; -/// A class representing an [ErrorCode] for [LintRule]s. +/// A class representing an [DiagnosticCode] for [LintRule]s. @immutable -class LintCode extends ErrorCode { - /// A class representing an [ErrorCode] for [LintRule]s. +class LintCode extends DiagnosticCode { + /// A class representing an [DiagnosticCode] for [LintRule]s. const LintCode({ required super.name, required super.problemMessage, super.correctionMessage, String? uniqueName, this.url, - this.errorSeverity = ErrorSeverity.INFO, + this.severity = DiagnosticSeverity.INFO, }) : super( uniqueName: uniqueName ?? name, ); @override - ErrorType get type => ErrorType.LINT; + DiagnosticType get type => DiagnosticType.LINT; @override final String? url; @override - final ErrorSeverity errorSeverity; + final DiagnosticSeverity severity; @override int get hashCode => uniqueName.hashCode; diff --git a/packages/custom_lint_core/lib/src/lint_rule.dart b/packages/custom_lint_core/lib/src/lint_rule.dart index 18ba2a4e..d7cc7d36 100644 --- a/packages/custom_lint_core/lib/src/lint_rule.dart +++ b/packages/custom_lint_core/lib/src/lint_rule.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'package:analyzer/dart/analysis/results.dart'; import 'package:analyzer/dart/analysis/utilities.dart'; import 'package:analyzer/dart/ast/ast.dart'; -import 'package:analyzer/error/error.dart' show AnalysisError; +import 'package:analyzer/diagnostic/diagnostic.dart'; import 'package:analyzer/error/listener.dart'; import 'package:custom_lint_visitor/custom_lint_visitor.dart'; import 'package:meta/meta.dart'; @@ -97,7 +97,7 @@ abstract class LintRule { /// [run] will only be invoked with files respecting [filesToAnalyze] void run( CustomLintResolver resolver, - ErrorReporter reporter, + DiagnosticReporter reporter, CustomLintContext context, ); @@ -145,7 +145,7 @@ abstract class DartLintRule extends LintRule { /// be passed to [CustomLintContext.pubspec]. /// By default, an empty pubspec with the name `test_project` will be used. @visibleForTesting - Future> testRun( + Future> testRun( ResolvedUnitResult result, { Pubspec? pubspec, }) async { @@ -164,13 +164,13 @@ abstract class DartLintRule extends LintRule { () => Future.value(result), lineInfo: result.lineInfo, path: result.path, - source: result.libraryElement2.firstFragment.source, + source: result.libraryElement.firstFragment.source, ); - final listener = RecordingErrorListener(); - final reporter = ErrorReporter( + final listener = RecordingDiagnosticListener(); + final reporter = DiagnosticReporter( listener, - result.libraryElement2.firstFragment.source, + result.libraryElement.firstFragment.source, ); await startUp(resolver, context); @@ -178,15 +178,15 @@ abstract class DartLintRule extends LintRule { run(resolver, reporter, context); runPostRunCallbacks(postRunCallbacks); - return listener.errors; + return listener.diagnostics; } /// Analyze a Dart file and runs this assist in test mode. /// /// The result will contain all the changes that would have been applied by [run]. @visibleForTesting - Future> testAnalyzeAndRun(File file) async { - final result = await resolveFile2(path: file.path); + Future> testAnalyzeAndRun(File file) async { + final result = await resolveFile(path: file.path); result as ResolvedUnitResult; return testRun(result); } diff --git a/packages/custom_lint_core/lib/src/matcher.dart b/packages/custom_lint_core/lib/src/matcher.dart index b25324a6..a62b1880 100644 --- a/packages/custom_lint_core/lib/src/matcher.dart +++ b/packages/custom_lint_core/lib/src/matcher.dart @@ -69,7 +69,8 @@ String encodePrioritizedSourceChanges( final output = SourceEdit.applySequence( source, prioritizedSourceChange.change.edits - .expand((element) => element.edits), + .expand((element) => element.edits) + .toList(), ); final outputLineInfo = LineInfo.fromContent(output); diff --git a/packages/custom_lint_core/lib/src/source_range_extensions.dart b/packages/custom_lint_core/lib/src/source_range_extensions.dart index 0097c192..b363bd70 100644 --- a/packages/custom_lint_core/lib/src/source_range_extensions.dart +++ b/packages/custom_lint_core/lib/src/source_range_extensions.dart @@ -1,8 +1,5 @@ import 'package:analyzer/dart/ast/syntactic_entity.dart'; -import 'package:analyzer/error/error.dart' - hide - // ignore: undefined_hidden_name, Needed to support lower analyzer versions - LintCode; +import 'package:analyzer/diagnostic/diagnostic.dart'; import 'package:analyzer/source/source_range.dart'; /// Adds [sourceRange] @@ -12,7 +9,7 @@ extension SyntacticEntitySourceRange on SyntacticEntity { } /// Adds [sourceRange] -extension AnalysisErrorSourceRange on AnalysisError { +extension AnalysisErrorSourceRange on Diagnostic { /// A [SourceRange] based on [offset] + [length] SourceRange get sourceRange => SourceRange(offset, length); } diff --git a/packages/custom_lint_core/lib/src/type_checker.dart b/packages/custom_lint_core/lib/src/type_checker.dart index 524da23f..f543f403 100644 --- a/packages/custom_lint_core/lib/src/type_checker.dart +++ b/packages/custom_lint_core/lib/src/type_checker.dart @@ -7,7 +7,7 @@ import 'package:analyzer/dart/analysis/results.dart'; import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/constant/value.dart'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:meta/meta.dart'; import 'package:path/path.dart' as p; @@ -72,21 +72,21 @@ abstract class TypeChecker { /// package like in the `dart:` SDK. const factory TypeChecker.fromUrl(dynamic url) = _UriTypeChecker; - /// Returns the first constant annotating [annotatable] assignable to this type. + /// Returns the first constant annotating [element] assignable to this type. /// /// Otherwise returns `null`. /// /// Throws on unresolved annotations unless [throwOnUnresolved] is `false`. DartObject? firstAnnotationOf( - Annotatable annotatable, { + Element element, { bool throwOnUnresolved = true, }) { - final annotations = annotatable.metadata2.annotations; + final annotations = element.metadata.annotations; if (annotations.isEmpty) { return null; } final results = annotationsOf( - annotatable, + element, throwOnUnresolved: throwOnUnresolved, ); return results.isEmpty ? null : results.first; @@ -95,38 +95,38 @@ abstract class TypeChecker { /// Returns if a constant annotating [element] is assignable to this type. /// /// Throws on unresolved annotations unless [throwOnUnresolved] is `false`. - bool hasAnnotationOf(Annotatable element, {bool throwOnUnresolved = true}) => + bool hasAnnotationOf(Element element, {bool throwOnUnresolved = true}) => firstAnnotationOf(element, throwOnUnresolved: throwOnUnresolved) != null; - /// Returns the first constant annotating [annotatable] that is exactly this type. + /// Returns the first constant annotating [element] that is exactly this type. /// /// Throws [UnresolvedAnnotationException] on unresolved annotations unless /// [throwOnUnresolved] is explicitly set to `false` (default is `true`). DartObject? firstAnnotationOfExact( - Annotatable annotatable, { + Element element, { bool throwOnUnresolved = true, }) { - final annotations = annotatable.metadata2.annotations; + final annotations = element.metadata.annotations; if (annotations.isEmpty) { return null; } final results = annotationsOfExact( - annotatable, + element, throwOnUnresolved: throwOnUnresolved, ); return results.isEmpty ? null : results.first; } - /// Returns if a constant annotating [annotatable] is exactly this type. + /// Returns if a constant annotating [element] is exactly this type. /// /// Throws [UnresolvedAnnotationException] on unresolved annotations unless /// [throwOnUnresolved] is explicitly set to `false` (default is `true`). bool hasAnnotationOfExact( - Annotatable annotatable, { + Element element, { bool throwOnUnresolved = true, }) => firstAnnotationOfExact( - annotatable, + element, throwOnUnresolved: throwOnUnresolved, ) != null; @@ -138,35 +138,35 @@ abstract class TypeChecker { bool throwOnUnresolved = true, }) { final result = annotation.computeConstantValue(); - if (result == null && throwOnUnresolved && element is Element2) { + if (result == null && throwOnUnresolved && element is Element) { throw UnresolvedAnnotationException._from(element, annotationIndex); } return result; } - /// Returns annotating constants on [annotatable] assignable to this type. + /// Returns annotating constants on [element] assignable to this type. /// /// Throws [UnresolvedAnnotationException] on unresolved annotations unless /// [throwOnUnresolved] is explicitly set to `false` (default is `true`). Iterable annotationsOf( - Annotatable annotatable, { + Element element, { bool throwOnUnresolved = true, }) => _annotationsWhere( - annotatable, + element, isAssignableFromType, throwOnUnresolved: throwOnUnresolved, ); Iterable _annotationsWhere( - Annotatable annotatable, + Element element, bool Function(DartType) predicate, { bool throwOnUnresolved = true, }) sync* { - final annotations = annotatable.metadata2.annotations; + final annotations = element.metadata.annotations; for (var i = 0; i < annotations.length; i++) { final value = _computeConstantValue( - annotatable, + element, annotations[i], i, throwOnUnresolved: throwOnUnresolved, @@ -177,41 +177,40 @@ abstract class TypeChecker { } } - /// Returns annotating constants on [annotatable] of exactly this type. + /// Returns annotating constants on [element] of exactly this type. /// /// Throws [UnresolvedAnnotationException] on unresolved annotations unless /// [throwOnUnresolved] is explicitly set to `false` (default is `true`). Iterable annotationsOfExact( - Annotatable annotatable, { + Element element, { bool throwOnUnresolved = true, }) => _annotationsWhere( - annotatable, + element, isExactlyType, throwOnUnresolved: throwOnUnresolved, ); /// Returns `true` if the type of [element] can be assigned to this type. - bool isAssignableFrom(Element2 element) => + bool isAssignableFrom(Element element) => isExactly(element) || - (element is InterfaceElement2 && - element.allSupertypes.any(isExactlyType)); + (element is InterfaceElement && element.allSupertypes.any(isExactlyType)); /// Returns `true` if [staticType] can be assigned to this type. bool isAssignableFromType(DartType staticType) { - final element = staticType.element3; + final element = staticType.element; return element != null && isAssignableFrom(element); } /// Returns `true` if representing the exact same class as [element]. - bool isExactly(Element2 element); + bool isExactly(Element element); /// Returns `true` if representing the exact same type as [staticType]. /// /// This will always return false for types without a backing class such as /// `void` or function types. bool isExactlyType(DartType staticType) { - final element = staticType.element3; + final element = staticType.element; return element != null && isExactly(element); } @@ -219,8 +218,8 @@ abstract class TypeChecker { /// /// This check only takes into account the *extends* hierarchy. If you wish /// to check mixins and interfaces, use [isAssignableFrom]. - bool isSuperOf(Element2 element) { - if (element is InterfaceElement2) { + bool isSuperOf(Element element) { + if (element is InterfaceElement) { var theSuper = element.supertype; do { @@ -240,7 +239,7 @@ abstract class TypeChecker { /// This only takes into account the *extends* hierarchy. If you wish /// to check mixins and interfaces, use [isAssignableFromType]. bool isSuperTypeOf(DartType staticType) { - final element = staticType.element3; + final element = staticType.element; return element != null && isSuperOf(element); } } @@ -251,11 +250,11 @@ class _LibraryTypeChecker extends TypeChecker { final DartType _type; @override - bool isExactly(Element2 element) => - element is InterfaceElement2 && element == _type.element3; + bool isExactly(Element element) => + element is InterfaceElement && element == _type.element; @override - String toString() => _urlOfElement(_type.element3!); + String toString() => _urlOfElement(_type.element!); } @immutable @@ -265,8 +264,8 @@ class _PackageChecker extends TypeChecker { final String _packageName; @override - bool isExactly(Element2 element) { - final targetUri = element.library2?.uri; + bool isExactly(Element element) { + final targetUri = element.library?.uri; if (targetUri == null) return false; if (_packageName == targetUri.toString()) return true; @@ -294,8 +293,8 @@ class _NamedChecker extends TypeChecker { final String? packageName; @override - bool isExactly(Element2 element) { - if (element.name3 != _name) return false; + bool isExactly(Element element) { + if (element.name != _name) return false; // No packageName specified, ignoring it. if (packageName == null) return true; @@ -339,7 +338,7 @@ class _UriTypeChecker extends TypeChecker { (url is String ? url : _normalizeUrl(url as Uri).toString()); @override - bool isExactly(Element2 element) => hasSameUrl(_urlOfElement(element)); + bool isExactly(Element element) => hasSameUrl(_urlOfElement(element)); @override bool operator ==(Object o) => o is _UriTypeChecker && o._url == _url; @@ -356,8 +355,7 @@ class _AnyChecker extends TypeChecker { final Iterable _checkers; @override - bool isExactly(Element2 element) => - _checkers.any((c) => c.isExactly(element)); + bool isExactly(Element element) => _checkers.any((c) => c.isExactly(element)); } class _EveryChecker extends TypeChecker { @@ -366,7 +364,7 @@ class _EveryChecker extends TypeChecker { final Iterable _checkers; @override - bool isExactly(Element2 element) { + bool isExactly(Element element) { return _checkers.every((c) => c.isExactly(element)); } } @@ -379,9 +377,9 @@ class _EveryChecker extends TypeChecker { /// defined (for build systems such as Bazel). class UnresolvedAnnotationException implements Exception { /// Creates an exception from an annotation ([annotationIndex]) that was not - /// resolvable while traversing `metadata2` on [annotatedElement]. + /// resolvable while traversing `metadata` on [annotatedElement]. factory UnresolvedAnnotationException._from( - Element2 annotatedElement, + Element annotatedElement, int annotationIndex, ) { final sourceSpan = _findSpan(annotatedElement, annotationIndex); @@ -394,16 +392,16 @@ class UnresolvedAnnotationException implements Exception { ); /// Element that was annotated with something we could not resolve. - final Element2 annotatedElement; + final Element annotatedElement; /// Source span of the annotation that was not resolved. /// /// May be `null` if the import library was not found. final SourceSpan? annotationSource; - static SourceSpan? _findSpan(Element2 annotatedElement, int annotationIndex) { - final parsedLibrary = annotatedElement.session!.getParsedLibraryByElement2( - annotatedElement.library2!, + static SourceSpan? _findSpan(Element annotatedElement, int annotationIndex) { + final parsedLibrary = annotatedElement.session!.getParsedLibraryByElement( + annotatedElement.library!, ) as ParsedLibraryResult; final declaration = parsedLibrary.getFragmentDeclaration( annotatedElement.firstFragment, @@ -444,13 +442,13 @@ class UnresolvedAnnotationException implements Exception { } /// Returns a URL representing [element]. -String _urlOfElement(Element2 element) => element.kind == ElementKind.DYNAMIC +String _urlOfElement(Element element) => element.kind == ElementKind.DYNAMIC ? 'dart:core#dynamic' : element.kind == ElementKind.NEVER ? 'dart:core#Never' // using librarySource.uri – in case the element is in a part - : _normalizeUrl(element.library2!.uri) - .replace(fragment: element.name3) + : _normalizeUrl(element.library!.uri) + .replace(fragment: element.name) .toString(); Uri _normalizeUrl(Uri url) { diff --git a/packages/custom_lint_core/pubspec.yaml b/packages/custom_lint_core/pubspec.yaml index c12a24a9..afe5122a 100644 --- a/packages/custom_lint_core/pubspec.yaml +++ b/packages/custom_lint_core/pubspec.yaml @@ -4,10 +4,12 @@ description: A package to help writing custom linters repository: https://github.com/invertase/dart_custom_lint environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.5.0 <4.0.0" + +resolution: workspace dependencies: - analyzer: ^7.5.0 + analyzer: ^8.1.0 analyzer_plugin: ^0.13.0 collection: ^1.16.0 custom_lint_visitor: ^1.0.0 diff --git a/packages/custom_lint_core/pubspec_overrides.yaml b/packages/custom_lint_core/pubspec_overrides.yaml deleted file mode 100644 index fa38855e..00000000 --- a/packages/custom_lint_core/pubspec_overrides.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# melos_managed_dependency_overrides: lint_visitor_generator,custom_lint_visitor -dependency_overrides: - custom_lint: - path: ../custom_lint - lint_visitor_generator: - path: ../lint_visitor_generator diff --git a/packages/custom_lint_core/test/assist_test.dart b/packages/custom_lint_core/test/assist_test.dart index 84ea82a0..6e1d4b0d 100644 --- a/packages/custom_lint_core/test/assist_test.dart +++ b/packages/custom_lint_core/test/assist_test.dart @@ -35,7 +35,7 @@ void main() { } '''; final file = writeToTemporaryFile(fileSource); - final result = await resolveFile2(path: file.path); + final result = await resolveFile(path: file.path); result as ResolvedUnitResult; final changes = assist.testRun(result, SourceRange.EMPTY); @@ -108,7 +108,7 @@ void main() { print('Custom world'); } '''); - final result = await resolveFile2(path: file.path); + final result = await resolveFile(path: file.path); result as ResolvedUnitResult; final changeList1 = await assist1.testRun(result, SourceRange.EMPTY); diff --git a/packages/custom_lint_core/test/fix_test.dart b/packages/custom_lint_core/test/fix_test.dart index cf344116..28a76823 100644 --- a/packages/custom_lint_core/test/fix_test.dart +++ b/packages/custom_lint_core/test/fix_test.dart @@ -1,9 +1,6 @@ import 'package:analyzer/dart/analysis/results.dart'; import 'package:analyzer/dart/analysis/utilities.dart'; -import 'package:analyzer/error/error.dart' - hide - // ignore: undefined_hidden_name, Needed to support lower analyzer versions - LintCode; +import 'package:analyzer/diagnostic/diagnostic.dart'; import 'package:custom_lint_core/src/change_reporter.dart'; import 'package:custom_lint_core/src/fixes.dart'; import 'package:custom_lint_core/src/lint_rule.dart'; @@ -25,7 +22,7 @@ void main() { } '''; final file = writeToTemporaryFile(fileSource); - final result = await resolveFile2(path: file.path); + final result = await resolveFile(path: file.path); result as ResolvedUnitResult; final errors = await const MyLintRule().testRun(result); @@ -116,8 +113,8 @@ class MyFix extends DartFix { CustomLintResolver resolver, ChangeReporter reporter, CustomLintContext context, - AnalysisError analysisError, - List others, + Diagnostic analysisError, + List others, ) { context.registry.addMethodInvocation((node) { final changeBuilder = reporter.createChangeBuilder( diff --git a/packages/custom_lint_core/test/lint_rule_test.dart b/packages/custom_lint_core/test/lint_rule_test.dart index 7dfa16e4..409b3576 100644 --- a/packages/custom_lint_core/test/lint_rule_test.dart +++ b/packages/custom_lint_core/test/lint_rule_test.dart @@ -28,7 +28,7 @@ class TestLintRule extends LintRule { @override void run( CustomLintResolver resolver, - ErrorReporter reporter, + DiagnosticReporter reporter, CustomLintContext context, ) {} } @@ -45,7 +45,7 @@ class MyLintRule extends DartLintRule { @override void run( CustomLintResolver resolver, - ErrorReporter reporter, + DiagnosticReporter reporter, CustomLintContext context, ) { context.registry.addMethodInvocation((node) { @@ -67,14 +67,14 @@ void main() { print('Hello world'); } '''); - final result = await resolveFile2(path: file.path); + final result = await resolveFile(path: file.path); result as ResolvedUnitResult; final analysisErrors = await assist.testRun(result); expect(analysisErrors, hasLength(1)); - expect(analysisErrors.first.errorCode.name, 'my_lint_code'); + expect(analysisErrors.first.diagnosticCode.name, 'my_lint_code'); expect(analysisErrors.first.message, 'message'); expect(analysisErrors.first.offset, 16); expect(analysisErrors.first.length, 'print'.length); @@ -93,14 +93,14 @@ void main() { expect(analysisErrors, hasLength(1)); - expect(analysisErrors.first.errorCode.name, 'my_lint_code'); + expect(analysisErrors.first.diagnosticCode.name, 'my_lint_code'); expect(analysisErrors.first.message, 'message'); expect(analysisErrors.first.offset, 16); expect(analysisErrors.first.length, 'print'.length); }); group('LintRule.isEnabled', () { - test('defaults to checking "enabedByDefault"', () { + test('defaults to checking "enabledByDefault"', () { expect(onByDefault.isEnabled(CustomLintConfigs.empty), true); expect(offByDefault.isEnabled(CustomLintConfigs.empty), false); }); diff --git a/packages/custom_lint_core/test/type_checker_test.dart b/packages/custom_lint_core/test/type_checker_test.dart index cb78de21..821c1a2a 100644 --- a/packages/custom_lint_core/test/type_checker_test.dart +++ b/packages/custom_lint_core/test/type_checker_test.dart @@ -19,7 +19,7 @@ void main() { } '''); - final unit = await resolveFile2(path: file.path); + final unit = await resolveFile(path: file.path); unit as ResolvedUnitResult; const checker = TypeChecker.fromName('foo'); @@ -41,7 +41,7 @@ void fn((int, String) record) { } '''); - final unit = await resolveFile2(path: file.path); + final unit = await resolveFile(path: file.path); unit as ResolvedUnitResult; const checker = TypeChecker.fromName('record'); @@ -53,7 +53,7 @@ void fn((int, String) record) { }), ); - expect(propertyAccessNode.realTarget.staticType!.element3, isNull); + expect(propertyAccessNode.realTarget.staticType!.element, isNull); expect( checker.isExactlyType(propertyAccessNode.realTarget.staticType!), isFalse, @@ -88,7 +88,7 @@ environment: workingDirectory: tempDir.path, ); - final unit = await resolveFile2(path: file.path); + final unit = await resolveFile(path: file.path); unit as ResolvedUnitResult; const checker = TypeChecker.fromPackage('some_package'); @@ -132,7 +132,7 @@ int a; File? x; '''); - final unit = await resolveFile2(path: file.path); + final unit = await resolveFile(path: file.path); unit as ResolvedUnitResult; const checker = TypeChecker.fromPackage('dart:core'); diff --git a/packages/custom_lint_visitor/lib/src/node_lint_visitor.g.dart b/packages/custom_lint_visitor/lib/src/node_lint_visitor.g.dart index d1604cea..a36e252e 100644 --- a/packages/custom_lint_visitor/lib/src/node_lint_visitor.g.dart +++ b/packages/custom_lint_visitor/lib/src/node_lint_visitor.g.dart @@ -86,20 +86,6 @@ class LinterVisitor extends GeneralizingAstVisitor { super.visitAssignmentExpression(node); } - @deprecated - @override - void visitAugmentedExpression(AugmentedExpression node) { - _runSubscriptions(node, _registry._forAugmentedExpression); - super.visitAugmentedExpression(node); - } - - @deprecated - @override - void visitAugmentedInvocation(AugmentedInvocation node) { - _runSubscriptions(node, _registry._forAugmentedInvocation); - super.visitAugmentedInvocation(node); - } - @override void visitAwaitExpression(AwaitExpression node) { _runSubscriptions(node, _registry._forAwaitExpression); @@ -1355,24 +1341,6 @@ class NodeLintRegistry { .add(_Subscription(listener, _getTimer(key), Zone.current)); } - @deprecated - final List<_Subscription> _forAugmentedExpression = []; - @deprecated - void addAugmentedExpression( - String key, void Function(AugmentedExpression node) listener) { - _forAugmentedExpression - .add(_Subscription(listener, _getTimer(key), Zone.current)); - } - - @deprecated - final List<_Subscription> _forAugmentedInvocation = []; - @deprecated - void addAugmentedInvocation( - String key, void Function(AugmentedInvocation node) listener) { - _forAugmentedInvocation - .add(_Subscription(listener, _getTimer(key), Zone.current)); - } - final List<_Subscription> _forAwaitExpression = []; void addAwaitExpression( String key, void Function(AwaitExpression node) listener) { @@ -2744,20 +2712,6 @@ class LintRuleNodeRegistry { nodeLintRegistry.addAssignmentExpression(name, listener); } - @deprecated - @preferInline - void addAugmentedExpression( - void Function(AugmentedExpression node) listener) { - nodeLintRegistry.addAugmentedExpression(name, listener); - } - - @deprecated - @preferInline - void addAugmentedInvocation( - void Function(AugmentedInvocation node) listener) { - nodeLintRegistry.addAugmentedInvocation(name, listener); - } - @preferInline void addAwaitExpression(void Function(AwaitExpression node) listener) { nodeLintRegistry.addAwaitExpression(name, listener); diff --git a/packages/custom_lint_visitor/pubspec.yaml b/packages/custom_lint_visitor/pubspec.yaml index f0db96cf..29d9cc60 100644 --- a/packages/custom_lint_visitor/pubspec.yaml +++ b/packages/custom_lint_visitor/pubspec.yaml @@ -1,16 +1,17 @@ name: custom_lint_visitor -version: 1.0.0+7.7.0 +version: 1.0.0+8.1.0 description: A package that exports visitors for CustomLint. repository: https://github.com/invertase/dart_custom_lint environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.5.0 <4.0.0" + +resolution: workspace dependencies: - analyzer: ">=7.4.5 <7.7.0" + analyzer: ">=8.1.0 <8.2.0" dev_dependencies: build_runner: ^2.5.0 lint_visitor_generator: - path: ../lint_visitor_generator test: ^1.22.2 diff --git a/packages/custom_lint_visitor/pubspec_overrides.yaml b/packages/custom_lint_visitor/pubspec_overrides.yaml deleted file mode 100644 index 42255ad1..00000000 --- a/packages/custom_lint_visitor/pubspec_overrides.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# melos_managed_dependency_overrides: lint_visitor_generator -dependency_overrides: - lint_visitor_generator: - path: ../lint_visitor_generator diff --git a/packages/lint_visitor_generator/lib/builder.dart b/packages/lint_visitor_generator/lib/builder.dart index 44aa975a..3ba22c5a 100644 --- a/packages/lint_visitor_generator/lib/builder.dart +++ b/packages/lint_visitor_generator/lib/builder.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:build/build.dart'; import 'package:collection/collection.dart'; import 'package:source_gen/source_gen.dart'; @@ -13,25 +13,18 @@ Builder lintVisitorGenerator(BuilderOptions options) { ); } -extension on Element2 { - Annotatable? get asAnnotatable { - if (this is Annotatable) return this as Annotatable; - return null; - } -} - -extension on LibraryElement2 { - Element2? findElementWithNameFromPackage(String name) { - return library2.firstFragment.importedLibraries2 +extension on LibraryElement { + Element? findElementWithNameFromPackage(String name) { + return library.firstFragment.importedLibraries .map( (e) => e.exportNamespace.get2(name), ) .firstWhereOrNull((element) => element != null); } - ClassElement2? _findAstVisitor() { + ClassElement? _findAstVisitor() { return findElementWithNameFromPackage('GeneralizingAstVisitor') - as ClassElement2?; + as ClassElement?; } } @@ -49,7 +42,7 @@ class _LintVisitorGenerator extends Generator { return buffer.toString(); } - void _writeNodeLintRegistry(StringBuffer buffer, ClassElement2 visitor) { + void _writeNodeLintRegistry(StringBuffer buffer, ClassElement visitor) { buffer.writeln(''' /// A single subscription for a node type, by the specified "key" class _Subscription { @@ -80,13 +73,13 @@ class NodeLintRegistry { '''); for (final visitorMethod - in visitor.methods2.where((e) => e.name3!.startsWith('visit'))) { - if (visitorMethod.metadata2.hasDeprecated) continue; + in visitor.methods.where((e) => e.name!.startsWith('visit'))) { + if (visitorMethod.metadata.hasDeprecated) continue; const start = 'visit'.length; - if (visitorMethod.formalParameters.single.type.element3!.asAnnotatable! - .metadata2.hasDeprecated) { + if (visitorMethod + .formalParameters.single.type.element!.metadata.hasDeprecated) { buffer.write('@deprecated '); } @@ -97,14 +90,14 @@ class NodeLintRegistry { ..write(visitorMethod.formalParameters.single.type) ..write(' = [];'); - if (visitorMethod.formalParameters.single.type.element3!.asAnnotatable! - .metadata2.hasDeprecated) { + if (visitorMethod + .formalParameters.single.type.element!.metadata.hasDeprecated) { buffer.write('@deprecated '); } buffer ..write('void add') - ..write(visitorMethod.name3!.substring(start)) + ..write(visitorMethod.name!.substring(start)) ..write('(String key, void Function(') ..write(visitorMethod.formalParameters.single.type) ..write(' node) listener) {_for') @@ -117,7 +110,7 @@ class NodeLintRegistry { buffer.write('}'); } - void _writeLinterVisitor(StringBuffer buffer, ClassElement2 visitor) { + void _writeLinterVisitor(StringBuffer buffer, ClassElement visitor) { buffer.writeln(''' /// The AST visitor that runs handlers for nodes from the [_registry]. class LinterVisitor extends GeneralizingAstVisitor { @@ -146,30 +139,30 @@ class LinterVisitor extends GeneralizingAstVisitor { '''); - for (final visitorMethod in visitor.methods2) { - if (visitorMethod.metadata2.hasDeprecated) continue; + for (final visitorMethod in visitor.methods) { + if (visitorMethod.metadata.hasDeprecated) continue; - if (visitorMethod.formalParameters.single.type.element3!.asAnnotatable! - .metadata2.hasDeprecated) { + if (visitorMethod + .formalParameters.single.type.element!.metadata.hasDeprecated) { buffer.write('@deprecated '); } buffer ..write('@override void ') - ..write(visitorMethod.name3) + ..write(visitorMethod.name) ..write('(') ..write(visitorMethod.formalParameters.single.type) ..write(' node) {_runSubscriptions(node, _registry._for') ..write(visitorMethod.formalParameters.single.type) ..write('); super.') - ..write(visitorMethod.name3) + ..write(visitorMethod.name) ..write('(node);}'); } buffer.writeln('}'); } - void _writeLintRuleNodeRegistry(StringBuffer buffer, ClassElement2 visitor) { + void _writeLintRuleNodeRegistry(StringBuffer buffer, ClassElement visitor) { buffer.writeln(''' class LintRuleNodeRegistry { LintRuleNodeRegistry(this.nodeLintRegistry, this.name); @@ -180,23 +173,23 @@ class LintRuleNodeRegistry { '''); for (final visitorMethod - in visitor.methods2.where((e) => e.name3!.startsWith('visit'))) { - if (visitorMethod.metadata2.hasDeprecated) continue; + in visitor.methods.where((e) => e.name!.startsWith('visit'))) { + if (visitorMethod.metadata.hasDeprecated) continue; const start = 'visit'.length; - if (visitorMethod.formalParameters.single.type.element3!.asAnnotatable! - .metadata2.hasDeprecated) { + if (visitorMethod + .formalParameters.single.type.element!.metadata.hasDeprecated) { buffer.write('@deprecated '); } buffer ..write('@preferInline void add') - ..write(visitorMethod.name3!.substring(start)) + ..write(visitorMethod.name!.substring(start)) ..write('(void Function(') ..write(visitorMethod.formalParameters.single.type) ..write(' node) listener) {nodeLintRegistry.add') - ..write(visitorMethod.name3!.substring(start)) + ..write(visitorMethod.name!.substring(start)) ..write('(name, listener);}'); } diff --git a/packages/lint_visitor_generator/pubspec.yaml b/packages/lint_visitor_generator/pubspec.yaml index 4d203d66..e7e673f2 100644 --- a/packages/lint_visitor_generator/pubspec.yaml +++ b/packages/lint_visitor_generator/pubspec.yaml @@ -2,17 +2,19 @@ name: lint_visitor_generator publish_to: none environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.5.0 <4.0.0" + +resolution: workspace dependencies: - analyzer: ^7.5.0 - build: ^3.0.0 + analyzer: ^8.1.0 + build: ^4.0.0 build_config: ^1.1.0 collection: ^1.17.1 meta: ^1.7.0 - source_gen: ^3.0.0 + source_gen: ^4.0.0 dev_dependencies: build_runner: ^2.5.0 build_test: ^3.0.0 - source_gen_test: ^1.0.4 + source_gen_test: ^1.3.1 diff --git a/pubspec.yaml b/pubspec.yaml index d10df1bd..221beb78 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,6 +2,17 @@ name: melos_root publish_to: none environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ^3.5.0 + +workspace: + - packages/custom_lint + - packages/custom_lint/example + - packages/custom_lint/tools/analyzer_plugin + - packages/custom_lint_builder + - packages/custom_lint_builder/example + - packages/custom_lint_core + - packages/custom_lint_visitor + - packages/lint_visitor_generator + dev_dependencies: - melos: ^3.0.0 + melos: ^7.1.0 diff --git a/pubspec_overrides.yaml b/pubspec_overrides.yaml new file mode 100644 index 00000000..e85e605e --- /dev/null +++ b/pubspec_overrides.yaml @@ -0,0 +1,9 @@ +dependency_overrides: + freezed: + git: + url: https://github.com/lishaduck/freezed.git + ref: analyzer-8 + path: packages/freezed + # path: ../freezed/packages/freezed/ + + test_api: ^0.7.7 diff --git a/website/src/components/PluginCodeExample.astro b/website/src/components/PluginCodeExample.astro index 5f3dbb7a..9bfa9e98 100644 --- a/website/src/components/PluginCodeExample.astro +++ b/website/src/components/PluginCodeExample.astro @@ -49,7 +49,7 @@ class MyCustomLintCode extends DartLintRule { @override void run( CustomLintResolver resolver, - ErrorReporter reporter, + DiagnosticReporter reporter, CustomLintContext context, ) { context.registry.addVariableDeclaration((node) {