mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-29 06:46:49 +08:00
fix(objc): a doc comment inside an @implementation documents the method below it (#2696)
Inside an Objective-C @implementation, tree-sitter-objc wraps each method, function and declaration in an implementation_definition of its own, and the comment above it is the wrapper's sibling, not the method's. getPrecedingDocstring looked only at the method's own siblings, so no method, function or static written in an @implementation had its doc comment, while the same comment above an @interface property was read. - tree-sitter-helpers.ts: implementation_definition joins DOCSTRING_WRAPPER_TYPES. Each wraps exactly one item, so the climb cannot hand a comment to a neighbour: a comment above an @synthesize stays its own. - codegraph-kernel docstring.rs: the faithful port's wrapper list gains it too. The kernel does not walk Objective-C, so the entry only keeps the two lists alike. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
036832d3a7
commit
3273f20f47
@@ -87,8 +87,10 @@ export const BUILTIN_TYPE_NAMES: ReadonlySet<string> = new Set([
|
||||
* inner node, so before looking for its preceding comment we climb out through
|
||||
* these. Examples: `export class X {}` (export_statement), `@dec\ndef f()`
|
||||
* (decorated_definition), `const f = () => {}` (lexical_declaration →
|
||||
* variable_declarator). Each wraps exactly one declaration, so climbing can't
|
||||
* mis-attribute a comment to a sibling. (#780)
|
||||
* variable_declarator), and each method, function or declaration of an
|
||||
* Objective-C `@implementation` (implementation_definition). Each wraps
|
||||
* exactly one declaration, so climbing can't mis-attribute a comment to a
|
||||
* sibling. (#780)
|
||||
*/
|
||||
const DOCSTRING_WRAPPER_TYPES = new Set([
|
||||
'export_statement', // JS/TS: export class/function/const ...
|
||||
@@ -97,6 +99,7 @@ const DOCSTRING_WRAPPER_TYPES = new Set([
|
||||
'variable_declaration', // JS/TS: var x = ...
|
||||
'variable_declarator', // JS/TS: the `x = () => {}` inside the declaration
|
||||
'ambient_declaration', // TS: declare ...
|
||||
'implementation_definition', // ObjC: each method, function or declaration of an @implementation
|
||||
]);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user