Skip to content

feat(julia): language extractor with vendored tree-sitter grammar#288

Closed
hexu2 wants to merge 1 commit into
colbymchenry:mainfrom
hexu2:feat/julia-language-support
Closed

feat(julia): language extractor with vendored tree-sitter grammar#288
hexu2 wants to merge 1 commit into
colbymchenry:mainfrom
hexu2:feat/julia-language-support

Conversation

@hexu2
Copy link
Copy Markdown

@hexu2 hexu2 commented May 22, 2026

Summary

Adds first-class Julia (.jl) indexing to CodeGraph using the tree-sitter-julia grammar.

This PR extends and supersedes the groundwork in #244 by @kongdd, with additional handling for common Julia AST shapes seen in real-world packages (including Julia 1.11):

  • Structs without block wrappersstruct_definition may use typed_expression children instead of body/block; extractStruct now uses resolveBody (consistent with interface extraction).
  • Functions without block wrappers — many files use a flat statement list after signature; resolveBody returns the function node so nested calls are still indexed.
  • One-line definitions — e.g. f(x) = expr via assignment handling (not covered in add support for Julia #244).
  • module nodesmodule_definition mapped to module kind for namespacing.
  • macrocall_expression — included in callTypes.
  • Vendored WASMtree-sitter-julia.wasm is committed under src/extraction/wasm/ (the grammar is not in tree-sitter-wasms@0.1.11; npm-only loading would fail in CI and offline installs).

Also adds the optional getName hook on LanguageExtractor (as proposed in #244) and wires it through extractName.

Test plan

  • npm run build
  • npm test -- --run -t "Julia Extraction" (11 tests)
  • Manual: extractFromSource on representative fixtures (structs, one-liners, modules, call sites)
  • codegraph index on a Julia project; codegraph query <symbol> returns expected definitions and references

Related

Notes for maintainers

  • tree-sitter-julia is a devDependency only for rebuilding WASM; runtime uses the committed src/extraction/wasm/tree-sitter-julia.wasm binary (same pattern as lua/luau/pascal/scala vendoring).

@hexu2 hexu2 force-pushed the feat/julia-language-support branch from 89652f4 to dd79e46 Compare May 22, 2026 01:52
Extends the approach in colbymchenry#244 (@kongdd) with fixes for common Julia 1.11
AST shapes in real-world packages:

- Add getName hook and use resolveBody for structs without block wrappers
- Extract one-line assignment functions (e.g. f(x) = expr)
- Emit module nodes; record macrocall_expression calls
- Vendor tree-sitter-julia.wasm (not shipped in tree-sitter-wasms)
- Register .jl in grammars, types, and EXTRACTORS map

Closes gaps in colbymchenry#244 where function bodies are statement lists rather than
block nodes.
@hexu2 hexu2 force-pushed the feat/julia-language-support branch from dd79e46 to d88581f Compare May 22, 2026 01:53
@hexu2
Copy link
Copy Markdown
Author

hexu2 commented May 22, 2026

Closing to resubmit with cleaned commit history and description.

@hexu2 hexu2 closed this May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant