1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Implement applyEdit in LSP for signal connecting

This commit is contained in:
Francois Belair
2021-07-11 15:51:31 -04:00
parent fb3961b2ef
commit 9a8421aa05
5 changed files with 126 additions and 0 deletions

View File

@@ -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;