gitnexus 1.6.6-rc.41 → 1.6.6-rc.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,4 +5,161 @@ export const cCallConfig = {
5
5
  };
6
6
  export const cppCallConfig = {
7
7
  language: SupportedLanguages.CPlusPlus,
8
+ extractLanguageCallSite(callNode) {
9
+ return extractCppOperatorCallSite(callNode);
10
+ },
8
11
  };
12
+ function extractCppOperatorCallSite(callNode) {
13
+ if (callNode.type !== 'binary_expression')
14
+ return null;
15
+ if (isPrimitiveOnlyBinaryOperatorCall(callNode))
16
+ return null;
17
+ const operator = callNode.childForFieldName('operator')?.text.trim();
18
+ // Keep the legacy DAG conservative: only simple identifier operands are
19
+ // modeled here. Complex expressions stay unresolved instead of guessed.
20
+ if (operator === '+') {
21
+ const left = callNode.childForFieldName('left');
22
+ const right = callNode.childForFieldName('right');
23
+ if (left?.type !== 'identifier' || right?.type !== 'identifier')
24
+ return null;
25
+ return {
26
+ calledName: 'operator+',
27
+ callForm: 'member',
28
+ receiverName: left.text,
29
+ argCount: 1,
30
+ };
31
+ }
32
+ if (operator === '<<') {
33
+ const right = callNode.childForFieldName('right');
34
+ if (right?.type !== 'identifier')
35
+ return null;
36
+ return {
37
+ calledName: 'operator<<',
38
+ callForm: 'free',
39
+ argCount: 2,
40
+ };
41
+ }
42
+ return null;
43
+ }
44
+ function isPrimitiveOnlyBinaryOperatorCall(callNode) {
45
+ const left = callNode.childForFieldName('left');
46
+ const right = callNode.childForFieldName('right');
47
+ if (left === null || right === null)
48
+ return false;
49
+ return isBuiltinOperatorOperand(left) && isBuiltinOperatorOperand(right);
50
+ }
51
+ function isBuiltinOperatorOperand(node) {
52
+ return isBuiltinOperatorType(inferCppOperatorOperandType(node));
53
+ }
54
+ function inferCppOperatorOperandType(node) {
55
+ const literalType = inferCppLiteralType(node);
56
+ if (literalType !== '')
57
+ return literalType;
58
+ if (node.type === 'identifier')
59
+ return lookupCppIdentifierType(node);
60
+ return '';
61
+ }
62
+ function inferCppLiteralType(node) {
63
+ if (node.type === 'number_literal')
64
+ return node.text.includes('.') ? 'double' : 'int';
65
+ if (node.type === 'char_literal')
66
+ return 'char';
67
+ if (node.type === 'true' || node.type === 'false')
68
+ return 'bool';
69
+ return '';
70
+ }
71
+ function lookupCppIdentifierType(identNode) {
72
+ const varName = identNode.text;
73
+ let scope = identNode.parent;
74
+ while (scope !== null &&
75
+ scope.type !== 'compound_statement' &&
76
+ scope.type !== 'translation_unit') {
77
+ scope = scope.parent;
78
+ }
79
+ if (scope === null)
80
+ return '';
81
+ const parameterType = lookupCppFunctionParameterType(scope, varName);
82
+ if (parameterType !== '')
83
+ return parameterType;
84
+ for (let i = 0; i < scope.childCount; i++) {
85
+ const stmt = scope.child(i);
86
+ if (stmt === null || stmt.type !== 'declaration')
87
+ continue;
88
+ const typeNode = stmt.childForFieldName('type');
89
+ const declarator = stmt.childForFieldName('declarator');
90
+ if (typeNode === null || declarator === null)
91
+ continue;
92
+ if (extractDeclaratorLeafName(declarator) === varName)
93
+ return normalizeCppTypeText(typeNode.text);
94
+ }
95
+ return '';
96
+ }
97
+ function lookupCppFunctionParameterType(scope, varName) {
98
+ let node = scope.parent;
99
+ while (node !== null) {
100
+ if (node.type === 'function_definition' || node.type === 'function_declarator') {
101
+ const fnDecl = node.type === 'function_declarator'
102
+ ? node
103
+ : findFirstDescendantOfType(node, 'function_declarator');
104
+ const params = fnDecl?.childForFieldName('parameters') ?? null;
105
+ if (params === null)
106
+ return '';
107
+ for (let i = 0; i < params.namedChildCount; i++) {
108
+ const param = params.namedChild(i);
109
+ if (param === null || param.type !== 'parameter_declaration')
110
+ continue;
111
+ const declarator = param.childForFieldName('declarator');
112
+ const typeNode = param.childForFieldName('type');
113
+ if (declarator !== null &&
114
+ typeNode !== null &&
115
+ extractDeclaratorLeafName(declarator) === varName) {
116
+ return normalizeCppTypeText(typeNode.text);
117
+ }
118
+ }
119
+ return '';
120
+ }
121
+ node = node.parent;
122
+ }
123
+ return '';
124
+ }
125
+ function findFirstDescendantOfType(node, type) {
126
+ if (node.type === type)
127
+ return node;
128
+ for (let i = 0; i < node.namedChildCount; i++) {
129
+ const found = findFirstDescendantOfType(node.namedChild(i), type);
130
+ if (found !== null)
131
+ return found;
132
+ }
133
+ return null;
134
+ }
135
+ function extractDeclaratorLeafName(node) {
136
+ if (node.type === 'identifier' ||
137
+ node.type === 'field_identifier' ||
138
+ node.type === 'operator_name') {
139
+ return node.text;
140
+ }
141
+ const named = node.namedChildren;
142
+ for (let i = named.length - 1; i >= 0; i--) {
143
+ const name = extractDeclaratorLeafName(named[i]);
144
+ if (name !== '')
145
+ return name;
146
+ }
147
+ return '';
148
+ }
149
+ function normalizeCppTypeText(text) {
150
+ return text
151
+ .replace(/\b(const|volatile|static|extern|register|mutable|inline|constexpr)\b/g, ' ')
152
+ .replace(/\s+/g, ' ')
153
+ .trim();
154
+ }
155
+ function isBuiltinOperatorType(type) {
156
+ return (type === 'bool' ||
157
+ type === 'char' ||
158
+ type === 'double' ||
159
+ type === 'float' ||
160
+ type === 'int' ||
161
+ type === 'long' ||
162
+ type === 'short' ||
163
+ type === 'signed' ||
164
+ type === 'unsigned');
165
+ }
@@ -194,6 +194,7 @@ const cCppExtractFunctionName = (node) => {
194
194
  if (c?.type === 'qualified_identifier' ||
195
195
  c?.type === 'identifier' ||
196
196
  c?.type === 'field_identifier' ||
197
+ c?.type === 'operator_name' ||
197
198
  c?.type === 'parenthesized_declarator') {
198
199
  innerDeclarator = c;
199
200
  break;
@@ -205,7 +206,7 @@ const cCppExtractFunctionName = (node) => {
205
206
  if (!nameNode) {
206
207
  for (let i = 0; i < innerDeclarator.childCount; i++) {
207
208
  const c = innerDeclarator.child(i);
208
- if (c?.type === 'identifier') {
209
+ if (c?.type === 'identifier' || c?.type === 'operator_name') {
209
210
  nameNode = c;
210
211
  break;
211
212
  }
@@ -217,7 +218,8 @@ const cCppExtractFunctionName = (node) => {
217
218
  }
218
219
  }
219
220
  else if (innerDeclarator?.type === 'identifier' ||
220
- innerDeclarator?.type === 'field_identifier') {
221
+ innerDeclarator?.type === 'field_identifier' ||
222
+ innerDeclarator?.type === 'operator_name') {
221
223
  // field_identifier is used for method names inside C++ class bodies
222
224
  funcName = innerDeclarator.text;
223
225
  if (innerDeclarator.type === 'field_identifier')
@@ -237,7 +239,7 @@ const cCppExtractFunctionName = (node) => {
237
239
  if (!nameNode) {
238
240
  for (let i = 0; i < nestedId.childCount; i++) {
239
241
  const c = nestedId.child(i);
240
- if (c?.type === 'identifier') {
242
+ if (c?.type === 'identifier' || c?.type === 'operator_name') {
241
243
  nameNode = c;
242
244
  break;
243
245
  }
@@ -135,11 +135,26 @@ export function emitCppScopeCaptures(sourceText, filePath, cachedTree) {
135
135
  const callAnchor = grouped['@reference.call.free'] ??
136
136
  grouped['@reference.call.member'] ??
137
137
  grouped['@reference.call.qualified'];
138
+ const operatorAnchor = grouped['@reference.operator'];
139
+ if (operatorAnchor !== undefined) {
140
+ const operatorNode = callAnchor !== undefined
141
+ ? findNodeAtRange(tree.rootNode, callAnchor.range, 'binary_expression')
142
+ : null;
143
+ if (operatorNode !== null && isPrimitiveOnlyBinaryOperator(operatorNode))
144
+ continue;
145
+ }
138
146
  if (callAnchor !== undefined && grouped['@reference.arity'] === undefined) {
139
- const callNode = findNodeAtRange(tree.rootNode, callAnchor.range, 'call_expression');
140
- if (callNode !== null) {
147
+ const callNode = findNodeAtRange(tree.rootNode, callAnchor.range, 'call_expression') ??
148
+ findNodeAtRange(tree.rootNode, callAnchor.range, 'binary_expression');
149
+ if (callNode?.type === 'call_expression') {
141
150
  grouped['@reference.arity'] = syntheticCapture('@reference.arity', callNode, String(computeCppCallArity(callNode)));
142
151
  }
152
+ else if (callNode?.type === 'binary_expression') {
153
+ grouped['@reference.arity'] = syntheticCapture('@reference.arity', callNode, grouped['@reference.call.member'] !== undefined ? '1' : '2');
154
+ }
155
+ }
156
+ if (operatorAnchor !== undefined && grouped['@reference.name'] === undefined) {
157
+ grouped['@reference.name'] = syntheticCapture('@reference.name', findNodeAtRange(tree.rootNode, operatorAnchor.range, operatorAnchor.text) ?? tree.rootNode, `operator${operatorAnchor.text}`);
143
158
  }
144
159
  // ── Enrich constructor calls (new Foo()) with arity ─────────────
145
160
  const ctorCallAnchor = grouped['@reference.call.constructor'];
@@ -153,13 +168,18 @@ export function emitCppScopeCaptures(sourceText, filePath, cachedTree) {
153
168
  const anyCallAnchor = callAnchor ?? ctorCallAnchor;
154
169
  if (anyCallAnchor !== undefined && grouped['@reference.parameter-types'] === undefined) {
155
170
  const cNode = findNodeAtRange(tree.rootNode, anyCallAnchor.range, 'call_expression') ??
156
- findNodeAtRange(tree.rootNode, anyCallAnchor.range, 'new_expression');
171
+ findNodeAtRange(tree.rootNode, anyCallAnchor.range, 'new_expression') ??
172
+ findNodeAtRange(tree.rootNode, anyCallAnchor.range, 'binary_expression');
157
173
  if (cNode !== null) {
158
- const argTypes = inferCppCallArgTypes(cNode);
174
+ const argTypes = cNode.type === 'binary_expression'
175
+ ? inferCppBinaryOperatorArgTypes(cNode, grouped['@reference.call.free'] !== undefined)
176
+ : inferCppCallArgTypes(cNode);
159
177
  if (argTypes !== undefined && argTypes.length > 0) {
160
178
  grouped['@reference.parameter-types'] = syntheticCapture('@reference.parameter-types', cNode, JSON.stringify(argTypes));
161
179
  }
162
- const argTypeClasses = inferCppCallArgTypeClasses(cNode);
180
+ const argTypeClasses = cNode.type === 'binary_expression'
181
+ ? inferCppBinaryOperatorArgTypeClasses(cNode, grouped['@reference.call.free'] !== undefined)
182
+ : inferCppCallArgTypeClasses(cNode);
163
183
  if (argTypeClasses !== undefined && argTypeClasses.length > 0) {
164
184
  grouped['@reference.parameter-type-classes'] = syntheticCapture('@reference.parameter-type-classes', cNode, JSON.stringify(argTypeClasses));
165
185
  }
@@ -640,6 +660,62 @@ function inferCppCallArgTypeClasses(node) {
640
660
  }
641
661
  return classes.length > 0 ? classes : undefined;
642
662
  }
663
+ function inferCppBinaryOperatorArgTypes(node, includeLeftOperand) {
664
+ const operands = binaryOperatorOperands(node, includeLeftOperand);
665
+ if (operands.length === 0)
666
+ return undefined;
667
+ const types = operands.map(inferCppExpressionType);
668
+ return types.length > 0 ? types : undefined;
669
+ }
670
+ function inferCppBinaryOperatorArgTypeClasses(node, includeLeftOperand) {
671
+ const operands = binaryOperatorOperands(node, includeLeftOperand);
672
+ if (operands.length === 0)
673
+ return undefined;
674
+ const classes = operands.map(inferCppExpressionTypeClass);
675
+ return classes.length > 0 ? classes : undefined;
676
+ }
677
+ function binaryOperatorOperands(node, includeLeftOperand) {
678
+ const operands = [];
679
+ const left = node.childForFieldName('left');
680
+ const right = node.childForFieldName('right');
681
+ if (includeLeftOperand && left !== null)
682
+ operands.push(left);
683
+ if (right !== null)
684
+ operands.push(right);
685
+ return operands;
686
+ }
687
+ function isPrimitiveOnlyBinaryOperator(node) {
688
+ const operands = binaryOperatorOperands(node, true);
689
+ return operands.length > 0 && operands.every((operand) => isBuiltinOperatorType(operand));
690
+ }
691
+ function isBuiltinOperatorType(node) {
692
+ const type = inferCppExpressionType(node);
693
+ return (type === 'bool' ||
694
+ type === 'char' ||
695
+ type === 'double' ||
696
+ type === 'float' ||
697
+ type === 'int' ||
698
+ type === 'long' ||
699
+ type === 'short' ||
700
+ type === 'signed' ||
701
+ type === 'unsigned');
702
+ }
703
+ function inferCppExpressionType(node) {
704
+ const litType = inferCppLiteralType(node);
705
+ if (litType !== '')
706
+ return litType;
707
+ if (node.type === 'identifier')
708
+ return lookupDeclaredTypeForIdentifier(node);
709
+ return '';
710
+ }
711
+ function inferCppExpressionTypeClass(node) {
712
+ const litType = inferCppLiteralType(node);
713
+ if (litType !== '')
714
+ return valueTypeClass(litType);
715
+ if (node.type === 'identifier')
716
+ return lookupDeclaredTypeClassForIdentifier(node);
717
+ return unknownTypeClass('unknown');
718
+ }
643
719
  function valueTypeClass(base) {
644
720
  return { base, cv: 'none', indirection: 'value', pointerDepth: 0 };
645
721
  }
@@ -97,6 +97,12 @@ const CPP_SCOPE_QUERY = `
97
97
  declarator: (qualified_identifier
98
98
  name: (identifier) @declaration.name))) @declaration.method
99
99
 
100
+ ;; Out-of-class operator method: Point::operator+(...)
101
+ (function_definition
102
+ declarator: (function_declarator
103
+ declarator: (qualified_identifier
104
+ name: (operator_name) @declaration.name))) @declaration.method
105
+
100
106
  ;; ─── Declarations — out-of-class method with pointer return ─────────
101
107
  (function_definition
102
108
  declarator: (pointer_declarator
@@ -129,6 +135,11 @@ const CPP_SCOPE_QUERY = `
129
135
  declarator: (function_declarator
130
136
  declarator: (field_identifier) @declaration.name)) @declaration.method
131
137
 
138
+ ;; Inline operator method in class body: Point operator+(Point) const { ... }
139
+ (function_definition
140
+ declarator: (function_declarator
141
+ declarator: (operator_name) @declaration.name)) @declaration.method
142
+
132
143
  ;; ─── Declarations — inline method with pointer return (field_identifier) ──
133
144
  ;; Covers: User* lookup(int id) { ... } inside a class body
134
145
  ;; AST: function_definition > pointer_declarator > function_declarator > field_identifier
@@ -144,17 +155,49 @@ const CPP_SCOPE_QUERY = `
144
155
  (function_declarator
145
156
  declarator: (field_identifier) @declaration.name))) @declaration.method
146
157
 
158
+ ;; Inline operator method with reference return: Point& operator+=(Point) { ... }
159
+ (field_declaration_list
160
+ (function_definition
161
+ declarator: (reference_declarator
162
+ (function_declarator
163
+ declarator: (operator_name) @declaration.name))) @declaration.method)
164
+
165
+ ;; Free operator definition with reference return: std::ostream& operator<<(...) { ... }
166
+ (translation_unit
167
+ (function_definition
168
+ declarator: (reference_declarator
169
+ (function_declarator
170
+ declarator: (operator_name) @declaration.name))) @declaration.function)
171
+
172
+ (namespace_definition
173
+ body: (declaration_list
174
+ (function_definition
175
+ declarator: (reference_declarator
176
+ (function_declarator
177
+ declarator: (operator_name) @declaration.name))) @declaration.function))
178
+
147
179
  ;; ─── Declarations — function prototype (forward declaration) ────────
148
180
  (declaration
149
181
  declarator: (function_declarator
150
182
  declarator: (identifier) @declaration.name)) @declaration.function
151
183
 
184
+ ;; Free operator prototype: std::ostream& operator<<(std::ostream&, T)
185
+ (declaration
186
+ declarator: (function_declarator
187
+ declarator: (operator_name) @declaration.name)) @declaration.function
188
+
152
189
  ;; ─── Declarations — function prototype with pointer return ──────────
153
190
  (declaration
154
191
  declarator: (pointer_declarator
155
192
  declarator: (function_declarator
156
193
  declarator: (identifier) @declaration.name))) @declaration.function
157
194
 
195
+ ;; Free operator prototype with reference return.
196
+ (declaration
197
+ declarator: (reference_declarator
198
+ (function_declarator
199
+ declarator: (operator_name) @declaration.name))) @declaration.function
200
+
158
201
  ;; ─── Declarations — typedef ─────────────────────────────────────────
159
202
  (type_definition
160
203
  declarator: (type_identifier) @declaration.name) @declaration.typedef
@@ -170,6 +213,11 @@ const CPP_SCOPE_QUERY = `
170
213
  declarator: (function_declarator
171
214
  declarator: (field_identifier) @declaration.name)) @declaration.method
172
215
 
216
+ ;; Operator method prototype in class body: Point operator+(Point) const;
217
+ (field_declaration
218
+ declarator: (function_declarator
219
+ declarator: (operator_name) @declaration.name)) @declaration.method
220
+
173
221
  ;; Method prototype with pointer return: User* lookup(int id);
174
222
  (field_declaration
175
223
  declarator: (pointer_declarator
@@ -182,6 +230,11 @@ const CPP_SCOPE_QUERY = `
182
230
  (function_declarator
183
231
  declarator: (field_identifier) @declaration.name))) @declaration.method
184
232
 
233
+ (field_declaration
234
+ declarator: (reference_declarator
235
+ (function_declarator
236
+ declarator: (operator_name) @declaration.name))) @declaration.method
237
+
185
238
  ;; ─── Declarations — fields ──────────────────────────────────────────
186
239
  (field_declaration
187
240
  declarator: (field_identifier) @declaration.name) @declaration.field
@@ -472,6 +525,22 @@ const CPP_SCOPE_QUERY = `
472
525
  argument: (_) @reference.receiver
473
526
  field: (field_identifier) @reference.name)) @reference.call.member
474
527
 
528
+ ;; Conservative operator-call support (#1636): model a + b as a
529
+ ;; member-style operator+ lookup, and lhs << rhs as a free
530
+ ;; operator<< lookup. Free operator+(T,T), member operator<<, and
531
+ ;; complex operand expressions remain false negatives for now.
532
+ ;; Built-in operators remain unresolved because no user-defined
533
+ ;; operator target exists.
534
+ (binary_expression
535
+ left: (_) @reference.receiver
536
+ operator: "+" @reference.operator
537
+ right: (_)) @reference.call.member
538
+
539
+ (binary_expression
540
+ left: (_)
541
+ operator: "<<" @reference.operator
542
+ right: (_)) @reference.call.free
543
+
475
544
  ;; ─── References — template calls (func<T>()) ────────────────────────
476
545
  (call_expression
477
546
  function: (template_function
@@ -812,6 +812,7 @@ const KNOWN_SUB_TAGS = new Set([
812
812
  '@type-binding.type',
813
813
  '@reference.name',
814
814
  '@reference.receiver',
815
+ '@reference.operator',
815
816
  '@reference.arity',
816
817
  '@reference.parameter-types',
817
818
  '@reference.parameter-type-classes',
@@ -4,7 +4,7 @@ export declare const PYTHON_QUERIES = "\n(class_definition\n name: (identifier)
4
4
  export declare const JAVA_QUERIES = "\n; Classes, Interfaces, Enums, Annotations\n(class_declaration name: (identifier) @name) @definition.class\n(interface_declaration name: (identifier) @name) @definition.interface\n(enum_declaration name: (identifier) @name) @definition.enum\n(annotation_type_declaration name: (identifier) @name) @definition.annotation\n\n; Methods & Constructors\n(method_declaration name: (identifier) @name) @definition.method\n(constructor_declaration name: (identifier) @name) @definition.constructor\n\n; Fields \u2014 typed field declarations inside class bodies\n(field_declaration\n declarator: (variable_declarator\n name: (identifier) @name)) @definition.property\n\n; Imports - capture any import declaration child as source\n(import_declaration (_) @import.source) @import\n\n; Calls\n(method_invocation name: (identifier) @call.name) @call\n(method_invocation object: (_) name: (identifier) @call.name) @call\n(method_reference) @call\n\n; Constructor calls: new Foo()\n(object_creation_expression type: (type_identifier) @call.name) @call\n\n; Local variable declarations inside method bodies\n(local_variable_declaration\n declarator: (variable_declarator\n name: (identifier) @name)) @definition.variable\n\n; Heritage - extends class\n(class_declaration name: (identifier) @heritage.class\n (superclass (type_identifier) @heritage.extends)) @heritage\n\n; Heritage - implements interfaces\n(class_declaration name: (identifier) @heritage.class\n (super_interfaces (type_list (type_identifier) @heritage.implements))) @heritage.impl\n\n; Write access: obj.field = value\n(assignment_expression\n left: (field_access\n object: (_) @assignment.receiver\n field: (identifier) @assignment.property)\n right: (_)) @assignment\n";
5
5
  export declare const C_QUERIES = "\n; Functions (direct declarator)\n(function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n(declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n\n; Functions returning pointers (pointer_declarator wraps function_declarator)\n(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n(declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n\n; Functions returning double pointers (nested pointer_declarator)\n(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function\n\n; Structs, Unions, Enums, Typedefs\n(struct_specifier name: (type_identifier) @name) @definition.struct\n(union_specifier name: (type_identifier) @name) @definition.union\n(enum_specifier name: (type_identifier) @name) @definition.enum\n(type_definition declarator: (type_identifier) @name) @definition.typedef\n\n; Macros\n(preproc_function_def name: (identifier) @name) @definition.macro\n(preproc_def name: (identifier) @name) @definition.macro\n\n; Includes\n(preproc_include path: (_) @import.source) @import\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n(call_expression function: (field_expression field: (field_identifier) @call.name)) @call\n\n; Variable declarations: int x = 5; or int x;\n(declaration\n declarator: (init_declarator\n declarator: (identifier) @name)) @definition.variable\n";
6
6
  export declare const GO_QUERIES = "\n; Functions & Methods\n(function_declaration name: (identifier) @name) @definition.function\n(method_declaration name: (field_identifier) @name) @definition.method\n\n; Types\n(type_declaration (type_spec name: (type_identifier) @name type: (struct_type))) @definition.struct\n(type_declaration (type_spec name: (type_identifier) @name type: (interface_type))) @definition.interface\n\n; Imports\n(import_declaration (import_spec path: (interpreted_string_literal) @import.source)) @import\n(import_declaration (import_spec_list (import_spec path: (interpreted_string_literal) @import.source))) @import\n\n; Struct fields \u2014 named field declarations inside struct types\n(field_declaration_list\n (field_declaration\n name: (field_identifier) @name) @definition.property)\n\n; Struct embedding (anonymous fields = inheritance)\n(type_declaration\n (type_spec\n name: (type_identifier) @heritage.class\n type: (struct_type\n (field_declaration_list\n (field_declaration\n type: (type_identifier) @heritage.extends))))) @definition.struct\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n(call_expression function: (selector_expression field: (field_identifier) @call.name)) @call\n\n; Const/var declarations\n(const_declaration (const_spec name: (identifier) @name)) @definition.const\n(var_declaration (var_spec name: (identifier) @name)) @definition.variable\n\n; Short variable declaration: x := 5\n(short_var_declaration left: (expression_list (identifier) @name)) @definition.variable\n\n; Struct literal construction: User{Name: \"Alice\"}\n(composite_literal type: (type_identifier) @call.name) @call\n\n; Write access: obj.field = value\n(assignment_statement\n left: (expression_list\n (selector_expression\n operand: (_) @assignment.receiver\n field: (field_identifier) @assignment.property))\n right: (_)) @assignment\n\n; Write access: obj.field++ / obj.field--\n(inc_statement\n (selector_expression\n operand: (_) @assignment.receiver\n field: (field_identifier) @assignment.property)) @assignment\n(dec_statement\n (selector_expression\n operand: (_) @assignment.receiver\n field: (field_identifier) @assignment.property)) @assignment\n";
7
- export declare const CPP_QUERIES = "\n; Classes, Structs, Namespaces\n(class_specifier name: (type_identifier) @name) @definition.class\n(class_specifier\n name: (template_type\n (type_identifier) @name\n (template_argument_list) @template-arguments)) @definition.class\n(struct_specifier name: (type_identifier) @name) @definition.struct\n(struct_specifier\n name: (template_type\n (type_identifier) @name\n (template_argument_list) @template-arguments)) @definition.struct\n(namespace_definition name: (namespace_identifier) @name) @definition.namespace\n(enum_specifier name: (type_identifier) @name) @definition.enum\n\n; Typedefs and unions (common in C-style headers and mixed C/C++ code)\n(type_definition declarator: (type_identifier) @name) @definition.typedef\n(union_specifier name: (type_identifier) @name) @definition.union\n\n; Macros\n(preproc_function_def name: (identifier) @name) @definition.macro\n(preproc_def name: (identifier) @name) @definition.macro\n\n; Functions & Methods (direct declarator)\n(function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n(function_definition declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))) @definition.method\n\n; Functions/methods returning pointers (pointer_declarator wraps function_declarator)\n(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method\n\n; Functions/methods returning double pointers (nested pointer_declarator)\n(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function\n(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))))) @definition.method\n\n; Functions/methods returning references (reference_declarator wraps function_declarator)\n(function_definition declarator: (reference_declarator (function_declarator declarator: (identifier) @name))) @definition.function\n(function_definition declarator: (reference_declarator (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method\n\n; Destructors (destructor_name is distinct from identifier in tree-sitter-cpp)\n(function_definition declarator: (function_declarator declarator: (qualified_identifier name: (destructor_name) @name))) @definition.method\n\n; Function declarations / prototypes (common in headers)\n(declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n(declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n\n; Class/struct data member fields (Address address; int count;)\n; Uses field_identifier to exclude method declarations (which use function_declarator)\n(field_declaration\n declarator: (field_identifier) @name) @definition.property\n\n; Pointer member fields (Address* address;)\n(field_declaration\n declarator: (pointer_declarator\n declarator: (field_identifier) @name)) @definition.property\n\n; Reference member fields (Address& address;)\n(field_declaration\n declarator: (reference_declarator\n (field_identifier) @name)) @definition.property\n\n; Inline class method declarations (inside class body, no body: void save();)\n; tree-sitter-cpp uses field_identifier (not identifier) for names inside class bodies\n(field_declaration declarator: (function_declarator declarator: [(field_identifier) (identifier)] @name)) @definition.method\n\n; Inline class method declarations returning a pointer (User* lookup();)\n(field_declaration declarator: (pointer_declarator declarator: (function_declarator declarator: [(field_identifier) (identifier)] @name))) @definition.method\n\n; Inline class method declarations returning a reference (User& lookup();)\n(field_declaration declarator: (reference_declarator (function_declarator declarator: [(field_identifier) (identifier)] @name))) @definition.method\n\n; Inline class method definitions (inside class body, with body: void Foo() { ... })\n(field_declaration_list\n (function_definition\n declarator: (function_declarator\n declarator: [(field_identifier) (identifier) (operator_name) (destructor_name)] @name)) @definition.method)\n\n; Inline class methods returning a pointer type (User* lookup(int id) { ... })\n(field_declaration_list\n (function_definition\n declarator: (pointer_declarator\n declarator: (function_declarator\n declarator: [(field_identifier) (identifier) (operator_name)] @name))) @definition.method)\n\n; Inline class methods returning a reference type (User& lookup(int id) { ... })\n(field_declaration_list\n (function_definition\n declarator: (reference_declarator\n (function_declarator\n declarator: [(field_identifier) (identifier) (operator_name)] @name))) @definition.method)\n\n; Templates\n(template_declaration (class_specifier name: (type_identifier) @name)) @definition.template\n(template_declaration\n (class_specifier\n name: (template_type\n (type_identifier) @name\n (template_argument_list) @template-arguments))) @definition.template\n(template_declaration (function_definition declarator: (function_declarator declarator: (identifier) @name))) @definition.template\n\n; Includes\n(preproc_include path: (_) @import.source) @import\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n(call_expression function: (field_expression field: (field_identifier) @call.name)) @call\n(call_expression function: (qualified_identifier name: (identifier) @call.name)) @call\n(call_expression function: (template_function name: (identifier) @call.name)) @call\n\n; Constructor calls: new User()\n(new_expression type: (type_identifier) @call.name) @call\n\n; Variable declarations: int x = 5; or auto x = 5;\n(declaration\n declarator: (init_declarator\n declarator: (identifier) @name)) @definition.variable\n\n; Heritage\n(class_specifier name: (type_identifier) @heritage.class\n (base_class_clause (type_identifier) @heritage.extends)) @heritage\n(class_specifier name: (type_identifier) @heritage.class\n (base_class_clause (access_specifier) (type_identifier) @heritage.extends)) @heritage\n\n; Write access: obj.field = value\n(assignment_expression\n left: (field_expression\n argument: (_) @assignment.receiver\n field: (field_identifier) @assignment.property)\n right: (_)) @assignment\n\n";
7
+ export declare const CPP_QUERIES = "\n; Classes, Structs, Namespaces\n(class_specifier name: (type_identifier) @name) @definition.class\n(class_specifier\n name: (template_type\n (type_identifier) @name\n (template_argument_list) @template-arguments)) @definition.class\n(struct_specifier name: (type_identifier) @name) @definition.struct\n(struct_specifier\n name: (template_type\n (type_identifier) @name\n (template_argument_list) @template-arguments)) @definition.struct\n(namespace_definition name: (namespace_identifier) @name) @definition.namespace\n(enum_specifier name: (type_identifier) @name) @definition.enum\n\n; Typedefs and unions (common in C-style headers and mixed C/C++ code)\n(type_definition declarator: (type_identifier) @name) @definition.typedef\n(union_specifier name: (type_identifier) @name) @definition.union\n\n; Macros\n(preproc_function_def name: (identifier) @name) @definition.macro\n(preproc_def name: (identifier) @name) @definition.macro\n\n; Functions & Methods (direct declarator)\n(function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n(function_definition declarator: (function_declarator declarator: (operator_name) @name)) @definition.function\n(function_definition declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))) @definition.method\n(function_definition declarator: (function_declarator declarator: (qualified_identifier name: (operator_name) @name))) @definition.method\n\n; Functions/methods returning pointers (pointer_declarator wraps function_declarator)\n(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n(function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method\n\n; Functions/methods returning double pointers (nested pointer_declarator)\n(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name)))) @definition.function\n(function_definition declarator: (pointer_declarator declarator: (pointer_declarator declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))))) @definition.method\n\n; Functions/methods returning references (reference_declarator wraps function_declarator)\n(function_definition declarator: (reference_declarator (function_declarator declarator: (identifier) @name))) @definition.function\n(function_definition declarator: (reference_declarator (function_declarator declarator: (operator_name) @name))) @definition.function\n(function_definition declarator: (reference_declarator (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method\n(function_definition declarator: (reference_declarator (function_declarator declarator: (qualified_identifier name: (operator_name) @name)))) @definition.method\n\n; Destructors (destructor_name is distinct from identifier in tree-sitter-cpp)\n(function_definition declarator: (function_declarator declarator: (qualified_identifier name: (destructor_name) @name))) @definition.method\n\n; Function declarations / prototypes (common in headers)\n(declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function\n(declaration declarator: (function_declarator declarator: (operator_name) @name)) @definition.function\n(declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function\n(declaration declarator: (reference_declarator (function_declarator declarator: (operator_name) @name))) @definition.function\n\n; Class/struct data member fields (Address address; int count;)\n; Uses field_identifier to exclude method declarations (which use function_declarator)\n(field_declaration\n declarator: (field_identifier) @name) @definition.property\n\n; Pointer member fields (Address* address;)\n(field_declaration\n declarator: (pointer_declarator\n declarator: (field_identifier) @name)) @definition.property\n\n; Reference member fields (Address& address;)\n(field_declaration\n declarator: (reference_declarator\n (field_identifier) @name)) @definition.property\n\n; Inline class method declarations (inside class body, no body: void save();)\n; tree-sitter-cpp uses field_identifier (not identifier) for names inside class bodies\n(field_declaration declarator: (function_declarator declarator: [(field_identifier) (identifier) (operator_name)] @name)) @definition.method\n\n; Inline class method declarations returning a pointer (User* lookup();)\n(field_declaration declarator: (pointer_declarator declarator: (function_declarator declarator: [(field_identifier) (identifier)] @name))) @definition.method\n\n; Inline class method declarations returning a reference (User& lookup();)\n(field_declaration declarator: (reference_declarator (function_declarator declarator: [(field_identifier) (identifier) (operator_name)] @name))) @definition.method\n\n; Inline class method definitions (inside class body, with body: void Foo() { ... })\n(field_declaration_list\n (function_definition\n declarator: (function_declarator\n declarator: [(field_identifier) (identifier) (operator_name) (destructor_name)] @name)) @definition.method)\n\n; Inline class methods returning a pointer type (User* lookup(int id) { ... })\n(field_declaration_list\n (function_definition\n declarator: (pointer_declarator\n declarator: (function_declarator\n declarator: [(field_identifier) (identifier) (operator_name)] @name))) @definition.method)\n\n; Inline class methods returning a reference type (User& lookup(int id) { ... })\n(field_declaration_list\n (function_definition\n declarator: (reference_declarator\n (function_declarator\n declarator: [(field_identifier) (identifier) (operator_name)] @name))) @definition.method)\n\n; Templates\n(template_declaration (class_specifier name: (type_identifier) @name)) @definition.template\n(template_declaration\n (class_specifier\n name: (template_type\n (type_identifier) @name\n (template_argument_list) @template-arguments))) @definition.template\n(template_declaration (function_definition declarator: (function_declarator declarator: (identifier) @name))) @definition.template\n\n; Includes\n(preproc_include path: (_) @import.source) @import\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n(call_expression function: (field_expression field: (field_identifier) @call.name)) @call\n(call_expression function: (qualified_identifier name: (identifier) @call.name)) @call\n(call_expression function: (template_function name: (identifier) @call.name)) @call\n(binary_expression operator: \"+\" @call.name) @call\n(binary_expression operator: \"<<\" @call.name) @call\n\n; Constructor calls: new User()\n(new_expression type: (type_identifier) @call.name) @call\n\n; Variable declarations: int x = 5; or auto x = 5;\n(declaration\n declarator: (init_declarator\n declarator: (identifier) @name)) @definition.variable\n\n; Heritage\n(class_specifier name: (type_identifier) @heritage.class\n (base_class_clause (type_identifier) @heritage.extends)) @heritage\n(class_specifier name: (type_identifier) @heritage.class\n (base_class_clause (access_specifier) (type_identifier) @heritage.extends)) @heritage\n\n; Write access: obj.field = value\n(assignment_expression\n left: (field_expression\n argument: (_) @assignment.receiver\n field: (field_identifier) @assignment.property)\n right: (_)) @assignment\n\n";
8
8
  export declare const CSHARP_QUERIES = "\n; Types\n(class_declaration name: (identifier) @name) @definition.class\n(interface_declaration name: (identifier) @name) @definition.interface\n(struct_declaration name: (identifier) @name) @definition.struct\n(enum_declaration name: (identifier) @name) @definition.enum\n(record_declaration name: (identifier) @name) @definition.record\n(delegate_declaration name: (identifier) @name) @definition.delegate\n\n; Namespaces (block form and C# 10+ file-scoped form)\n(namespace_declaration name: (identifier) @name) @definition.namespace\n(namespace_declaration name: (qualified_name) @name) @definition.namespace\n(file_scoped_namespace_declaration name: (identifier) @name) @definition.namespace\n(file_scoped_namespace_declaration name: (qualified_name) @name) @definition.namespace\n\n; Methods & Properties\n(method_declaration name: (identifier) @name) @definition.method\n(local_function_statement name: (identifier) @name) @definition.function\n(constructor_declaration name: (identifier) @name) @definition.constructor\n(property_declaration name: (identifier) @name) @definition.property\n\n; Primary constructors (C# 12): class User(string name, int age) { }\n(class_declaration name: (identifier) @name (parameter_list) @definition.constructor)\n(record_declaration name: (identifier) @name (parameter_list) @definition.constructor)\n\n; Using\n(using_directive (qualified_name) @import.source) @import\n(using_directive (identifier) @import.source) @import\n\n; Calls\n(invocation_expression function: (identifier) @call.name) @call\n(invocation_expression function: (member_access_expression name: (identifier) @call.name)) @call\n\n; Null-conditional method calls: user?.Save()\n; Parses as: invocation_expression \u2192 conditional_access_expression \u2192 member_binding_expression \u2192 identifier\n(invocation_expression\n function: (conditional_access_expression\n (member_binding_expression\n (identifier) @call.name))) @call\n\n; Constructor calls: new Foo() and new Foo { Props }\n(object_creation_expression type: (identifier) @call.name) @call\n\n; Target-typed new (C# 9): User u = new(\"x\", 5)\n(variable_declaration type: (identifier) @call.name (variable_declarator (implicit_object_creation_expression) @call))\n\n; Local variable declarations\n(local_declaration_statement\n (variable_declaration\n (variable_declarator\n (identifier) @name))) @definition.variable\n\n; Heritage\n(class_declaration name: (identifier) @heritage.class\n (base_list (identifier) @heritage.extends)) @heritage\n(class_declaration name: (identifier) @heritage.class\n (base_list (generic_name (identifier) @heritage.extends))) @heritage\n\n; Interface inheritance: interface IFoo : IBar / interface IFoo : IBar, IBaz\n; Without these patterns, interface-to-interface relationships are never\n; captured, so transitive \"class X implements IBar\" chains are broken.\n(interface_declaration name: (identifier) @heritage.class\n (base_list (identifier) @heritage.extends)) @heritage\n(interface_declaration name: (identifier) @heritage.class\n (base_list (generic_name (identifier) @heritage.extends))) @heritage\n\n; Write access: obj.field = value\n(assignment_expression\n left: (member_access_expression\n expression: (_) @assignment.receiver\n name: (identifier) @assignment.property)\n right: (_)) @assignment\n";
9
9
  export declare const RUST_QUERIES = "\n; Functions & Items\n(function_item name: (identifier) @name) @definition.function\n(function_signature_item name: (identifier) @name) @definition.function\n(struct_item name: (type_identifier) @name) @definition.struct\n(enum_item name: (type_identifier) @name) @definition.enum\n(trait_item name: (type_identifier) @name) @definition.trait\n(impl_item type: (type_identifier) @name !trait) @definition.impl\n(impl_item type: (generic_type type: (type_identifier) @name) !trait) @definition.impl\n(mod_item name: (identifier) @name) @definition.module\n\n; Type aliases, const, static, macros\n(type_item name: (type_identifier) @name) @definition.type\n(const_item name: (identifier) @name) @definition.const\n(static_item name: (identifier) @name) @definition.static\n(macro_definition name: (identifier) @name) @definition.macro\n\n; Use statements\n(use_declaration argument: (_) @import.source) @import\n\n; Calls\n(call_expression function: (identifier) @call.name) @call\n(call_expression function: (field_expression field: (field_identifier) @call.name)) @call\n(call_expression function: (scoped_identifier name: (identifier) @call.name)) @call\n(call_expression function: (generic_function function: (identifier) @call.name)) @call\n\n; Struct literal construction: User { name: value }\n(struct_expression name: (type_identifier) @call.name) @call\n\n; Struct fields \u2014 named field declarations inside struct bodies\n(field_declaration_list\n (field_declaration\n name: (field_identifier) @name) @definition.property)\n\n; Heritage (trait implementation) \u2014 all combinations of concrete/generic trait \u00D7 concrete/generic type\n(impl_item trait: (type_identifier) @heritage.trait type: (type_identifier) @heritage.class) @heritage\n(impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (type_identifier) @heritage.class) @heritage\n(impl_item trait: (type_identifier) @heritage.trait type: (generic_type type: (type_identifier) @heritage.class)) @heritage\n(impl_item trait: (generic_type type: (type_identifier) @heritage.trait) type: (generic_type type: (type_identifier) @heritage.class)) @heritage\n\n; Write access: obj.field = value\n(assignment_expression\n left: (field_expression\n value: (_) @assignment.receiver\n field: (field_identifier) @assignment.property)\n right: (_)) @assignment\n\n; Write access: obj.field += value (compound assignment)\n(compound_assignment_expr\n left: (field_expression\n value: (_) @assignment.receiver\n field: (field_identifier) @assignment.property)\n right: (_)) @assignment\n";
10
10
  export declare const PHP_QUERIES = "\n; \u2500\u2500 Namespace \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(namespace_definition\n name: (namespace_name) @name) @definition.namespace\n\n; \u2500\u2500 Classes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(class_declaration\n name: (name) @name) @definition.class\n\n; \u2500\u2500 Interfaces \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(interface_declaration\n name: (name) @name) @definition.interface\n\n; \u2500\u2500 Traits \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(trait_declaration\n name: (name) @name) @definition.trait\n\n; \u2500\u2500 Enums (PHP 8.1) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(enum_declaration\n name: (name) @name) @definition.enum\n\n; \u2500\u2500 Top-level functions \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(function_definition\n name: (name) @name) @definition.function\n\n; \u2500\u2500 Methods (including constructors) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(method_declaration\n name: (name) @name) @definition.method\n\n; \u2500\u2500 Class properties (including Eloquent $fillable, $casts, etc.) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(property_declaration\n (property_element\n (variable_name\n (name) @name))) @definition.property\n\n; Constructor property promotion (PHP 8.0+: public Address $address in __construct)\n(method_declaration\n parameters: (formal_parameters\n (property_promotion_parameter\n name: (variable_name\n (name) @name)))) @definition.property\n\n; \u2500\u2500 Imports: use statements \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n; Simple: use App\\Models\\User;\n(namespace_use_declaration\n (namespace_use_clause\n (qualified_name) @import.source)) @import\n\n; \u2500\u2500 Function/method calls \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n; Regular function call: foo()\n(function_call_expression\n function: (name) @call.name) @call\n\n; Method call: $obj->method()\n(member_call_expression\n name: (name) @call.name) @call\n\n; Nullsafe method call: $obj?->method()\n(nullsafe_member_call_expression\n name: (name) @call.name) @call\n\n; Static call: Foo::bar() (php_only uses scoped_call_expression)\n(scoped_call_expression\n name: (name) @call.name) @call\n\n; Constructor call: new User()\n(object_creation_expression (name) @call.name) @call\n\n; Const declarations at class scope\n(const_declaration\n (const_element\n (name) @name)) @definition.const\n\n; \u2500\u2500 Heritage: extends \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(class_declaration\n name: (name) @heritage.class\n (base_clause\n [(name) (qualified_name)] @heritage.extends)) @heritage\n\n; \u2500\u2500 Heritage: implements \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(class_declaration\n name: (name) @heritage.class\n (class_interface_clause\n [(name) (qualified_name)] @heritage.implements)) @heritage.impl\n\n; \u2500\u2500 Heritage: use trait (must capture enclosing class name) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n(class_declaration\n name: (name) @heritage.class\n body: (declaration_list\n (use_declaration\n [(name) (qualified_name)] @heritage.trait))) @heritage\n\n; \u2500\u2500 Heritage: trait uses another trait (transitive trait composition) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n; PHP allows a trait body to contain \"use OtherTrait;\". The trait-uses-trait\n; IMPLEMENTS edge is required by buildPhpMro to compute the full transitive\n; trait closure (depth 3+ chains).\n(trait_declaration\n name: (name) @heritage.class\n body: (declaration_list\n (use_declaration\n [(name) (qualified_name)] @heritage.trait))) @heritage\n\n; PHP HTTP consumers: file_get_contents('/path'), curl_init('/path')\n(function_call_expression\n function: (name) @_php_http (#match? @_php_http \"^(file_get_contents|curl_init)$\")\n arguments: (arguments\n (argument (string (string_content) @http_client.url)))) @http_client\n\n; Write access: $obj->field = value\n(assignment_expression\n left: (member_access_expression\n object: (_) @assignment.receiver\n name: (name) @assignment.property)\n right: (_)) @assignment\n\n; Write access: ClassName::$field = value (static property)\n(assignment_expression\n left: (scoped_property_access_expression\n scope: (_) @assignment.receiver\n name: (variable_name (name) @assignment.property))\n right: (_)) @assignment\n";
@@ -695,7 +695,9 @@ export const CPP_QUERIES = `
695
695
 
696
696
  ; Functions & Methods (direct declarator)
697
697
  (function_definition declarator: (function_declarator declarator: (identifier) @name)) @definition.function
698
+ (function_definition declarator: (function_declarator declarator: (operator_name) @name)) @definition.function
698
699
  (function_definition declarator: (function_declarator declarator: (qualified_identifier name: (identifier) @name))) @definition.method
700
+ (function_definition declarator: (function_declarator declarator: (qualified_identifier name: (operator_name) @name))) @definition.method
699
701
 
700
702
  ; Functions/methods returning pointers (pointer_declarator wraps function_declarator)
701
703
  (function_definition declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
@@ -707,14 +709,18 @@ export const CPP_QUERIES = `
707
709
 
708
710
  ; Functions/methods returning references (reference_declarator wraps function_declarator)
709
711
  (function_definition declarator: (reference_declarator (function_declarator declarator: (identifier) @name))) @definition.function
712
+ (function_definition declarator: (reference_declarator (function_declarator declarator: (operator_name) @name))) @definition.function
710
713
  (function_definition declarator: (reference_declarator (function_declarator declarator: (qualified_identifier name: (identifier) @name)))) @definition.method
714
+ (function_definition declarator: (reference_declarator (function_declarator declarator: (qualified_identifier name: (operator_name) @name)))) @definition.method
711
715
 
712
716
  ; Destructors (destructor_name is distinct from identifier in tree-sitter-cpp)
713
717
  (function_definition declarator: (function_declarator declarator: (qualified_identifier name: (destructor_name) @name))) @definition.method
714
718
 
715
719
  ; Function declarations / prototypes (common in headers)
716
720
  (declaration declarator: (function_declarator declarator: (identifier) @name)) @definition.function
721
+ (declaration declarator: (function_declarator declarator: (operator_name) @name)) @definition.function
717
722
  (declaration declarator: (pointer_declarator declarator: (function_declarator declarator: (identifier) @name))) @definition.function
723
+ (declaration declarator: (reference_declarator (function_declarator declarator: (operator_name) @name))) @definition.function
718
724
 
719
725
  ; Class/struct data member fields (Address address; int count;)
720
726
  ; Uses field_identifier to exclude method declarations (which use function_declarator)
@@ -733,13 +739,13 @@ export const CPP_QUERIES = `
733
739
 
734
740
  ; Inline class method declarations (inside class body, no body: void save();)
735
741
  ; tree-sitter-cpp uses field_identifier (not identifier) for names inside class bodies
736
- (field_declaration declarator: (function_declarator declarator: [(field_identifier) (identifier)] @name)) @definition.method
742
+ (field_declaration declarator: (function_declarator declarator: [(field_identifier) (identifier) (operator_name)] @name)) @definition.method
737
743
 
738
744
  ; Inline class method declarations returning a pointer (User* lookup();)
739
745
  (field_declaration declarator: (pointer_declarator declarator: (function_declarator declarator: [(field_identifier) (identifier)] @name))) @definition.method
740
746
 
741
747
  ; Inline class method declarations returning a reference (User& lookup();)
742
- (field_declaration declarator: (reference_declarator (function_declarator declarator: [(field_identifier) (identifier)] @name))) @definition.method
748
+ (field_declaration declarator: (reference_declarator (function_declarator declarator: [(field_identifier) (identifier) (operator_name)] @name))) @definition.method
743
749
 
744
750
  ; Inline class method definitions (inside class body, with body: void Foo() { ... })
745
751
  (field_declaration_list
@@ -778,6 +784,8 @@ export const CPP_QUERIES = `
778
784
  (call_expression function: (field_expression field: (field_identifier) @call.name)) @call
779
785
  (call_expression function: (qualified_identifier name: (identifier) @call.name)) @call
780
786
  (call_expression function: (template_function name: (identifier) @call.name)) @call
787
+ (binary_expression operator: "+" @call.name) @call
788
+ (binary_expression operator: "<<" @call.name) @call
781
789
 
782
790
  ; Constructor calls: new User()
783
791
  (new_expression type: (type_identifier) @call.name) @call
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.6-rc.41",
3
+ "version": "1.6.6-rc.42",
4
4
  "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
5
  "author": "Abhigyan Patwari",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",