| Index: pkg/analysis_server/lib/src/server/driver.dart
|
| diff --git a/pkg/analysis_server/lib/src/server/driver.dart b/pkg/analysis_server/lib/src/server/driver.dart
|
| index 502b5d6d040f677f376050dc8bdb670d3788b238..dc275175addebdd88281eff42936c4efbf782a65 100644
|
| --- a/pkg/analysis_server/lib/src/server/driver.dart
|
| +++ b/pkg/analysis_server/lib/src/server/driver.dart
|
| @@ -6,15 +6,18 @@ library driver;
|
|
|
| import 'dart:async';
|
| import 'dart:io';
|
| +import 'dart:math';
|
|
|
| import 'package:analysis_server/plugin/plugin.dart';
|
| import 'package:analysis_server/src/analysis_server.dart';
|
| +import 'package:analysis_server/src/constants.dart';
|
| import 'package:analysis_server/src/plugin/plugin_impl.dart';
|
| import 'package:analysis_server/src/plugin/server_plugin.dart';
|
| import 'package:analysis_server/src/server/http_server.dart';
|
| import 'package:analysis_server/src/server/stdio_server.dart';
|
| import 'package:analysis_server/src/socket_server.dart';
|
| import 'package:analysis_server/starter.dart';
|
| +import 'package:analyzer/file_system/physical_file_system.dart';
|
| import 'package:analyzer/instrumentation/instrumentation.dart';
|
| import 'package:analyzer/src/generated/engine.dart';
|
| import 'package:analyzer/src/generated/incremental_logger.dart';
|
| @@ -23,7 +26,6 @@ import 'package:analyzer/src/generated/sdk.dart';
|
| import 'package:analyzer/src/generated/sdk_io.dart';
|
| import 'package:args/args.dart';
|
|
|
| -
|
| /**
|
| * Initializes incremental logger.
|
| *
|
| @@ -67,6 +69,11 @@ class Driver implements ServerStarter {
|
| static const String CLIENT_ID = "client-id";
|
|
|
| /**
|
| + * The name of the option used to set the version for the client.
|
| + */
|
| + static const String CLIENT_VERSION = "client-version";
|
| +
|
| + /**
|
| * The name of the option used to enable incremental resolution of API
|
| * changes.
|
| */
|
| @@ -208,7 +215,12 @@ class Driver implements ServerStarter {
|
|
|
| InstrumentationService service =
|
| new InstrumentationService(instrumentationServer);
|
| -// service.logVersion(results[CLIENT_ID], defaultSdk.sdkVersion);
|
| + service.logVersion(
|
| + _readUuid(service),
|
| + results[CLIENT_ID],
|
| + results[CLIENT_VERSION],
|
| + AnalysisServer.VERSION,
|
| + defaultSdk.sdkVersion);
|
| AnalysisEngine.instance.instrumentationService = service;
|
| //
|
| // Process all of the plugins so that extensions are registered.
|
| @@ -278,6 +290,7 @@ class Driver implements ServerStarter {
|
| parser.addOption(
|
| CLIENT_ID,
|
| help: "an identifier used to identify the client");
|
| + parser.addOption(CLIENT_VERSION, help: "the version of the client");
|
| parser.addFlag(
|
| ENABLE_INCREMENTAL_RESOLUTION_API,
|
| help: "enable using incremental resolution for API changes",
|
| @@ -312,8 +325,7 @@ class Driver implements ServerStarter {
|
| parser.addOption(SDK_OPTION, help: "[path] the path to the sdk");
|
| parser.addFlag(
|
| NO_ERROR_NOTIFICATION,
|
| - help:
|
| - "disable sending all analysis error notifications to the server",
|
| + help: "disable sending all analysis error notifications to the server",
|
| defaultsTo: false,
|
| negatable: false);
|
|
|
| @@ -329,4 +341,35 @@ class Driver implements ServerStarter {
|
| print('Supported flags are:');
|
| print(parser.usage);
|
| }
|
| +
|
| + /**
|
| + * Read the UUID from disk, generating and storing a new one if necessary.
|
| + */
|
| + String _readUuid(InstrumentationService service) {
|
| + File uuidFile = new File(
|
| + PhysicalResourceProvider.INSTANCE.getStateLocation(
|
| + '.instrumentation').getChild('uuid.txt').path);
|
| + try {
|
| + if (uuidFile.existsSync()) {
|
| + String uuid = uuidFile.readAsStringSync();
|
| + if (uuid != null && uuid.length > 5) {
|
| + return uuid;
|
| + }
|
| + }
|
| + } catch (exception, stackTrace) {
|
| + service.logPriorityException(exception, stackTrace);
|
| + }
|
| + int millisecondsSinceEpoch = new DateTime.now().millisecondsSinceEpoch;
|
| + int random = new Random().nextInt(0x3fffffff);
|
| + String uuid = '$millisecondsSinceEpoch$random';
|
| + try {
|
| + uuidFile.parent.createSync(recursive: true);
|
| + uuidFile.writeAsStringSync(uuid);
|
| + } catch (exception, stackTrace) {
|
| + service.logPriorityException(exception, stackTrace);
|
| + // Slightly alter the uuid to indicate it was not persisted
|
| + uuid = 'temp-$uuid';
|
| + }
|
| + return uuid;
|
| + }
|
| }
|
|
|