fix: update Swift queries and tests for tree-sitter-swift 0.7.1

- Fix assignment query: tree-sitter-swift 0.7.1 uses named fields
  (target:/result:/suffix:) instead of positional children
- Update export detection tests: Swift `internal` (default) is now
  correctly treated as exported (module-scoped visibility)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
marxo126 2026-03-21 20:04:46 +01:00
parent 90c9153ccc
commit 712598a055
2 changed files with 11 additions and 10 deletions

View file

@ -911,13 +911,14 @@ export const SWIFT_QUERIES = `
(class_declaration "extension" name: (user_type (type_identifier) @heritage.class)
(inheritance_specifier inherits_from: (user_type (type_identifier) @heritage.extends))) @heritage
; Write access: obj.field = value
; Write access: obj.field = value (tree-sitter-swift 0.7.1 uses named fields)
(assignment
(directly_assignable_expression
(_) @assignment.receiver
(navigation_suffix
(simple_identifier) @assignment.property))
(_)) @assignment
target: (directly_assignable_expression
(navigation_expression
target: (_) @assignment.receiver
suffix: (navigation_suffix
suffix: (simple_identifier) @assignment.property)))
result: (_)) @assignment
`;

View file

@ -163,10 +163,10 @@ describe('parsing', () => {
expect(isNodeExported(nameNode, 'doStuff', 'swift')).toBe(true);
});
it('non-public function is not exported', () => {
it('non-public (internal) function is exported (Swift default is module-scoped)', () => {
const fnDecl = mockNode('function_declaration', 'func helper() {}');
const nameNode = mockNode('identifier', 'helper', fnDecl);
expect(isNodeExported(nameNode, 'helper', 'swift')).toBe(false);
expect(isNodeExported(nameNode, 'helper', 'swift')).toBe(true);
});
});
@ -660,10 +660,10 @@ describe('parsing', () => {
// Swift edge cases
describe('swift edge cases', () => {
it('internal function is not exported (Swift default)', () => {
it('internal function is exported (Swift internal = module-scoped visibility)', () => {
const visMod = mockNode('visibility_modifier', 'internal');
const nameNode = mockNode('identifier', 'setup', visMod);
expect(isNodeExported(nameNode, 'setup', 'swift')).toBe(false);
expect(isNodeExported(nameNode, 'setup', 'swift')).toBe(true);
});
it('private function is not exported', () => {