Skip to content
Merged
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
11 changes: 5 additions & 6 deletions src/metricsAnalyzer/languages/csharpAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,15 +756,14 @@ export class CSharpMetricsAnalyzer {
* @returns The operator string or null if not found
*/
private getBinaryOperator(node: Parser.SyntaxNode): string | null {
// binary_expression structure: [left, operator, right] β€” operator always at index 1
// binary_expression structure: [left, operator, right] β€” operator always at index 1.
// In tree-sitter-c-sharp, anonymous operator tokens use their literal text as their node
// type (e.g. type === "&&"), so reading `.type` avoids a sourceText.substring allocation.
const operatorNode = node.child(1);
if (!operatorNode) { return null; }
const type = operatorNode.type;
if (type === "&&" || type === "||" || type === "binary_operator") {
return this.sourceText.substring(
operatorNode.startIndex,
operatorNode.endIndex
);
if (type === "&&" || type === "||") {
return type;
}
return null;
}
Expand Down