Skip to content

Commit

Permalink
Version 2.14.0-371.0.dev
Browse files Browse the repository at this point in the history
Merge commit '58969783ba6b20b68c42da32a91a77e5862bbafb' into 'dev'
  • Loading branch information
Dart CI committed Jul 31, 2021
2 parents 406d207 + 5896978 commit 2cddb14
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
8 changes: 8 additions & 0 deletions pkg/dartdev/lib/src/analysis_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,31 @@ import 'dart:io';
import 'package:analysis_server/src/server/driver.dart' show Driver;
import 'package:analysis_server_client/protocol.dart'
show EditBulkFixesResult, ResponseDecoder;
import 'package:args/args.dart';
import 'package:meta/meta.dart';
import 'package:path/path.dart' as path;

import 'core.dart';
import 'sdk.dart';
import 'utils.dart';

/// When set, this function is executed just before the Analysis Server starts.
void Function(String cmdName, List<FileSystemEntity> analysisRoots,
ArgResults argResults) preAnalysisServerStart;

/// A class to provide an API wrapper around an analysis server process.
class AnalysisServer {
AnalysisServer(
this.sdkPath,
this.analysisRoots, {
@required this.commandName,
@required this.argResults,
});

final Directory sdkPath;
final List<FileSystemEntity> analysisRoots;
final String commandName;
final ArgResults argResults;

Process _process;

Expand Down Expand Up @@ -69,6 +76,7 @@ class AnalysisServer {
final Map<String, Completer<Map<String, dynamic>>> _requestCompleters = {};

Future<void> start() async {
preAnalysisServerStart?.call(commandName, analysisRoots, argResults);
final List<String> command = <String>[
sdk.analysisServerSnapshot,
'--${Driver.SUPPRESS_ANALYTICS_FLAG}',
Expand Down
1 change: 1 addition & 0 deletions pkg/dartdev/lib/src/commands/analyze.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class AnalyzeCommand extends DartdevCommand {
io.Directory(sdk.sdkPath),
targets,
commandName: 'analyze',
argResults: argResults,
);

server.onErrors.listen((FileAnalysisErrors fileErrors) {
Expand Down
1 change: 1 addition & 0 deletions pkg/dartdev/lib/src/commands/fix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ To use the tool, run either ['dart fix --dry-run'] for a preview of the proposed
io.Directory(sdk.sdkPath),
[dir],
commandName: 'fix',
argResults: argResults,
);

await server.start();
Expand Down
8 changes: 7 additions & 1 deletion pkg/dartdev/lib/src/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import 'utils.dart';
Logger log;
bool isDiagnostics = false;

/// When set, this function is executed from the [DartdevCommand] constructor to
/// contribute additional flags.
void Function(ArgParser argParser, String cmdName) flagContributor;

abstract class DartdevCommand extends Command<int> {
final String _name;
final String _description;
Expand All @@ -29,7 +33,9 @@ abstract class DartdevCommand extends Command<int> {
final bool hidden;

DartdevCommand(this._name, this._description, this._verbose,
{this.hidden = false});
{this.hidden = false}) {
flagContributor?.call(argParser, _name);
}

@override
String get name => _name;
Expand Down
4 changes: 2 additions & 2 deletions pkg/dartdev/test/analysis_server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ void main() {

test('can start', () async {
AnalysisServer server = AnalysisServer(io.Directory(sdk.sdkPath), [p.dir],
commandName: 'testing');
commandName: 'testing', argResults: null);
await server.start();
await server.shutdown();
});

test('can send message', () async {
AnalysisServer server = AnalysisServer(io.Directory(sdk.sdkPath), [p.dir],
commandName: 'testing');
commandName: 'testing', argResults: null);
await server.start();

final response = await server.getVersion();
Expand Down
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ CHANNEL dev
MAJOR 2
MINOR 14
PATCH 0
PRERELEASE 370
PRERELEASE 371
PRERELEASE_PATCH 0

0 comments on commit 2cddb14

Please sign in to comment.