aboutsummaryrefslogtreecommitdiff
path: root/src/server/file_resolve.odin
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/file_resolve.odin')
-rw-r--r--src/server/file_resolve.odin39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/server/file_resolve.odin b/src/server/file_resolve.odin
index 53fda8f..22d2d63 100644
--- a/src/server/file_resolve.odin
+++ b/src/server/file_resolve.odin
@@ -36,6 +36,45 @@ reset_position_context :: proc(position_context: ^DocumentPositionContext) {
position_context.index = nil
}
+resolve_ranged_file :: proc(
+ document: ^Document,
+ range: common.Range,
+ allocator := context.allocator,
+) -> map[uintptr]SymbolAndNode {
+ ast_context := make_ast_context(
+ document.ast,
+ document.imports,
+ document.package_name,
+ document.uri.uri,
+ document.fullpath,
+ allocator,
+ )
+
+ position_context: DocumentPositionContext
+
+ get_globals(document.ast, &ast_context)
+
+ ast_context.current_package = ast_context.document_package
+
+ symbols := make(map[uintptr]SymbolAndNode, 10000, allocator)
+
+ margin := 20
+
+ for decl in document.ast.decls {
+ if _, is_value := decl.derived.(^ast.Value_Decl); !is_value {
+ continue
+ }
+
+ //Look for declarations that overlap with range
+ if range.start.line - margin <= decl.end.line && decl.pos.line <= range.end.line + margin {
+ resolve_decl(&position_context, &ast_context, document, decl, &symbols, .None, allocator)
+ clear(&ast_context.locals)
+ }
+ }
+
+ return symbols
+}
+
resolve_entire_file :: proc(
document: ^Document,
flag := ResolveReferenceFlag.None,