aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/ast.odin23
-rw-r--r--src/index/collector.odin2
2 files changed, 17 insertions, 8 deletions
diff --git a/src/common/ast.odin b/src/common/ast.odin
index c798c1c..e85a261 100644
--- a/src/common/ast.odin
+++ b/src/common/ast.odin
@@ -34,8 +34,17 @@ GlobalExpr :: struct {
docs: ^ast.Comment_Group,
}
-collect_value_decl :: proc(exprs: ^[dynamic]GlobalExpr, file: ast.File, stmt: ^ast.Node) {
+collect_value_decl :: proc(exprs: ^[dynamic]GlobalExpr, file: ast.File, stmt: ^ast.Node, skip_private: bool) {
if value_decl, ok := stmt.derived.(ast.Value_Decl); ok {
+
+ for attribute in value_decl.attributes {
+ for elem in attribute.elems {
+ if ident, ok := elem.derived.(ast.Ident); ok && ident.name == "private" && skip_private {
+ return;
+ }
+ }
+ }
+
for name, i in value_decl.names {
str := get_ast_node_string(name, file.src);
@@ -50,14 +59,14 @@ collect_value_decl :: proc(exprs: ^[dynamic]GlobalExpr, file: ast.File, stmt: ^a
}
}
-collect_globals :: proc(file: ast.File) -> []GlobalExpr {
+collect_globals :: proc(file: ast.File, skip_private := false) -> []GlobalExpr {
exprs := make([dynamic]GlobalExpr, context.temp_allocator);
for decl in file.decls {
if value_decl, ok := decl.derived.(ast.Value_Decl); ok {
- collect_value_decl(&exprs, file, decl);
+ collect_value_decl(&exprs, file, decl, skip_private);
} else if when_decl, ok := decl.derived.(ast.When_Stmt); ok {
if when_decl.cond == nil {
@@ -96,13 +105,13 @@ collect_globals :: proc(file: ast.File) -> []GlobalExpr {
if block, ok := when_decl.body.derived.(ast.Block_Stmt); ok {
for stmt in block.stmts {
- collect_value_decl(&exprs, file, stmt);
+ collect_value_decl(&exprs, file, stmt, skip_private);
}
}
} else if ident.name != "ODIN_OS" {
if block, ok := when_decl.body.derived.(ast.Block_Stmt); ok {
for stmt in block.stmts {
- collect_value_decl(&exprs, file, stmt);
+ collect_value_decl(&exprs, file, stmt, skip_private);
}
}
}
@@ -112,7 +121,7 @@ collect_globals :: proc(file: ast.File) -> []GlobalExpr {
else {
if block, ok := when_decl.body.derived.(ast.Block_Stmt); ok {
for stmt in block.stmts {
- collect_value_decl(&exprs, file, stmt);
+ collect_value_decl(&exprs, file, stmt, skip_private);
}
}
}
@@ -124,7 +133,7 @@ collect_globals :: proc(file: ast.File) -> []GlobalExpr {
if block, ok := foreign_decl.body.derived.(ast.Block_Stmt); ok {
for stmt in block.stmts {
- collect_value_decl(&exprs, file, stmt);
+ collect_value_decl(&exprs, file, stmt, skip_private);
}
}
}
diff --git a/src/index/collector.odin b/src/index/collector.odin
index d22710a..781418a 100644
--- a/src/index/collector.odin
+++ b/src/index/collector.odin
@@ -211,7 +211,7 @@ collect_symbols :: proc(collection: ^SymbolCollection, file: ast.File, uri: stri
package_map := get_package_mapping(file, collection.config, directory);
- exprs := common.collect_globals(file);
+ exprs := common.collect_globals(file, true);
for expr in exprs {