Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGavin committed Nov 25, 2023
2 parents 31cda7e + e53da4d commit eff0220
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
macos:
strategy:
matrix:
os: [macos-11, macos-latest]
os: [macos-12, macos-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
timeout-minutes: 15
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Download LLVM
run: sudo apt-get install llvm-11 clang-11
run: sudo apt update && sudo apt purge -qq -y llvm-12 clang-12
- name: Download Odin
run: |
git clone https://github.com/odin-lang/Odin
Expand Down
35 changes: 27 additions & 8 deletions src/common/ast.odin
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ collect_value_decl :: proc(
skip_private: bool,
) {
if value_decl, ok := stmt.derived.(^ast.Value_Decl); ok {
is_deprecated := false
is_deprecated := false
is_private_file := false
is_package_file := false
is_builtin := false
is_private_pkg := false
is_builtin := false

for attribute in value_decl.attributes {
for elem in attribute.elems {
Expand All @@ -215,10 +215,10 @@ collect_value_decl :: proc(
case "\"file\"":
is_private_file = true
case "package":
is_package_file = true
is_private_pkg = true
}
} else {
is_package_file = true
is_private_pkg = true
}
}
}
Expand All @@ -229,7 +229,7 @@ collect_value_decl :: proc(
case "builtin":
is_builtin = true
case "private":
is_package_file = true
is_private_pkg = true
}
}
}
Expand All @@ -238,6 +238,25 @@ collect_value_decl :: proc(
if is_private_file && skip_private {
return
}

// If a private status is not explicitly set with an attribute above the declaration
// check the file comment.
if !is_private_file && !is_private_pkg && file.docs != nil {
for comment in file.docs.list {
txt := comment.text
if strings.has_prefix(txt, "//+private") {
txt = strings.trim_prefix(txt, "//+private")
is_private_pkg = true

if strings.has_prefix(txt, " ") {
txt = strings.trim_space(txt)
if txt == "file" {
is_private_file = true
}
}
}
}
}

for name, i in value_decl.names {
str := get_ast_node_string(name, file.src)
Expand All @@ -254,7 +273,7 @@ collect_value_decl :: proc(
attributes = value_decl.attributes[:],
deprecated = is_deprecated,
builtin = is_builtin,
package_private = is_package_file,
package_private = is_private_pkg,
},
)
} else {
Expand All @@ -270,7 +289,7 @@ collect_value_decl :: proc(
attributes = value_decl.attributes[:],
deprecated = is_deprecated,
builtin = is_builtin,
package_private = is_package_file,
package_private = is_private_pkg,
},
)
}
Expand Down

0 comments on commit eff0220

Please sign in to comment.