Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit afc908f

Browse files
author
Dart CI
committed
Version 2.18.0-158.0.dev
Merge commit '1e7bc687a7931c7bd837147b6fef60b9cf4fa42c' into 'dev'
2 parents f350404 + 1e7bc68 commit afc908f

35 files changed

+242
-388
lines changed

DEPS

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ vars = {
9090
"cli_util_rev": "b0adbba89442b2ea6fef39c7a82fe79cb31e1168",
9191
"clock_rev": "f594d86da123015186d5680b0d0e8255c52fc162",
9292
"collection_rev": "e1407da23b9f17400b3a905aafe2b8fa10db3d86",
93-
"convert_rev": "e063fdca4bebffecbb5e6aa5525995120982d9ce",
93+
"convert_rev": "00b251529c074df394b3391c7e3eea3dd9e5778e",
9494
"crypto_rev": "4297d240b0e1e780ec0a9eab23eaf1ad491f3e68",
9595
"csslib_rev": "518761b166974537f334dbf264e7f56cb157a96a",
9696

pkg/analysis_server/lib/src/analysis_server_abstract.dart

+5
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,11 @@ abstract class AbstractAnalysisServer {
534534

535535
@mustCallSuper
536536
void shutdown() {
537+
// For now we record plugins only on shutdown. We might want to record them
538+
// every time the set of plugins changes, in which case we'll need to listen
539+
// to the `PluginManager.pluginsChanged` stream.
540+
analyticsManager.changedPlugins(pluginManager);
541+
537542
pubPackageService.shutdown();
538543
analyticsManager.shutdown();
539544
}

pkg/analysis_server/lib/src/analytics/analytics_manager.dart

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'package:analysis_server/lsp_protocol/protocol.dart';
66
import 'package:analysis_server/protocol/protocol.dart';
77
import 'package:analysis_server/src/analytics/google_analytics_manager.dart';
8+
import 'package:analysis_server/src/plugin/plugin_manager.dart';
89
import 'package:telemetry/telemetry.dart';
910

1011
/// An interface for managing and reporting analytics.
@@ -19,6 +20,9 @@ abstract class AnalyticsManager {
1920
factory AnalyticsManager.forAnalytics(Analytics analytics) =
2021
GoogleAnalyticsManager;
2122

23+
/// Record that the set of plugins known to the [pluginManager] has changed.
24+
void changedPlugins(PluginManager pluginManager);
25+
2226
/// Record that the given [response] was sent to the client.
2327
void sentResponse({required Response response});
2428

pkg/analysis_server/lib/src/analytics/google_analytics_manager.dart

+53-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'dart:convert';
6+
57
import 'package:analysis_server/lsp_protocol/protocol.dart';
68
import 'package:analysis_server/protocol/protocol.dart';
79
import 'package:analysis_server/src/analytics/analytics_manager.dart';
810
import 'package:analysis_server/src/analytics/percentile_calculator.dart';
11+
import 'package:analysis_server/src/plugin/plugin_manager.dart';
912
import 'package:telemetry/telemetry.dart';
1013

1114
/// An implementation of [AnalyticsManager] that's appropriate to use when
@@ -18,6 +21,8 @@ class GoogleAnalyticsManager implements AnalyticsManager {
1821
/// been invoked.
1922
_SessionData? _sessionData;
2023

24+
final _PluginData _pluginData = _PluginData();
25+
2126
/// A map from the id of a request to data about the request.
2227
final Map<String, _ActiveRequestData> _activeRequests = {};
2328

@@ -29,6 +34,11 @@ class GoogleAnalyticsManager implements AnalyticsManager {
2934
/// service.
3035
GoogleAnalyticsManager(this.analytics);
3136

37+
@override
38+
void changedPlugins(PluginManager pluginManager) {
39+
_pluginData.recordPlugins(pluginManager);
40+
}
41+
3242
@override
3343
void sentResponse({required Response response}) {
3444
var sendTime = DateTime.now();
@@ -59,10 +69,7 @@ class GoogleAnalyticsManager implements AnalyticsManager {
5969
'clientId': sessionData.clientId,
6070
'sdkVersion': sessionData.sdkVersion,
6171
'duration': duration.toString(),
62-
// TODO(brianwilkerson) Report a list of the names of the plugins that
63-
// were loaded, or possibly a map from plugin names to the number of
64-
// analysis roots in which the plugins were loaded.
65-
'plugins': '',
72+
'plugins': _pluginData.usageCountData,
6673
});
6774
// Send response data.
6875
for (var data in _completedRequests.values) {
@@ -148,6 +155,48 @@ class _ActiveRequestData {
148155
_ActiveRequestData(this.requestName, this.clientRequestTime, this.startTime);
149156
}
150157

158+
/// Data about the plugins associated with the context roots.
159+
class _PluginData {
160+
/// The number of times that plugin information has been recorded.
161+
int recordCount = 0;
162+
163+
/// A table mapping the ids of running plugins to the number of context roots
164+
/// associated with each of the plugins.
165+
Map<String, PercentileCalculator> usageCounts = {};
166+
167+
/// Initialize a newly created holder of plugin data.
168+
_PluginData();
169+
170+
String get usageCountData {
171+
return json.encode({
172+
'recordCount': recordCount,
173+
'rootCounts': _encodeUsageCounts(),
174+
});
175+
}
176+
177+
/// Use the [pluginManager] to record data about the plugins that are
178+
/// currently running.
179+
void recordPlugins(PluginManager pluginManager) {
180+
recordCount++;
181+
var plugins = pluginManager.plugins;
182+
for (var i = 0; i < plugins.length; i++) {
183+
var info = plugins[i];
184+
usageCounts
185+
.putIfAbsent(info.pluginId, () => PercentileCalculator())
186+
.addValue(info.contextRoots.length);
187+
}
188+
}
189+
190+
/// Return an encoding of the [usageCounts].
191+
Map<String, String> _encodeUsageCounts() {
192+
var encoded = <String, String>{};
193+
for (var entry in usageCounts.entries) {
194+
encoded[entry.key] = entry.value.toAnalyticsString();
195+
}
196+
return encoded;
197+
}
198+
}
199+
151200
/// Data about the requests that have been responded to that have the same name.
152201
class _RequestData {
153202
/// The name of the requests.

pkg/analysis_server/lib/src/analytics/noop_analytics_manager.dart

+4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
import 'package:analysis_server/lsp_protocol/protocol.dart';
66
import 'package:analysis_server/protocol/protocol.dart';
77
import 'package:analysis_server/src/analytics/analytics_manager.dart';
8+
import 'package:analysis_server/src/plugin/plugin_manager.dart';
89

910
/// An implementation of [AnalyticsManager] that's appropriate to use when
1011
/// analytics have not been enabled.
1112
class NoopAnalyticsManager implements AnalyticsManager {
13+
@override
14+
void changedPlugins(PluginManager pluginManager) {}
15+
1216
@override
1317
void sentResponse({required Response response}) {}
1418

pkg/analysis_server_client/README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# analysis_server_client
1+
[![pub package](https://img.shields.io/pub/v/analysis_server_client.svg)](https://pub.dev/packages/analysis_server_client)
2+
[![package publisher](https://img.shields.io/pub/publisher/analysis_server_client.svg)](https://pub.dev/packages/analysis_server_client/publisher)
23

3-
analysis_server_client is a client wrapper over Analysis Server.
4+
`package:analysis_server_client` is a client wrapper over the Analysis Server.
45

56
## Overview
67

pkg/analyzer/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Analyzer for Dart
1+
[![pub package](https://img.shields.io/pub/v/analyzer.svg)](https://pub.dev/packages/analyzer)
2+
[![package publisher](https://img.shields.io/pub/publisher/analyzer.svg)](https://pub.dev/packages/analyzer/publisher)
23

34
This package provides a library that performs static analysis
45
of Dart code. It is useful for tool integration and embedding.

pkg/analyzer/lib/src/dart/error/ffi_code.g.dart

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class FfiCode extends AnalyzerErrorCode {
1919
correctionMessage:
2020
"Try removing all type parameters, removing all members, and adding "
2121
"one const constructor.",
22+
hasPublishedDocs: true,
2223
);
2324

2425
/// No parameters.
@@ -28,6 +29,7 @@ class FfiCode extends AnalyzerErrorCode {
2829
"'AbiSpecificIntegerMapping' annotation specifying the mapping from "
2930
"ABI to a 'NativeType' integer with a fixed size.",
3031
correctionMessage: "Try removing the extra annotation.",
32+
hasPublishedDocs: true,
3133
);
3234

3335
/// No parameters.
@@ -37,6 +39,7 @@ class FfiCode extends AnalyzerErrorCode {
3739
"'AbiSpecificIntegerMapping' annotation specifying the mapping from "
3840
"ABI to a 'NativeType' integer with a fixed size.",
3941
correctionMessage: "Try adding an annotation.",
42+
hasPublishedDocs: true,
4043
);
4144

4245
/// No parameters.
@@ -47,6 +50,7 @@ class FfiCode extends AnalyzerErrorCode {
4750
correctionMessage:
4851
"Try changing the value to 'Int8', 'Int16', 'Int32', 'Int64', 'Uint8', "
4952
"'Uint16', 'UInt32', or 'Uint64'.",
53+
hasPublishedDocs: true,
5054
);
5155

5256
/// No parameters.

pkg/analyzer/lib/src/dart/error/hint_codes.g.dart

+6
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ class HintCode extends AnalyzerErrorCode {
187187
"The operator x ~/ y is more efficient than (x / y).toInt().",
188188
correctionMessage:
189189
"Try re-writing the expression to use the '~/' operator.",
190+
hasPublishedDocs: true,
190191
);
191192

192193
/// No parameters.
@@ -543,6 +544,7 @@ class HintCode extends AnalyzerErrorCode {
543544
"The annotation '@nonVirtual' can only be applied to a concrete instance "
544545
"member.",
545546
correctionMessage: "Try removing '@nonVirtual'.",
547+
hasPublishedDocs: true,
546548
);
547549

548550
/// This hint is generated anywhere where an instance member annotated with
@@ -555,6 +557,7 @@ class HintCode extends AnalyzerErrorCode {
555557
'INVALID_OVERRIDE_OF_NON_VIRTUAL_MEMBER',
556558
"The member '{0}' is declared non-virtual in '{1}' and can't be overridden "
557559
"in subclasses.",
560+
hasPublishedDocs: true,
558561
);
559562

560563
/// This hint is generated anywhere where `@required` annotates a named
@@ -601,6 +604,7 @@ class HintCode extends AnalyzerErrorCode {
601604
'INVALID_SEALED_ANNOTATION',
602605
"The annotation '@sealed' can only be applied to classes.",
603606
correctionMessage: "Try removing the '@sealed' annotation.",
607+
hasPublishedDocs: true,
604608
);
605609

606610
/// Parameters:
@@ -651,6 +655,7 @@ class HintCode extends AnalyzerErrorCode {
651655
static const HintCode INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER = HintCode(
652656
'INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER',
653657
"The member '{0}' can only be used within '{1}' or a test.",
658+
hasPublishedDocs: true,
654659
);
655660

656661
/// This hint is generated anywhere where a private declaration is annotated
@@ -1177,6 +1182,7 @@ class HintCode extends AnalyzerErrorCode {
11771182
"The keyword 'final' isn't necessary because the parameter is implicitly "
11781183
"'final'.",
11791184
correctionMessage: "Try removing the 'final'.",
1185+
hasPublishedDocs: true,
11801186
);
11811187

11821188
/// Parameters:

pkg/analyzer/lib/src/error/codes.g.dart

+1
Original file line numberDiff line numberDiff line change
@@ -2762,6 +2762,7 @@ class CompileTimeErrorCode extends AnalyzerErrorCode {
27622762
'MIXIN_SUPER_CLASS_CONSTRAINT_DEFERRED_CLASS',
27632763
"Deferred classes can't be used as superclass constraints.",
27642764
correctionMessage: "Try changing the import to not be deferred.",
2765+
hasPublishedDocs: true,
27652766
);
27662767

27672768
/// Parameters:

0 commit comments

Comments
 (0)