Skip to content

Commit 68b5f64

Browse files
keertipCommit Queue
authored andcommitted
[analytics] Split the other workspace types into Blaze, Gn and other
Change-Id: Ibf46f2dec665e2cbee88ee961d6a4b46b6617c6d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459541 Commit-Queue: Keerti Parthasarathy <keertip@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
1 parent 293c4b9 commit 68b5f64

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

pkg/analysis_server/lib/src/analysis_server.dart

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ import 'package:analyzer/src/generated/sdk.dart';
8282
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
8383
import 'package:analyzer/src/util/performance/operation_performance.dart';
8484
import 'package:analyzer/src/utilities/extensions/analysis_session.dart';
85+
import 'package:analyzer/src/workspace/basic.dart';
86+
import 'package:analyzer/src/workspace/blaze.dart';
87+
import 'package:analyzer/src/workspace/gn.dart';
8588
import 'package:analyzer/src/workspace/pub.dart';
8689
import 'package:analyzer_plugin/protocol/protocol.dart';
8790
import 'package:analyzer_plugin/src/protocol/protocol_internal.dart'
@@ -951,7 +954,7 @@ abstract class AnalysisServer {
951954
var transitiveFilePaths = <String>{};
952955
var transitiveFileUniqueLineCount = 0;
953956
var libraryCycles = <LibraryCycle>{};
954-
var workspaceTypes = <int>[0, 0, 0];
957+
var workspaceTypes = List<int>.filled(5, 0);
955958
var numberOfPackages = <int>[];
956959
var driverMap = contextManager.driverMap;
957960
for (var entry in driverMap.entries) {
@@ -962,17 +965,21 @@ abstract class AnalysisServer {
962965
var contextRoot = analysisContext.contextRoot;
963966
packagesFileMap[rootPath] = contextRoot.packagesFile;
964967
var workspace = contextRoot.workspace;
965-
if (workspace is PackageConfigWorkspace) {
966-
if (workspace.isPubWorkspace) {
967-
// Pub workspace index = 2, Package workspace index = 1
968-
workspaceTypes[2]++;
969-
numberOfPackages.add(workspace.allPackages.length);
970-
} else {
971-
workspaceTypes[1]++;
972-
}
973-
} else {
974-
// Blaze, GN or other workspace index = 0
975-
workspaceTypes[0]++;
968+
switch (workspace) {
969+
case PackageConfigWorkspace():
970+
if (workspace.isPubWorkspace) {
971+
// Pub workspace index = 2, Package workspace index = 1
972+
workspaceTypes[2]++;
973+
numberOfPackages.add(workspace.allPackages.length);
974+
} else {
975+
workspaceTypes[1]++;
976+
}
977+
case BlazeWorkspace():
978+
workspaceTypes[3]++;
979+
case GnWorkspace():
980+
workspaceTypes[4]++;
981+
case BasicWorkspace():
982+
workspaceTypes[0]++;
976983
}
977984
}
978985
var fileSystemState = driver.fsState;

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ class ContextStructure {
4848
final int transitiveFileUniqueLineCount;
4949

5050
/// The type of the workspaces in all of the contexts. A list of 3 elements,
51-
/// index 0 - number of Blaze/GN/Basic workspace
51+
/// index 0 - number of Basic workspaces
5252
/// index 1 - number of workspaces with one package
5353
/// index 2 - number of Pub workspaces
54+
/// index 3 - number of Blaze workspaces
55+
/// index 4 - number of GN workspaces
5456
final List<int> contextWorkspaceType;
5557

5658
/// The number of packages in the workspace. This value is calculated only
@@ -71,8 +73,8 @@ class ContextStructure {
7173
required this.transitiveFileUniqueLineCount,
7274
required List<int> libraryCycleLibraryCounts,
7375
required List<int> libraryCycleLineCounts,
74-
this.contextWorkspaceType = const <int>[0, 0, 0],
75-
List<int> numberOfPackagesInWorkspace = const <int>[],
76+
required this.contextWorkspaceType,
77+
required List<int> numberOfPackagesInWorkspace,
7678
}) : libraryCycleLibraryCounts = PercentileCalculator.from(
7779
libraryCycleLibraryCounts,
7880
),

0 commit comments

Comments
 (0)