summaryrefslogtreecommitdiff
path: root/modules/gdscript/language_server/lsp.hpp
diff options
context:
space:
mode:
authorFrancois Belair <razoric480@gmail.com>2021-07-11 15:51:31 -0400
committerFrancois Belair <razoric480@gmail.com>2021-07-11 16:17:49 -0400
commit9a8421aa058437ce01bc67244bb8dcd0f15fc9e6 (patch)
treea6e5958415dd3651e7565dd3743542d711e268b9 /modules/gdscript/language_server/lsp.hpp
parentfb3961b2ef9ed03501f98a8aa621f78679cc2be9 (diff)
Implement applyEdit in LSP for signal connecting
Diffstat (limited to 'modules/gdscript/language_server/lsp.hpp')
-rw-r--r--modules/gdscript/language_server/lsp.hpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/modules/gdscript/language_server/lsp.hpp b/modules/gdscript/language_server/lsp.hpp
index a7dcfdb22d..025b1f498c 100644
--- a/modules/gdscript/language_server/lsp.hpp
+++ b/modules/gdscript/language_server/lsp.hpp
@@ -1266,6 +1266,58 @@ struct DocumentSymbol {
}
};
+struct WorkspaceEdit {
+ HashMap<String, List<TextEdit>> changes;
+
+ void add_edit(String uri, TextEdit edit) {
+ if (changes.has(uri)) {
+ changes[uri].push_back(edit);
+ } else {
+ List<TextEdit> edits;
+ edits.push_back(edit);
+ changes[uri] = edits;
+ }
+ }
+
+ Dictionary to_json() {
+ Dictionary dict;
+
+ Dictionary changes_dict;
+
+ List<String> key_list;
+ changes.get_key_list(&key_list);
+ for (int i = 0; i < key_list.size(); ++i) {
+ String uri = key_list[i];
+
+ List<TextEdit> edits = changes[key_list[i]];
+ Array changes_arr;
+ for (int l = 0; l < edits.size(); ++l) {
+ Dictionary change_dict;
+ change_dict["newText"] = edits[l].newText;
+ change_dict["range"] = edits[l].range.to_json();
+ changes_arr.push_back(change_dict);
+ }
+ changes_dict[uri] = changes_arr;
+ }
+
+ dict["changes"] = changes_dict;
+
+ return dict;
+ }
+};
+
+struct ApplyWorkspaceEditParams {
+ WorkspaceEdit edit;
+
+ Dictionary to_json() {
+ Dictionary dict;
+
+ dict["edit"] = edit.to_json();
+
+ return dict;
+ }
+};
+
struct NativeSymbolInspectParams {
String native_class;
String symbol_name;