🐛 fix(core): enable syntax diagnostics
This commit is contained in:
@@ -14,7 +14,6 @@ import lsp.manager.bootstrap;
|
|||||||
import lsp.manager.events;
|
import lsp.manager.events;
|
||||||
import lsp.manager.manager_hub;
|
import lsp.manager.manager_hub;
|
||||||
import lsp.protocol;
|
import lsp.protocol;
|
||||||
import lsp.provider.manifest;
|
|
||||||
import lsp.scheduler.async_executor;
|
import lsp.scheduler.async_executor;
|
||||||
import lsp.utils.text_coordinates;
|
import lsp.utils.text_coordinates;
|
||||||
|
|
||||||
@@ -157,8 +156,7 @@ namespace lsp::core
|
|||||||
std::ostream& output,
|
std::ostream& output,
|
||||||
ProviderRegistrar registrar,
|
ProviderRegistrar registrar,
|
||||||
std::size_t concurrency,
|
std::size_t concurrency,
|
||||||
std::string interpreter_path)
|
std::string interpreter_path) : input_(input),
|
||||||
: input_(input),
|
|
||||||
output_(output),
|
output_(output),
|
||||||
manager_hub_(),
|
manager_hub_(),
|
||||||
async_executor_(concurrency),
|
async_executor_(concurrency),
|
||||||
@@ -169,14 +167,7 @@ namespace lsp::core
|
|||||||
|
|
||||||
InitializeManagerHub();
|
InitializeManagerHub();
|
||||||
RegisterProviders(std::move(registrar));
|
RegisterProviders(std::move(registrar));
|
||||||
if (provider::kEnableDiagnosticsPublisher)
|
|
||||||
{
|
|
||||||
RegisterDiagnosticsPublisher();
|
RegisterDiagnosticsPublisher();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
spdlog::debug("Diagnostics publisher disabled (staged rollout)");
|
|
||||||
}
|
|
||||||
|
|
||||||
spdlog::debug("LSP server initialized with {} providers.",
|
spdlog::debug("LSP server initialized with {} providers.",
|
||||||
dispatcher_.GetAllSupportedMethods().size());
|
dispatcher_.GetAllSupportedMethods().size());
|
||||||
@@ -701,7 +692,7 @@ namespace lsp::core
|
|||||||
}
|
}
|
||||||
|
|
||||||
manager::bootstrap::InitializeManagerHub(
|
manager::bootstrap::InitializeManagerHub(
|
||||||
manager_hub_, async_executor_, {funcext_path.string()});
|
manager_hub_, async_executor_, { funcext_path.string() });
|
||||||
}
|
}
|
||||||
|
|
||||||
void LspServer::RegisterProviders(ProviderRegistrar registrar)
|
void LspServer::RegisterProviders(ProviderRegistrar registrar)
|
||||||
|
|||||||
@@ -15,78 +15,8 @@ import lsp.provider.text_document.did_open;
|
|||||||
import lsp.provider.text_document.completion;
|
import lsp.provider.text_document.completion;
|
||||||
import lsp.provider.trace.set_trace;
|
import lsp.provider.trace.set_trace;
|
||||||
|
|
||||||
// NOTE: keep other providers implemented but disabled.
|
|
||||||
// Uncomment when re-enabling additional capabilities.
|
|
||||||
// import lsp.provider.call_hierarchy.incoming_calls;
|
|
||||||
// import lsp.provider.call_hierarchy.outgoing_calls;
|
|
||||||
// import lsp.provider.client.register_capability;
|
|
||||||
// import lsp.provider.client.unregister_capability;
|
|
||||||
// import lsp.provider.code_action.resolve;
|
|
||||||
// import lsp.provider.code_lens.resolve;
|
|
||||||
// import lsp.provider.document_link.resolve;
|
|
||||||
// import lsp.provider.inlay_hint.resolve;
|
|
||||||
// import lsp.provider.telemetry.event;
|
|
||||||
// import lsp.provider.text_document.code_action;
|
|
||||||
// import lsp.provider.text_document.code_lens;
|
|
||||||
// import lsp.provider.text_document.color_presentation;
|
|
||||||
// import lsp.provider.text_document.diagnostic;
|
|
||||||
// import lsp.provider.text_document.document_color;
|
|
||||||
// import lsp.provider.text_document.document_highlight;
|
|
||||||
// import lsp.provider.text_document.document_link;
|
|
||||||
// import lsp.provider.text_document.document_symbol;
|
|
||||||
// import lsp.provider.text_document.folding_range;
|
|
||||||
// import lsp.provider.text_document.formatting;
|
|
||||||
// import lsp.provider.text_document.hover;
|
|
||||||
// import lsp.provider.text_document.implementation;
|
|
||||||
// import lsp.provider.text_document.inlay_hint;
|
|
||||||
// import lsp.provider.text_document.inline_value;
|
|
||||||
// import lsp.provider.text_document.linked_editing_range;
|
|
||||||
// import lsp.provider.text_document.moniker;
|
|
||||||
// import lsp.provider.text_document.on_type_formatting;
|
|
||||||
// import lsp.provider.text_document.prepare_call_hierarchy;
|
|
||||||
// import lsp.provider.text_document.prepare_rename;
|
|
||||||
// import lsp.provider.text_document.prepare_type_hierarchy;
|
|
||||||
// import lsp.provider.text_document.publish_diagnostics;
|
|
||||||
// import lsp.provider.text_document.range_formatting;
|
|
||||||
// import lsp.provider.text_document.references;
|
|
||||||
// import lsp.provider.text_document.rename;
|
|
||||||
// import lsp.provider.text_document.selection_range;
|
|
||||||
// import lsp.provider.text_document.semantic_tokens;
|
|
||||||
// import lsp.provider.text_document.signature_help;
|
|
||||||
// import lsp.provider.text_document.type_definition;
|
|
||||||
// import lsp.provider.type_hierarchy.subtypes;
|
|
||||||
// import lsp.provider.type_hierarchy.supertypes;
|
|
||||||
// import lsp.provider.window.log_message;
|
|
||||||
// import lsp.provider.window.show_document;
|
|
||||||
// import lsp.provider.window.show_message;
|
|
||||||
// import lsp.provider.window.show_message_request;
|
|
||||||
// import lsp.provider.window.work_done_progress_create;
|
|
||||||
// import lsp.provider.workspace.apply_edit;
|
|
||||||
// import lsp.provider.workspace.code_lens_refresh;
|
|
||||||
// import lsp.provider.workspace.configuration;
|
|
||||||
// import lsp.provider.workspace.diagnostic;
|
|
||||||
// import lsp.provider.workspace.did_change_configuration;
|
|
||||||
// import lsp.provider.workspace.did_change_watched_files;
|
|
||||||
// import lsp.provider.workspace.did_change_workspace_folders;
|
|
||||||
// import lsp.provider.workspace.did_create_files;
|
|
||||||
// import lsp.provider.workspace.did_delete_files;
|
|
||||||
// import lsp.provider.workspace.did_rename_files;
|
|
||||||
// import lsp.provider.workspace.diagnostic_refresh;
|
|
||||||
// import lsp.provider.workspace.execute_command;
|
|
||||||
// import lsp.provider.workspace.inlay_hint_refresh;
|
|
||||||
// import lsp.provider.workspace.inline_value_refresh;
|
|
||||||
// import lsp.provider.workspace.semantic_tokens_refresh;
|
|
||||||
// import lsp.provider.workspace.symbol;
|
|
||||||
// import lsp.provider.workspace.workspace_folders;
|
|
||||||
// import lsp.provider.workspace.will_create_files;
|
|
||||||
// import lsp.provider.workspace.will_delete_files;
|
|
||||||
// import lsp.provider.workspace.will_rename_files;
|
|
||||||
// import lsp.provider.workspace_symbol.resolve;
|
|
||||||
|
|
||||||
export namespace lsp::provider
|
export namespace lsp::provider
|
||||||
{
|
{
|
||||||
inline constexpr bool kEnableDiagnosticsPublisher = false;
|
|
||||||
|
|
||||||
using AllProviders = ProviderRegistry<
|
using AllProviders = ProviderRegistry<
|
||||||
completion_item::Resolve,
|
completion_item::Resolve,
|
||||||
Initialize,
|
Initialize,
|
||||||
@@ -96,88 +26,7 @@ export namespace lsp::provider
|
|||||||
text_document::DidChange,
|
text_document::DidChange,
|
||||||
text_document::DidClose,
|
text_document::DidClose,
|
||||||
text_document::DidOpen,
|
text_document::DidOpen,
|
||||||
SetTrace
|
SetTrace>;
|
||||||
>;
|
|
||||||
|
|
||||||
// Full provider registry (kept commented for quick re-enable during staged rollout):
|
|
||||||
// using AllProviders = ProviderRegistry<
|
|
||||||
// call_hierarchy::IncomingCalls,
|
|
||||||
// call_hierarchy::OutgoingCalls,
|
|
||||||
// client::RegisterCapability,
|
|
||||||
// client::UnregisterCapability,
|
|
||||||
// code_action::Resolve,
|
|
||||||
// code_lens::Resolve,
|
|
||||||
// completion_item::Resolve,
|
|
||||||
// document_link::Resolve,
|
|
||||||
// Initialize,
|
|
||||||
// Initialized,
|
|
||||||
// inlay_hint::Resolve,
|
|
||||||
// telemetry::Event,
|
|
||||||
// text_document::CodeAction,
|
|
||||||
// text_document::CodeLens,
|
|
||||||
// text_document::ColorPresentation,
|
|
||||||
// text_document::Completion,
|
|
||||||
// text_document::Definition,
|
|
||||||
// text_document::Diagnostic,
|
|
||||||
// text_document::DidChange,
|
|
||||||
// text_document::DidClose,
|
|
||||||
// text_document::DidOpen,
|
|
||||||
// text_document::DocumentColor,
|
|
||||||
// text_document::DocumentHighlight,
|
|
||||||
// text_document::DocumentLink,
|
|
||||||
// text_document::DocumentSymbol,
|
|
||||||
// text_document::FoldingRange,
|
|
||||||
// text_document::Formatting,
|
|
||||||
// text_document::Hover,
|
|
||||||
// text_document::Implementation,
|
|
||||||
// text_document::InlayHint,
|
|
||||||
// text_document::InlineValue,
|
|
||||||
// text_document::LinkedEditingRange,
|
|
||||||
// text_document::Moniker,
|
|
||||||
// text_document::OnTypeFormatting,
|
|
||||||
// text_document::PrepareCallHierarchy,
|
|
||||||
// text_document::PrepareRename,
|
|
||||||
// text_document::PrepareTypeHierarchy,
|
|
||||||
// text_document::PublishDiagnostics,
|
|
||||||
// text_document::RangeFormatting,
|
|
||||||
// text_document::References,
|
|
||||||
// text_document::Rename,
|
|
||||||
// text_document::SelectionRange,
|
|
||||||
// text_document::SemanticTokensRange,
|
|
||||||
// text_document::SemanticTokensFull,
|
|
||||||
// text_document::SemanticTokensFullDelta,
|
|
||||||
// text_document::SignatureHelp,
|
|
||||||
// text_document::TypeDefinition,
|
|
||||||
// SetTrace,
|
|
||||||
// type_hierarchy::Subtypes,
|
|
||||||
// type_hierarchy::Supertypes,
|
|
||||||
// window::LogMessage,
|
|
||||||
// window::ShowDocument,
|
|
||||||
// window::ShowMessage,
|
|
||||||
// window::ShowMessageRequest,
|
|
||||||
// window::WorkDoneProgressCreate,
|
|
||||||
// workspace::ApplyEdit,
|
|
||||||
// workspace::CodeLensRefresh,
|
|
||||||
// workspace::Configuration,
|
|
||||||
// workspace::Diagnostic,
|
|
||||||
// workspace::DidChangeConfiguration,
|
|
||||||
// workspace::DidChangeWatchedFiles,
|
|
||||||
// workspace::DidChangeWorkspaceFolders,
|
|
||||||
// workspace::DidCreateFiles,
|
|
||||||
// workspace::DidDeleteFiles,
|
|
||||||
// workspace::DidRenameFiles,
|
|
||||||
// workspace::DiagnosticRefresh,
|
|
||||||
// workspace::ExecuteCommand,
|
|
||||||
// workspace::InlayHintRefresh,
|
|
||||||
// workspace::InlineValueRefresh,
|
|
||||||
// workspace::SemanticTokensRefresh,
|
|
||||||
// workspace::Symbol,
|
|
||||||
// workspace::WorkspaceFolders,
|
|
||||||
// workspace::WillCreateFiles,
|
|
||||||
// workspace::WillDeleteFiles,
|
|
||||||
// workspace::WillRenameFiles,
|
|
||||||
// workspace_symbol::Resolve
|
|
||||||
// >;
|
|
||||||
|
|
||||||
static_assert(AllProviders::kProviderCount > 0, "No providers registered.");
|
static_assert(AllProviders::kProviderCount > 0, "No providers registered.");
|
||||||
|
|
||||||
|
|||||||
@@ -340,6 +340,48 @@ def assert_framing(server: Path) -> None:
|
|||||||
raise RuntimeError("continuous framing should reach shutdown")
|
raise RuntimeError("continuous framing should reach shutdown")
|
||||||
|
|
||||||
|
|
||||||
|
def assert_diagnostics(server: Path) -> None:
|
||||||
|
client = LspClient(server)
|
||||||
|
try:
|
||||||
|
client.send({
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 41,
|
||||||
|
"method": "initialize",
|
||||||
|
"params": {},
|
||||||
|
})
|
||||||
|
if client.read().get("id") != 41:
|
||||||
|
raise RuntimeError("missing initialize response")
|
||||||
|
|
||||||
|
uri = "file:///diagnostics.tsl"
|
||||||
|
client.send({
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "textDocument/didOpen",
|
||||||
|
"params": {
|
||||||
|
"textDocument": {
|
||||||
|
"uri": uri,
|
||||||
|
"languageId": "tsl",
|
||||||
|
"version": 1,
|
||||||
|
"text": "function broken(",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
diagnostics = client.read(timeout=1)
|
||||||
|
if diagnostics.get("method") != "textDocument/publishDiagnostics":
|
||||||
|
raise RuntimeError("didOpen should publish diagnostics")
|
||||||
|
params = diagnostics.get("params", {})
|
||||||
|
if params.get("uri") != uri or not params.get("diagnostics"):
|
||||||
|
raise RuntimeError("syntax diagnostics should identify the opened document")
|
||||||
|
|
||||||
|
client.send({"jsonrpc": "2.0", "id": 42, "method": "shutdown"})
|
||||||
|
if client.read().get("id") != 42:
|
||||||
|
raise RuntimeError("missing shutdown response")
|
||||||
|
client.send({"jsonrpc": "2.0", "method": "exit"})
|
||||||
|
if client.close_input() != 0:
|
||||||
|
raise RuntimeError("diagnostics sequence should shut down cleanly")
|
||||||
|
finally:
|
||||||
|
client.kill()
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("--server", type=Path, required=True)
|
parser.add_argument("--server", type=Path, required=True)
|
||||||
@@ -349,6 +391,7 @@ def main() -> int:
|
|||||||
assert_json_rpc_errors(args.server)
|
assert_json_rpc_errors(args.server)
|
||||||
assert_cancellation_and_failures(args.server)
|
assert_cancellation_and_failures(args.server)
|
||||||
assert_framing(args.server)
|
assert_framing(args.server)
|
||||||
|
assert_diagnostics(args.server)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import lsp.codec.facade;
|
|||||||
import lsp.core.server;
|
import lsp.core.server;
|
||||||
import lsp.protocol;
|
import lsp.protocol;
|
||||||
import lsp.provider.base.interface;
|
import lsp.provider.base.interface;
|
||||||
|
import lsp.provider.text_document.did_open;
|
||||||
|
|
||||||
export namespace lsp::test::provider
|
export namespace lsp::test::provider
|
||||||
{
|
{
|
||||||
@@ -121,6 +122,8 @@ namespace lsp::test::provider
|
|||||||
dispatcher.RegisterRequestProvider(std::make_shared<FixtureInitialize>());
|
dispatcher.RegisterRequestProvider(std::make_shared<FixtureInitialize>());
|
||||||
dispatcher.RegisterRequestProvider(std::make_shared<FixtureBlock>());
|
dispatcher.RegisterRequestProvider(std::make_shared<FixtureBlock>());
|
||||||
dispatcher.RegisterRequestProvider(std::make_shared<FixtureThrow>());
|
dispatcher.RegisterRequestProvider(std::make_shared<FixtureThrow>());
|
||||||
|
dispatcher.RegisterNotificationProvider(
|
||||||
|
std::make_shared<::lsp::provider::text_document::DidOpen>());
|
||||||
dispatcher.RegisterNotificationProvider(
|
dispatcher.RegisterNotificationProvider(
|
||||||
std::make_shared<FixtureThrowNotification>());
|
std::make_shared<FixtureThrowNotification>());
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user