Compare commits

...
Author SHA1 Message Date
Gergo Magyar 39628adeea Merge remote-tracking branch 'origin/main' into fix/csharp-query-node-types 2026-03-09 12:48:58 +00:00
jiangnan acda87a247 test(csharp): remove try/catch that masked query compilation failures
The C# integration test wrapped parseAndQuery in a try/catch that
accepted TSQueryError as a passing condition. This meant the broken
simple_base_type query compiled, failed silently, and the test still
passed — hiding the fact that zero C# symbols were being extracted.

Removed the try/catch so query compilation errors are caught by CI.
Also added specific assertions for class, method, and namespace
extraction from the C# fixture.
2026-03-07 08:47:58 +08:00
jiangnan 8ca25fe753 fix(csharp): remove invalid simple_base_type from heritage queries
tree-sitter-c-sharp v0.21 does not have a simple_base_type node in
base_list — identifiers appear directly under base_list. The invalid
node type caused the entire CSHARP_QUERIES to fail at query compilation
time (TSQueryErrorNodeType), which meant processFileGroup silently
returned early and no C# symbols were extracted at all.

Fixes #173
2026-03-07 08:47:58 +08:00
2 changed files with 17 additions and 19 deletions
@@ -282,9 +282,9 @@ export const CSHARP_QUERIES = `
; Heritage
(class_declaration name: (identifier) @heritage.class
(base_list (simple_base_type (identifier) @heritage.extends))) @heritage
(base_list (identifier) @heritage.extends)) @heritage
(class_declaration name: (identifier) @heritage.class
(base_list (simple_base_type (generic_name (identifier) @heritage.extends)))) @heritage
(base_list (generic_name (identifier) @heritage.extends))) @heritage
`;
// Rust queries - works with tree-sitter-rust
@@ -150,17 +150,20 @@ describe('Tree-sitter multi-language parsing', () => {
});
describe('C#', () => {
it('parses class, method, and property declarations', async () => {
it('parses class, method, and namespace declarations', async () => {
await loadLanguage(SupportedLanguages.CSharp);
const content = readFixture('simple.cs');
try {
const { matches } = parseAndQuery(parser, content, LANGUAGE_QUERIES[SupportedLanguages.CSharp]);
const defs = extractDefinitions(matches);
expect(defs.length).toBeGreaterThan(0);
} catch (e: any) {
// Some tree-sitter-c-sharp versions don't support all query node types
expect(e.message).toContain('TSQueryError');
}
const { matches } = parseAndQuery(parser, content, LANGUAGE_QUERIES[SupportedLanguages.CSharp]);
const defs = extractDefinitions(matches);
expect(defs.length).toBeGreaterThan(0);
const defTypes = defs.map(d => d.type);
expect(defTypes).toContain('definition.class');
expect(defTypes).toContain('definition.method');
expect(defTypes).toContain('definition.namespace');
const names = defs.map(d => d.name);
expect(names).toContain('Calculator');
expect(names).toContain('Add');
});
});
@@ -252,14 +255,9 @@ describe('Tree-sitter multi-language parsing', () => {
for (const [lang, fixture, filePath] of langFixtures) {
await loadLanguage(lang, filePath || fixture);
const content = readFixture(fixture);
try {
const { matches } = parseAndQuery(parser, content, LANGUAGE_QUERIES[lang]);
const defs = extractDefinitions(matches);
expect(defs.length, `${lang} (${fixture}) should have definitions`).toBeGreaterThan(0);
} catch (e: any) {
// Some grammars may have query compatibility issues
if (!e.message?.includes('TSQueryError')) throw e;
}
const { matches } = parseAndQuery(parser, content, LANGUAGE_QUERIES[lang]);
const defs = extractDefinitions(matches);
expect(defs.length, `${lang} (${fixture}) should have definitions`).toBeGreaterThan(0);
}
});
});