Files
codegraph/__tests__
Colby Mchenry 6c202bca32 fix(objc): a struct, union or enum defined in a variable declaration is indexed (#2690)
Objective-C kept the gap that PR #2446 closed for C and C++: a struct,
union or enum defined in the type of a file-scope declaration, like
`static struct { Class isa; } placeholder;`, `struct Foo { int a; } foo;`
or `enum { ModeA, ModeB } mode;`, never became a node. The walker's
declaration branch extracted the variable and skipped the declaration's
children, and Objective-C did not take the declared-type walk.

- tree-sitter.ts: Objective-C walks a type defined in a declaration's
  type, as C does, also when the tree has errors. Most Objective-C trees
  have errors (a lone macro like NS_ASSUME_NONNULL_BEGIN is enough; 832 of
  ObjFW's 1087 Objective-C files), so a clean-tree gate would skip nearly
  every real site, and neither grammar has a namespace or a class written
  as a type that error recovery could close at the wrong brace.
- objc.ts: resolveName composes selector naming with C's
  unnamedTypeVariableName, so an unnamed type takes the first variable its
  declaration declares (in function and method bodies too), and
  getDeclarationWrapper makes the declaration's comment the docstring.
- c-cpp.ts: export definingDeclaration and unnamedTypeVariableName.
- name-matcher.ts: a struct, union, enum or typedef that a .m or .mm file
  defines is visible only to that file, as isCppTranslationUnitLocal keeps
  a .c file's. Without it, ObjFW's calls of AmigaOS's Lock(path, mode)
  linked to the runtime's private struct Lock in synchronized.m. A class
  stays visible: it is the runtime's, wherever it is written.

The walk also recovers a typedef written right after a line holding only a
macro (OF_ASSUME_NONNULL_BEGIN, RCT_EXTERN_C_BEGIN), which the parser reads
as a declaration of a variable: ObjFW's public enums with their values,
and React Native's RCTMethodInfo, were missing. Objective-C has no kernel
walker, so the kernel is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 00:03:37 +00:00
..