summaryrefslogtreecommitdiff
path: root/ide-usages.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-08-05 15:08:45 -0400
committerpommicket <pommicket@gmail.com>2023-08-05 15:08:45 -0400
commit4b10cb8f0892a720bd8d7f61b39f5faffc43107c (patch)
tree0c28195572231c93c11fa3d6b625ea0dc0328ce9 /ide-usages.c
parentb65943698a241624973f3ab54530bb5d5884cff2 (diff)
internalize signature help, usages
Diffstat (limited to 'ide-usages.c')
-rw-r--r--ide-usages.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/ide-usages.c b/ide-usages.c
index b9c2085..0547b5c 100644
--- a/ide-usages.c
+++ b/ide-usages.c
@@ -1,14 +1,27 @@
// find usages of symbol
#include "ted.h"
+struct Usages {
+ LSPServerRequestID last_request;
+ double last_request_time;
+};
+
+void usages_init(Ted *ted) {
+ ted->usages = calloc(1, sizeof *ted->usages);
+}
+
+void usages_quit(Ted *ted) {
+ free(ted->usages);
+ ted->usages = NULL;
+}
void usages_cancel_lookup(Ted *ted) {
- Usages *usages = &ted->usages;
+ Usages *usages = ted->usages;
ted_cancel_lsp_request(ted, &usages->last_request);
}
void usages_find(Ted *ted) {
- Usages *usages = &ted->usages;
+ Usages *usages = ted->usages;
TextBuffer *buffer = ted->active_buffer;
if (!buffer) return;
LSP *lsp = buffer_lsp(buffer);
@@ -26,7 +39,7 @@ void usages_find(Ted *ted) {
void usages_process_lsp_response(Ted *ted, const LSPResponse *response) {
- Usages *usages = &ted->usages;
+ Usages *usages = ted->usages;
if (response->request.type != LSP_REQUEST_REFERENCES)
return; // not for us
if (response->request.id != usages->last_request.id)
@@ -125,7 +138,7 @@ void usages_process_lsp_response(Ted *ted, const LSPResponse *response) {
}
void usages_frame(Ted *ted) {
- Usages *usages = &ted->usages;
+ Usages *usages = ted->usages;
if (usages->last_request.id && ted->frame_time - usages->last_request_time > 0.2)
ted->cursor = ted->cursor_wait; // this request is takin a while
}