summaryrefslogtreecommitdiff
path: root/src/lsp/lsp_index.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lsp/lsp_index.h')
-rw-r--r--src/lsp/lsp_index.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/lsp/lsp_index.h b/src/lsp/lsp_index.h
new file mode 100644
index 0000000..f4aaf96
--- /dev/null
+++ b/src/lsp/lsp_index.h
@@ -0,0 +1,43 @@
+
+#ifndef LSP_INDEX_H
+#define LSP_INDEX_H
+
+#include "parser.h"
+
+typedef enum
+{
+ RANGE_DEFINITION,
+ RANGE_REFERENCE
+} RangeType;
+
+typedef struct LSPRange
+{
+ int start_line;
+ int start_col;
+ int end_line;
+ int end_col; // Approximation.
+ RangeType type;
+ int def_line;
+ int def_col;
+ char *hover_text;
+ ASTNode *node;
+ struct LSPRange *next;
+} LSPRange;
+
+typedef struct LSPIndex
+{
+ LSPRange *head;
+ LSPRange *tail;
+} LSPIndex;
+
+// API.
+LSPIndex *lsp_index_new();
+void lsp_index_free(LSPIndex *idx);
+void lsp_index_add_def(LSPIndex *idx, Token t, const char *hover, ASTNode *node);
+void lsp_index_add_ref(LSPIndex *idx, Token t, Token def_t, ASTNode *node);
+LSPRange *lsp_find_at(LSPIndex *idx, int line, int col);
+
+// Walker.
+void lsp_build_index(LSPIndex *idx, ASTNode *root);
+
+#endif