Skip to content

About

A transparent LSP proxy for a Dart analysis server snapshot.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

dart_analysis_server_proxy

GitHub stars GitHub forks GitHub license GitHub issues FlutterCandies QQ 群

English | 简体中文

Transparent LSP proxy for replacing the Dart SDK analysis server snapshot.

This is the first implementation layer of the replacement design. It starts an upstream analysis server snapshot, preserves LSP Content-Length framing, and forwards IDE traffic unchanged. It observes diagnostics and status notifications and exposes an authenticated dana bridge after the IDE sends initialize. status and fullCheck are currently supported; fullCheck triggers dart/reanalyze, waits for analyzer idle notifications, and returns the diagnostics cache.

Example:

dart run bin/dana_analysis_server_proxy.dart `
  --upstream D:\sdk\bin\snapshots\analysis_server_upstream.dart.snapshot `
  -- --protocol=lsp

Proxy options before -- are parsed by the args package. Everything after -- is forwarded unchanged to the upstream analyzer. When the installed SDK snapshot is launched by Dart-Code, no separator is needed: all original analyzer arguments are forwarded and the sibling upstream snapshot is selected automatically. For example, --protocol=lsp is not parsed by the proxy.

The installed SDK wrapper will pass the original analyzer arguments after the proxy's own options. The upstream snapshot must come from the same Dart SDK revision and runtime.

Install or restore snapshots explicitly:

dart run bin/install.dart --sdk D:\Flutter\SDK\3.44.1\bin\cache\dart-sdk
dart run bin/install.dart --sdk D:\Flutter\SDK\3.44.1\bin\cache\dart-sdk --restore
dart run bin/install.dart --sdk D:\Flutter\SDK\3.44.1\bin\cache\dart-sdk --status

Installation keeps the original JIT and AOT snapshots beside the proxy and writes an installation marker. It is intended for an SDK copy or test SDK; the current user's SDK is not modified by this project unless install.dart is explicitly run. The installed JIT proxy selects the upstream JIT snapshot; the installed AOT proxy selects the upstream AOT snapshot. Snapshot compilation always uses the target SDK's bin/dart, so incompatible SDK/package versions fail during installation instead of producing a cross-version snapshot. The target must be a complete Dart SDK installation, not only copied analyzer snapshots; its compiler runtime and platform artifacts are required by dart compile.

If the proxy is compiled as a standalone AOT executable, set DANA_DART_EXECUTABLE (or DART_SDK) so it can launch the upstream snapshot. Installed SDK snapshots launched by the SDK's dart runtime need no extra setting. Full-check and upstream request waits default to 30 minutes for large projects; set DANA_ANALYSIS_TIMEOUT_SECONDS=0 to remove the wall-clock limit.

The current implementation has been smoke-tested against an isolated copy of a complete Dart SDK for both JIT and AOT snapshots: snapshot installation, LSP initialization, endpoint publication, dana check --mode full --reuse-ide require, and a subsequent disk edit plus dana check --mode fast --reuse-ide require --files <file> all complete successfully. The smoke also verifies root selection and invalid-token rejection. Snapshot restore and post-restore status were verified too.

Multi-root workspaces are supported. The proxy publishes one authenticated endpoint per workspace root while sharing one loopback listener; bridge tokens select the root, and diagnostics/files are filtered to that root.

About

A transparent LSP proxy for a Dart analysis server snapshot.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages