5399dbf6f6
- split the Dart CLI tool out of the VM into it's own embedder which runs in AOT mode. The pure Dart VM executable is called 'dartvm' and has no Dart CLI functionality in it - the Dart CLI executable parses the CLI commands and invokes the rest of the AOT tools in the same process, for the 'run' and 'test' commands it execs a process which runs 'dartvm' to run - 'dart hello.dart' execs the 'dartvm' process and runs 'hello.dart' - the Dart CLI is not generated for ia32 as we are not shipping a Dart SDK for ia32 anymore (support to execute the 'dartvm' for ia32 architecture is retained) - the Dart CLI tool is not built in the internal Dart SDK builds TEST=ci Some performance improvement numbers 'dart format pkg/dartdev' goes from 1.17 secs to 0.22 secs 'dart doc pkg/dartdev' goes from 100.2 secs to 66.6 secs 'dart fix pkg/dartdev' goes from 19.3 secs to 14.5 secs Change-Id: I66984a26cb2ab014b34dc1873f1f3d2884e13518 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364202 Commit-Queue: Ben Konyi <bkonyi@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com>
91 lines
2.9 KiB
Dart
91 lines
2.9 KiB
Dart
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
|
|
// 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 'dart:async';
|
|
|
|
import 'package:analysis_server/src/server/driver.dart' as server;
|
|
import 'package:args/args.dart';
|
|
|
|
import '../core.dart';
|
|
import '../sdk.dart';
|
|
import '../utils.dart';
|
|
import '../vm_interop_handler.dart';
|
|
|
|
class LanguageServerCommand extends DartdevCommand {
|
|
static const String commandName = 'language-server';
|
|
|
|
@override
|
|
CommandCategory get commandCategory => CommandCategory.tools;
|
|
|
|
static const String commandDescription = '''
|
|
Start Dart's analysis server.
|
|
|
|
This is a long-running process used to provide language services to IDEs and other tooling clients.
|
|
|
|
It communicates over stdin and stdout and provides services like code completion, errors and warnings, and refactorings. This command is generally not user-facing but consumed by higher level tools.
|
|
|
|
For more information about the server's capabilities and configuration, see:
|
|
|
|
https://github.com/dart-lang/sdk/tree/main/pkg/analysis_server''';
|
|
|
|
LanguageServerCommand({bool verbose = false})
|
|
: super(commandName, commandDescription, verbose, hidden: !verbose);
|
|
|
|
@override
|
|
ArgParser createArgParser() {
|
|
return server.Driver.createArgParser(
|
|
usageLineLength: dartdevUsageLineLength,
|
|
includeHelpFlag: false,
|
|
defaultToLsp: true,
|
|
)..addFlag(useAotSnapshotFlag,
|
|
help: 'Use the AOT analysis server snapshot',
|
|
defaultsTo: true,
|
|
hide: true);
|
|
}
|
|
|
|
@override
|
|
Future<int> run() async {
|
|
const protocol = server.Driver.SERVER_PROTOCOL;
|
|
const lsp = server.Driver.PROTOCOL_LSP;
|
|
|
|
var args = argResults!.arguments;
|
|
if (!args.any((arg) => arg.startsWith('--$protocol'))) {
|
|
args = [...args, '--$protocol=$lsp'];
|
|
}
|
|
try {
|
|
var script = sdk.analysisServerAotSnapshot;
|
|
var useExec = false;
|
|
if (argResults!.flag(useAotSnapshotFlag)) {
|
|
if (!Sdk.checkArtifactExists(sdk.analysisServerAotSnapshot)) {
|
|
log.stderr('Error: launching language analysis server failed');
|
|
log.stderr('${sdk.analysisServerAotSnapshot} not found');
|
|
return _genericErrorExitCode;
|
|
}
|
|
args = [...args];
|
|
args.remove('--$useAotSnapshotFlag');
|
|
} else {
|
|
args = [...args];
|
|
args.remove('--no-$useAotSnapshotFlag');
|
|
script = sdk.analysisServerSnapshot;
|
|
useExec = true;
|
|
}
|
|
VmInteropHandler.run(
|
|
script,
|
|
args,
|
|
useExecProcess: useExec,
|
|
);
|
|
return 0;
|
|
} catch (e, st) {
|
|
log.stderr('Error: launching language analysis server failed');
|
|
log.stderr(e.toString());
|
|
if (verbose) {
|
|
log.stderr(st.toString());
|
|
}
|
|
return _genericErrorExitCode;
|
|
}
|
|
}
|
|
|
|
static const _genericErrorExitCode = 255;
|
|
}
|