Skip to content

Commit 57ebcfd

Browse files
authored
feat: add Solidity, Objective-C, CUDA, Groovy, Verilog language support (#729)
* feat: add Solidity, Objective-C, CUDA, Groovy, Verilog language support * fix: correct Solidity state variable kind and struct member collection (#729) - Change handleStateVarDecl to emit kind 'variable' instead of 'function' for state variables like `uint256 public totalSupply` - Fix inverted condition in handleStructDecl that prevented struct members from ever being collected * fix: resolve ObjC extractor name extraction for grammar compatibility (#729) The tree-sitter-objc grammar does not expose class/protocol names as named fields. Fall back to finding the first identifier child node when childForFieldName('name') returns null. * fix: resolve Verilog function/task name extraction and strengthen test assertions (#729) - Add findFunctionOrTaskName helper that searches for function_identifier and task_identifier node types used by the tree-sitter-verilog grammar - Remove duplicate handling of function_body_declaration/task_body_declaration from the walker to prevent double definitions - Replace trivially-passing toBeGreaterThanOrEqual(0) assertions with specific content checks for module instantiations and package imports
1 parent aadb536 commit 57ebcfd

15 files changed

Lines changed: 2130 additions & 2 deletions

File tree

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@
174174
"tree-sitter-ruby": "^0.23.1",
175175
"tree-sitter-rust": "^0.24.0",
176176
"tree-sitter-scala": "^0.24.0",
177+
"tree-sitter-solidity": "^1.2.13",
178+
"tree-sitter-objc": "^3.0.2",
179+
"tree-sitter-cuda": "^0.21.1",
180+
"tree-sitter-groovy": "^0.1.2",
181+
"tree-sitter-verilog": "^1.0.0",
177182
"tree-sitter-swift": "^0.7.1",
178183
"tree-sitter-typescript": "^0.23.2",
179184
"typescript": "^6.0.2",

scripts/build-wasm.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ const grammars = [
5252
{ name: 'tree-sitter-julia', pkg: 'tree-sitter-julia', sub: null },
5353
{ name: 'tree-sitter-r', pkg: '@eagleoutice/tree-sitter-r', sub: null },
5454
{ name: 'tree-sitter-erlang', pkg: 'tree-sitter-erlang', sub: null },
55+
{ name: 'tree-sitter-solidity', pkg: 'tree-sitter-solidity', sub: null },
56+
{ name: 'tree-sitter-objc', pkg: 'tree-sitter-objc', sub: null },
57+
{ name: 'tree-sitter-cuda', pkg: 'tree-sitter-cuda', sub: null },
58+
{ name: 'tree-sitter-groovy', pkg: 'tree-sitter-groovy', sub: null },
59+
{ name: 'tree-sitter-verilog', pkg: 'tree-sitter-verilog', sub: null },
5560
];
5661

5762
let failed = 0;

src/domain/parser.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,32 @@ export {
2121
extractCppSymbols,
2222
extractCSharpSymbols,
2323
extractCSymbols,
24+
extractCudaSymbols,
2425
extractDartSymbols,
2526
extractElixirSymbols,
2627
extractErlangSymbols,
2728
extractFSharpSymbols,
2829
extractGleamSymbols,
2930
extractGoSymbols,
31+
extractGroovySymbols,
3032
extractHaskellSymbols,
3133
extractHCLSymbols,
3234
extractJavaSymbols,
3335
extractJuliaSymbols,
3436
extractKotlinSymbols,
3537
extractLuaSymbols,
38+
extractObjCSymbols,
3639
extractOCamlSymbols,
3740
extractPHPSymbols,
3841
extractPythonSymbols,
3942
extractRSymbols,
4043
extractRubySymbols,
4144
extractRustSymbols,
4245
extractScalaSymbols,
46+
extractSoliditySymbols,
4347
extractSwiftSymbols,
4448
extractSymbols,
49+
extractVerilogSymbols,
4550
extractZigSymbols,
4651
} from '../extractors/index.js';
4752

@@ -51,27 +56,32 @@ import {
5156
extractCppSymbols,
5257
extractCSharpSymbols,
5358
extractCSymbols,
59+
extractCudaSymbols,
5460
extractDartSymbols,
5561
extractElixirSymbols,
5662
extractErlangSymbols,
5763
extractFSharpSymbols,
5864
extractGleamSymbols,
5965
extractGoSymbols,
66+
extractGroovySymbols,
6067
extractHaskellSymbols,
6168
extractHCLSymbols,
6269
extractJavaSymbols,
6370
extractJuliaSymbols,
6471
extractKotlinSymbols,
6572
extractLuaSymbols,
73+
extractObjCSymbols,
6674
extractOCamlSymbols,
6775
extractPHPSymbols,
6876
extractPythonSymbols,
6977
extractRSymbols,
7078
extractRubySymbols,
7179
extractRustSymbols,
7280
extractScalaSymbols,
81+
extractSoliditySymbols,
7382
extractSwiftSymbols,
7483
extractSymbols,
84+
extractVerilogSymbols,
7585
extractZigSymbols,
7686
} from '../extractors/index.js';
7787

@@ -588,6 +598,41 @@ export const LANGUAGE_REGISTRY: LanguageRegistryEntry[] = [
588598
extractor: extractErlangSymbols,
589599
required: false,
590600
},
601+
{
602+
id: 'solidity',
603+
extensions: ['.sol'],
604+
grammarFile: 'tree-sitter-solidity.wasm',
605+
extractor: extractSoliditySymbols,
606+
required: false,
607+
},
608+
{
609+
id: 'objc',
610+
extensions: ['.m'],
611+
grammarFile: 'tree-sitter-objc.wasm',
612+
extractor: extractObjCSymbols,
613+
required: false,
614+
},
615+
{
616+
id: 'cuda',
617+
extensions: ['.cu', '.cuh'],
618+
grammarFile: 'tree-sitter-cuda.wasm',
619+
extractor: extractCudaSymbols,
620+
required: false,
621+
},
622+
{
623+
id: 'groovy',
624+
extensions: ['.groovy', '.gvy'],
625+
grammarFile: 'tree-sitter-groovy.wasm',
626+
extractor: extractGroovySymbols,
627+
required: false,
628+
},
629+
{
630+
id: 'verilog',
631+
extensions: ['.v', '.sv'],
632+
grammarFile: 'tree-sitter-verilog.wasm',
633+
extractor: extractVerilogSymbols,
634+
required: false,
635+
},
591636
];
592637

593638
const _extToLang: Map<string, LanguageRegistryEntry> = new Map();
@@ -820,7 +865,7 @@ export function getActiveEngine(opts: ParseEngineOpts = {}): {
820865
*/
821866
export function createParseTreeCache(): any {
822867
const native = loadNative();
823-
if (!native || !native.ParseTreeCache) return null;
868+
if (!native?.ParseTreeCache) return null;
824869
return new native.ParseTreeCache();
825870
}
826871

0 commit comments

Comments
 (0)