Skip to content

feat: add Lua language support#82

Open
DeepKariaX wants to merge 1 commit intotirth8205:mainfrom
DeepKariaX:feat/add-lua-language-support
Open

feat: add Lua language support#82
DeepKariaX wants to merge 1 commit intotirth8205:mainfrom
DeepKariaX:feat/add-lua-language-support

Conversation

@DeepKariaX
Copy link
Copy Markdown

@DeepKariaX DeepKariaX commented Mar 29, 2026

Summary

  • Adds Lua (.lua) as the 19th supported language with full Tree-sitter grammar support
  • Handles Lua-specific idioms: require() imports, metatable-based OOP (dot and colon syntax), and variable-assigned anonymous functions
  • Includes comprehensive test fixture (139 lines) and 14 test cases covering all extraction paths

What's extracted

Construct Example Extracted as
Top-level function function greet(name) Function node
Local function local function helper(x) Function node
Anonymous function local fn = function(x) end Function node (named from variable)
Dot-syntax method function Animal.new(name) Function node, parent=Animal
Colon-syntax method function Animal:speak() Function node, parent=Animal
require() import local json = require("cjson") IMPORTS_FROM edge
Function call print("hello") CALLS edge
Method call obj:method() / obj.method() CALLS edge
Test function function test_greet() Test node

Files changed

File Change
code_review_graph/parser.py +315 — extension mapping, node-type dicts, _extract_lua_constructs handler with 3 sub-handlers, _get_name and _get_call_name branches
tests/fixtures/sample.lua +139 (new) — exercises require imports, functions, OOP, inheritance, method calls, tests
tests/test_multilang.py +122 — TestLuaParsing class with 14 tests
CLAUDE.md 18 → 19 languages
README.md 18 → 19 languages (3 locations)

Add Lua (.lua) as the 19th supported language with full Tree-sitter
grammar support for functions, imports, call sites, and test detection.

Lua-specific handling includes:
- require() calls extracted as IMPORTS_FROM edges
- Variable-assigned anonymous functions (local fn = function() end)
- Table-qualified methods via dot syntax (function Tbl.method())
- Table-qualified methods via colon syntax (function Tbl:method())
- Correct parent assignment for metatable-based OOP patterns
- Test function detection (test_* pattern)

Changes:
- parser.py: extension mapping, 4 node-type dicts, Lua constructs
  handler with 3 sub-handlers, _get_name and _get_call_name branches
- tests/fixtures/sample.lua: 139-line fixture covering require imports,
  top-level/local/anonymous functions, OOP with metatables, inheritance,
  method calls (dot + colon), and test functions
- tests/test_multilang.py: 14 tests in TestLuaParsing
- CLAUDE.md, README.md: 18 → 19 languages

Full suite: 516 passed, 0 failed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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