This repository has been archived by the owner on Jul 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
99 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#include "lsp.h" | ||
|
||
// codeAction | ||
struct CommandArgs { | ||
lsDocumentUri textDocumentUri; | ||
std::vector<lsTextEdit> edits; | ||
}; | ||
MAKE_REFLECT_STRUCT_WRITER_AS_ARRAY(CommandArgs, textDocumentUri, edits); | ||
|
||
// codeLens | ||
struct lsCodeLensUserData {}; | ||
MAKE_REFLECT_EMPTY_STRUCT(lsCodeLensUserData); | ||
|
||
struct lsCodeLensCommandArguments { | ||
lsDocumentUri uri; | ||
lsPosition position; | ||
std::vector<lsLocation> locations; | ||
}; | ||
|
||
// FIXME Don't use array in vscode-cquery | ||
inline void Reflect(Writer& visitor, lsCodeLensCommandArguments& value) { | ||
visitor.StartArray(3); | ||
Reflect(visitor, value.uri); | ||
Reflect(visitor, value.position); | ||
Reflect(visitor, value.locations); | ||
visitor.EndArray(); | ||
} | ||
|
||
inline void Reflect(Reader& visitor, lsCodeLensCommandArguments& value) { | ||
int i = 0; | ||
visitor.IterArray([&](Reader& visitor) { | ||
switch (i++) { | ||
case 0: | ||
Reflect(visitor, value.uri); | ||
break; | ||
case 1: | ||
Reflect(visitor, value.position); | ||
break; | ||
case 2: | ||
Reflect(visitor, value.locations); | ||
break; | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "lsp_code_action.h" | ||
#include "message_handler.h" | ||
#include "query_utils.h" | ||
#include "queue_manager.h" | ||
|
||
namespace { | ||
|
||
struct Ipc_WorkspaceExecuteCommand | ||
: public RequestMessage<Ipc_WorkspaceExecuteCommand> { | ||
const static IpcId kIpcId = IpcId::WorkspaceExecuteCommand; | ||
lsCommand<lsCodeLensCommandArguments> params; | ||
}; | ||
MAKE_REFLECT_STRUCT(Ipc_WorkspaceExecuteCommand, id, params); | ||
REGISTER_IPC_MESSAGE(Ipc_WorkspaceExecuteCommand); | ||
|
||
struct Out_WorkspaceExecuteCommand | ||
: public lsOutMessage<Out_WorkspaceExecuteCommand> { | ||
lsRequestId id; | ||
std::variant<std::vector<lsLocation>, CommandArgs> result; | ||
}; | ||
MAKE_REFLECT_STRUCT(Out_WorkspaceExecuteCommand, jsonrpc, id, result); | ||
|
||
void Reflect(Writer& visitor, Out_WorkspaceExecuteCommand& value) { | ||
REFLECT_MEMBER_START(); | ||
REFLECT_MEMBER(jsonrpc); | ||
REFLECT_MEMBER(id); | ||
REFLECT_MEMBER(result); | ||
REFLECT_MEMBER_END(); | ||
} | ||
|
||
struct WorkspaceExecuteCommandHandler | ||
: BaseMessageHandler<Ipc_WorkspaceExecuteCommand> { | ||
void Run(Ipc_WorkspaceExecuteCommand* request) override { | ||
const auto& params = request->params; | ||
Out_WorkspaceExecuteCommand out; | ||
out.id = request->id; | ||
if (params.command == "cquery._applyFixIt") { | ||
} else if (params.command == "cquery._autoImplement") { | ||
} else if (params.command == "cquery._insertInclude") { | ||
} else if (params.command == "cquery.showReferences") { | ||
out.result = params.arguments.locations; | ||
} | ||
|
||
QueueManager::WriteStdout(IpcId::WorkspaceExecuteCommand, out); | ||
} | ||
}; | ||
REGISTER_MESSAGE_HANDLER(WorkspaceExecuteCommandHandler); | ||
|
||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters