Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/Protocol/Basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <string>
#include <vector>

#include "llvm/Support/JSON.h"

namespace clice::proto {

using integer = std::int32_t;
Expand All @@ -15,6 +17,8 @@ using decimal = double;

using string = std::string;

using any = llvm::json::Value;

template <typename T>
using array = std::vector<T>;

Expand Down
17 changes: 17 additions & 0 deletions include/Protocol/Feature/ExecuteCommand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "../Basic.h"

namespace clice::proto {

struct ExecuteCommandParams {
string command;
array<any> arguments;
};

struct TextDocumentParams {
/// The text document.
TextDocumentIdentifier textDocument;
};

} // namespace clice::proto
1 change: 1 addition & 0 deletions include/Protocol/TextDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Feature/DocumentHighlight.h"
#include "Feature/DocumentLink.h"
#include "Feature/DocumentSymbol.h"
#include "Feature/ExecuteCommand.h"
#include "Feature/FoldingRange.h"
#include "Feature/Formatting.h"
#include "Feature/Hover.h"
Expand Down
2 changes: 2 additions & 0 deletions include/Server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ class Server {
private:
using Result = async::Task<json::Value>;

auto on_execute_command(proto::ExecuteCommandParams params) -> Result;

auto on_completion(proto::CompletionParams params) -> Result;

auto on_hover(proto::HoverParams params) -> Result;
Expand Down
6 changes: 6 additions & 0 deletions src/Server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ Server::Server() : indexer(database, config, kind) {
register_callback<&Server::on_shutdown>("shutdown");
register_callback<&Server::on_exit>("exit");

register_callback<&Server::on_execute_command>("workspace/executeCommand");

Comment on lines +105 to +106
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Search for executeCommandProvider or ExecuteCommandOptions registration
rg -n -A3 -B3 'executeCommandProvider|ExecuteCommandOptions' --type=cpp

Repository: clice-io/clice

Length of output: 564


🏁 Script executed:

# Also search for the initialize handler and response building
rg -n -A10 'initialize|on_initialize' --type=cpp src/Server/

Repository: clice-io/clice

Length of output: 3132


🏁 Script executed:

# Search for where capabilities are set or advertised
rg -n 'capabilities|Capabilities' --type=cpp src/Server/ | head -30

Repository: clice-io/clice

Length of output: 2018


🏁 Script executed:

# Get the full on_initialize function implementation
sed -n '5,103p' src/Server/Lifecycle.cpp

Repository: clice-io/clice

Length of output: 3522


The command handler is registered correctly, but executeCommandProvider capability is not advertised in the initialize response.

The handler registration at line 105 is correct. However, the on_initialize response in src/Server/Lifecycle.cpp does not set the executeCommandProvider capability, which clients rely on to discover supported commands. Per LSP specification, servers must advertise this capability for clients to know what commands are available. This is currently marked as FIXME in the protocol header file and should be implemented.

🤖 Prompt for AI Agents
In @src/Server/Server.cpp around lines 105 - 106, The initialize response
currently omits the executeCommandProvider capability; update the
Server::on_initialize implementation to populate
InitializeResult.capabilities.executeCommandProvider with the list of commands
the server supports (the same commands registered with
register_callback<&Server::on_execute_command>), e.g. set
executeCommandProvider.commands to that command list (and set workDoneProgress
as appropriate), and remove the FIXME in the protocol header so clients can
discover supported commands.

register_callback<&Server::on_did_open>("textDocument/didOpen");
register_callback<&Server::on_did_change>("textDocument/didChange");
register_callback<&Server::on_did_save>("textDocument/didSave");
Expand Down Expand Up @@ -184,4 +186,8 @@ async::Task<> Server::on_receive(json::Value value) {
co_return;
}

async::Task<json::Value> Server::on_execute_command(proto::ExecuteCommandParams params) {
co_return json::Value{};
}

} // namespace clice
Loading