From 4a7dd72bcf4a8d60da3732f49787379d875af32a Mon Sep 17 00:00:00 2001 From: pq Date: Thu, 18 Jan 2024 00:40:29 +0000 Subject: [PATCH] stop accessing `driver.analysisOptions` Change-Id: Ieb9d2581691b82f59b2a5540aaae2c3e453c078c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346944 Reviewed-by: Brian Wilkerson Commit-Queue: Phil Quitslund --- .../lib/src/status/diagnostics.dart | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/pkg/analysis_server/lib/src/status/diagnostics.dart b/pkg/analysis_server/lib/src/status/diagnostics.dart index a91f962d3713..9efd4b5e2884 100644 --- a/pkg/analysis_server/lib/src/status/diagnostics.dart +++ b/pkg/analysis_server/lib/src/status/diagnostics.dart @@ -160,6 +160,17 @@ String writeOption(String name, dynamic value) { return '$name: $value
'; } +_CollectedOptionsData _collectOptionsData(AnalysisDriver driver) { + var collectedData = _CollectedOptionsData(); + if (driver.analysisContext?.allAnalysisOptions case var allAnalysisOptions?) { + for (var analysisOptions in allAnalysisOptions) { + collectedData.lints.addAll(analysisOptions.lintRules.map((e) => e.name)); + collectedData.plugins.addAll(analysisOptions.enabledPluginNames); + } + } + return collectedData; +} + class AnalyticsPage extends DiagnosticPageWithNav { AnalyticsPage(DiagnosticsSite site) : super(site, 'analytics', 'Analytics', @@ -468,19 +479,6 @@ class CollectReportPage extends DiagnosticPage { const JsonEncoder encoder = JsonEncoder.withIndent(' '); return encoder.convert(collectedData); } - - _CollectedOptionsData _collectOptionsData(AnalysisDriver driver) { - var collectedData = _CollectedOptionsData(); - if (driver.analysisContext?.allAnalysisOptions - case var allAnalysisOptions?) { - for (var analysisOptions in allAnalysisOptions) { - collectedData.lints - .addAll(analysisOptions.lintRules.map((e) => e.name)); - collectedData.plugins.addAll(analysisOptions.enabledPluginNames); - } - } - return collectedData; - } } class CommunicationsPage extends DiagnosticPageWithNav { @@ -761,9 +759,8 @@ class ContextsPage extends DiagnosticPageWithNav { buf.writeln(''); h3('Plugins'); - // TODO(pq): migrate to *all* analysis options - // ignore: deprecated_member_use - p(driver.analysisOptions.enabledPluginNames.join(', ')); + var optionsData = _collectOptionsData(driver); + p(optionsData.plugins.toList().join(', ')); var priorityFiles = driver.priorityFiles; var addedFiles = driver.addedFiles.toList();