jak-project/lsp/protocol/progress_report.h
Tyler Wilding 53277a65ad
LSP: A bunch of new OpenGOAL language features (#3437)
- Integrate the AST into the LSP, this makes parsing and tokenizing the
files much easier
- Consolidate most of the symbol info tracking in `goalc` to a single
map. Fixed some issues where the old map would never evict symbols when
re-compiling files. There is still some more to cleanup, but this now
can be used as an incrementally updated source-of-truth for the LSP
- re-compile files when they are saved. Ideally this would be done
everytime they are changed but that:
  - may be too aggressive
- goalc doesn't compile incrementally yet so it likely would be a worse
UX

Features added, see
https://github.com/open-goal/opengoal-vscode/issues/256
- Hover

![image](https://github.com/open-goal/jak-project/assets/13153231/58dadb5d-582c-4c1f-9ffe-eaa4c85a0255)

![image](https://github.com/open-goal/jak-project/assets/13153231/b383adde-57fc-462c-a256-b2de5c30ca9a)
- LSP Status fixed
- Type Hierarchy

![image](https://github.com/open-goal/jak-project/assets/13153231/8e681377-1d4e-4336-ad70-1695a4607340)
- Document Color

![image](https://github.com/open-goal/jak-project/assets/13153231/4e48ccd8-0ed1-4459-a133-5277561e4201)
- Document Symbols
![Screenshot 2024-03-27
004105](https://github.com/open-goal/jak-project/assets/13153231/8e655034-43c4-4261-b6e0-85de00cbfc7f)
- Completions
![Screenshot 2024-03-30
004504](https://github.com/open-goal/jak-project/assets/13153231/d123a187-af90-466b-9eb7-561b2ee97cd1)

---------

Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
2024-03-30 19:49:07 -04:00

86 lines
3.5 KiB
C++

#pragma once
#include "common_types.h"
namespace LSPSpec {
struct WorkDoneProgressCreateParams {
// The token to be used to report progress. (can also be an integer)
std::string token;
};
void to_json(json& j, const WorkDoneProgressCreateParams& obj);
void from_json(const json& j, WorkDoneProgressCreateParams& obj);
struct WorkDoneProgressBegin {
std::string kind = "begin";
// Mandatory title of the progress operation. Used to briefly inform about
// the kind of operation being performed.
//
// Examples: "Indexing" or "Linking dependencies".
std::string title;
// Controls if a cancel button should show to allow the user to cancel the
// long running operation. Clients that don't support cancellation are
// allowed to ignore the setting.
bool cancellable = false;
// Optional, more detailed associated progress message. Contains
// complementary information to the `title`.
//
// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
// If unset, the previous progress message (if any) is still valid.
std::optional<std::string> message;
// Optional progress percentage to display (value 100 is considered 100%).
// If not provided infinite progress is assumed and clients are allowed
// to ignore the `percentage` value in subsequent in report notifications.
//
// The value should be steadily rising. Clients are free to ignore values
// that are not following this rule. The value range is [0, 100]
std::optional<uint32_t> percentage;
};
void to_json(json& j, const WorkDoneProgressBegin& obj);
void from_json(const json& j, WorkDoneProgressBegin& obj);
struct WorkDoneProgressReport {
std::string kind = "report";
// Controls enablement state of a cancel button. This property is only valid
// if a cancel button got requested in the `WorkDoneProgressBegin` payload.
//
// Clients that don't support cancellation or don't support control the
// button's enablement state are allowed to ignore the setting.
bool cancellable = false;
// Optional, more detailed associated progress message. Contains
// complementary information to the `title`.
//
// Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
// If unset, the previous progress message (if any) is still valid.
std::optional<std::string> message;
// Optional progress percentage to display (value 100 is considered 100%).
// If not provided infinite progress is assumed and clients are allowed
// to ignore the `percentage` value in subsequent in report notifications.
//
// The value should be steadily rising. Clients are free to ignore values
// that are not following this rule. The value range is [0, 100]
std::optional<uint32_t> percentage;
};
void to_json(json& j, const WorkDoneProgressReport& obj);
void from_json(const json& j, WorkDoneProgressReport& obj);
struct WorkDoneProgressEnd {
std::string kind = "end";
// Optional, a final message indicating to for example indicate the outcome
// of the operation.
std::optional<std::string> message;
};
void to_json(json& j, const WorkDoneProgressEnd& obj);
void from_json(const json& j, WorkDoneProgressEnd& obj);
struct ProgressNotificationPayload {
std::string token;
std::optional<WorkDoneProgressBegin> beginValue;
std::optional<WorkDoneProgressReport> reportValue;
std::optional<WorkDoneProgressEnd> endValue;
};
void to_json(json& j, const ProgressNotificationPayload& obj);
void from_json(const json& j, ProgressNotificationPayload& obj);
} // namespace LSPSpec