aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/index/collector.odin12
-rw-r--r--src/index/symbol.odin1
-rw-r--r--src/server/analysis.odin18
3 files changed, 27 insertions, 4 deletions
diff --git a/src/index/collector.odin b/src/index/collector.odin
index 30150a7..4154637 100644
--- a/src/index/collector.odin
+++ b/src/index/collector.odin
@@ -92,6 +92,7 @@ collect_struct_fields :: proc(collection: ^SymbolCollection, struct_type: ast.St
names := make([dynamic] string, 0, collection.allocator);
types := make([dynamic] ^ast.Expr, 0, collection.allocator);
+ usings := make([dynamic] bool, 0, collection.allocator);
for field in struct_type.fields.list {
@@ -102,14 +103,23 @@ collect_struct_fields :: proc(collection: ^SymbolCollection, struct_type: ast.St
cloned := clone_type(field.type, collection.allocator, &collection.unique_strings);
replace_package_alias(cloned, package_map, collection);
append(&types, cloned);
+
+ if .Using in field.flags {
+ append(&usings, true);
+ }
+
+ else {
+ append(&usings, false);
+ }
+
}
}
-
value := SymbolStructValue {
names = names[:],
types = types[:],
+ usings = usings[:],
};
return value;
diff --git a/src/index/symbol.odin b/src/index/symbol.odin
index 2950bb9..1f902db 100644
--- a/src/index/symbol.odin
+++ b/src/index/symbol.odin
@@ -20,6 +20,7 @@ import "shared:common"
SymbolStructValue :: struct {
names: [] string,
types: [] ^ast.Expr,
+ usings: [] bool, //not memory efficient
};
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 7731fd7..d3d0c22 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1118,18 +1118,20 @@ make_symbol_struct_from_ast :: proc(ast_context: ^AstContext, v: ast.Struct_Type
names := make([dynamic] string, context.temp_allocator);
types := make([dynamic] ^ast.Expr, context.temp_allocator);
+ usings := make([dynamic] bool, context.temp_allocator);
for field in v.fields.list {
for n in field.names {
if identifier, ok := n.derived.(ast.Ident); ok {
append(&names, identifier.name);
+ append(&types, index.clone_type(field.type, context.temp_allocator, nil));
if .Using in field.flags {
- append(&types, index.clone_type(field.type, context.temp_allocator, nil));
+ append(&usings, true);
}
else {
- append(&types, index.clone_type(field.type, context.temp_allocator, nil));
+ append(&usings, false);
}
}
}
@@ -1139,6 +1141,7 @@ make_symbol_struct_from_ast :: proc(ast_context: ^AstContext, v: ast.Struct_Type
symbol.value = index.SymbolStructValue {
names = names[:],
types = types[:],
+ usings = usings[:],
};
return symbol;
@@ -1547,7 +1550,6 @@ get_locals :: proc(file: ast.File, function: ^ast.Node, ast_context: ^AstContext
log.info(arg.flags);
if .Using in arg.flags {
- log.info("in using");
using_stmt: ast.Using_Stmt;
using_stmt.list = make([] ^ ast.Expr, 1, context.temp_allocator);
using_stmt.list[0] = arg.type;
@@ -1848,6 +1850,11 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
if resolved, ok := resolve_type_identifier(&ast_context, ident); ok {
resolved.name = ident.name;
resolved.signature = get_signature(&ast_context, ident, resolved);
+
+ if is_variable, ok := ast_context.variables[ident.name]; ok && is_variable {
+ resolved.pkg = ast_context.document_package;
+ }
+
hover.range = common.get_token_range(position_context.identifier^, document.ast.src);
hover.contents = write_hover_content(&ast_context, resolved);
return hover, true;
@@ -1911,6 +1918,11 @@ get_hover_information :: proc(document: ^Document, position: common.Position) ->
if resolved, ok := resolve_type_identifier(&ast_context, ident); ok {
resolved.name = ident.name;
resolved.signature = get_signature(&ast_context, ident, resolved);
+
+ if is_variable, ok := ast_context.variables[ident.name]; ok && is_variable {
+ resolved.pkg = ast_context.document_package;
+ }
+
hover.range = common.get_token_range(position_context.identifier^, document.ast.src);
hover.contents = write_hover_content(&ast_context, resolved);
return hover, true;