Skip to content

fix: Fix nested packages #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ jobs:
- name: Run parser and binding tests
uses: tree-sitter/parser-test-action@v2
with:
generate: false
test-rust: true
test-node: true
test-python: true
test-go: true
test-swift: true
test-swift: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity is there a reason we don't want to test swift anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GitHub Action setup-swift is broken, so the CI currently fails on test-swift: https://github.com/tree-sitter/tree-sitter-scala/actions/runs/15515697083/job/43682548623

Run swift-actions/setup-swift@v2
/usr/bin/gpg --import /home/runner/work/_temp/f422a293-ac58-4b0d-b0e4-d1579ed0a03d
gpg: directory '/home/runner/.gnupg' created
gpg: keybox '/home/runner/.gnupg/pubring.kbx' created
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
Error: Unexpected error, unable to continue. Please report at https://github.com/swift-actions/setup-swift/issues
The process '/usr/bin/gpg' failed with exit code 2
Stacktrace:
Error: The process '/usr/bin/gpg' failed with exit code 2
    at ExecState._setResult (/home/runner/work/_actions/swift-actions/setup-swift/v2/dist/index.js:3197:25)

swift-actions/setup-swift#694


- name: Parse sample files
uses: tree-sitter/parse-action@v4
Expand Down
4 changes: 2 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const PREC = {

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, scala_scala/src/library/: 100.00%, expected at least 100%

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, scala_scala/src/compiler/: 96.65%, expected at least 96%

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, dotty/compiler/: 83.76%, expected at least 83%

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, lila/modules/: 84.35%, expected at least 84%
comment: 1,
using_directive: 2,
control: 1,
Expand Down Expand Up @@ -126,8 +126,6 @@

_top_level_definition: $ =>
choice(
$.package_clause,
$.package_object,
$._definition,
$._end_marker,
$.expression,
Expand All @@ -150,6 +148,8 @@
$.type_definition,
$.function_definition,
$.function_declaration,
$.package_clause,
$.package_object,
),

enum_definition: $ =>
Expand Down Expand Up @@ -941,7 +941,7 @@
),
),

tuple_type: $ => seq("(", trailingCommaSep1($._type), ")"),

Check notice on line 944 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, complexity of the most complex definition tuple_type: 1223, lower than the allowed ceiling 1400

named_tuple_type: $ => seq("(", trailingCommaSep1($.name_and_type), ")"),

Expand Down
34 changes: 32 additions & 2 deletions test/corpus/definitions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ package a.b
package c {
object A
}
package d {
package e {
object B
}
}

--------------------------------------------------------------------------------

Expand All @@ -154,7 +159,17 @@ package c {
(identifier))
(template_body
(object_definition
(identifier)))))
(identifier))))
(package_clause
(package_identifier
(identifier))
(template_body
(package_clause
(package_identifier
(identifier))
(template_body
(object_definition
(identifier)))))))

================================================================================
Package with comma
Expand Down Expand Up @@ -210,6 +225,12 @@ package object d extends A {
val hello: String = "there"
}

package object p1 {
package object p2 {
val a = 1
}
}

--------------------------------------------------------------------------------

(compilation_unit
Expand All @@ -221,7 +242,16 @@ package object d extends A {
(val_definition
(identifier)
(type_identifier)
(string)))))
(string))))
(package_object
(identifier)
(template_body
(package_object
(identifier)
(template_body
(val_definition
(identifier)
(integer_literal)))))))

================================================================================
Imports
Expand Down
Loading