Skip to content

Commit

Permalink
[dartdev] switch the analysis server to use VMInteropHandler instead of
Browse files Browse the repository at this point in the history
spawning an isolate (higher memory footprint)

Change-Id: I74bcb382c6269183beb4b8f2fcd04aee10eaa549
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/404921
Reviewed-by: Derek Xu <[email protected]>
Commit-Queue: Siva Annamalai <[email protected]>
  • Loading branch information
a-siva authored and Commit Queue committed Jan 17, 2025
1 parent 4dba853 commit da6dc03
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions pkg/dartdev/lib/src/commands/language_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ 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';
Expand Down Expand Up @@ -45,16 +46,22 @@ For more information about the server's capabilities and configuration, see:
var args = argResults!.arguments;
if (!args.any((arg) => arg.startsWith('--$protocol'))) {
args = [...args, '--$protocol=$lsp'];
} else {
// Need to make a copy as argResults!.arguments is an
// UnmodifiableListView object which cannot be passed as
// the args for spawnUri.
args = [...args];
}
return await runFromSnapshot(
snapshot: sdk.analysisServerSnapshot,
args: args,
verbose: verbose,
);
try {
VmInteropHandler.run(
sdk.analysisServerSnapshot,
args,
packageConfigOverride: null,
useExecProcess : false,
);
return 0;
} catch (e, st) {
log.stderr('Error: launching language analysis server failed');
log.stderr(e.toString());
if (verbose) {
log.stderr(st.toString());
}
return 255;
}
}
}

0 comments on commit da6dc03

Please sign in to comment.