Repository navigation
Description
Summary
graphify currently has no MATLAB/tree-sitter support at all — .m files fall through to a bare file-stub node with zero structural edges (no functions, no calls, no cross-file imports/references detected), even though a real, maintained tree-sitter grammar for MATLAB already exists and is installable as a normal dependency.
Evidence
- Checked the installed
graphifyypackage dependencies (uv tool install graphifyy) — notree-sitter-matlabamong the 27 language grammars bundled. - A working grammar exists:
acristoffers/tree-sitter-matlab— actively maintained (updated within the last ~2 weeks as of filing), and already published on PyPI astree-sitter-matlab(currently v1.3.0), same packaging convention as graphify's othertree-sitter-<language>dependencies. - Confirmed the gap concretely on a real corpus: 4 MATLAB files with genuine call/usage relationships (one script calling into another, importing shared config) extracted to 4 isolated nodes, 0 edges via
graphify extract. By contrast, a 6-file Python module with equivalent internal structure extracted to 72 nodes, 152 edges in the same session — same tool, same AST-only pass, only the language differed. - This isn't just "reduced fidelity" — it produces a wrong-by-omission answer for any code-navigation question touching MATLAB. Asked
graphify query"what code implements X", where X is a MATLAB-only feature — the correct files never appeared anywhere in a 35-node depth-2 BFS, because they have no edges to be traversed through.
Why it matters
MATLAB is heavily used in engineering/scientific domains (controls, aerospace, signal processing, simulation) where graphify's docs+code+papers pitch is otherwise a great fit — but right now those codebases get effectively no structural graph at all for their primary language.
What I looked at on the implementation side
Per-language extraction in extract.py looks hand-written per language (~150-300 lines each, e.g. the Julia block), not a generic tree-sitter-node walker — so this isn't a one-line pip install fix, it'd need a new extraction function targeting tree-sitter-matlab's specific node-type names (function definitions, classdef blocks, calls, etc.), following the same pattern as the existing per-language blocks. Flagging that context in case it's useful for scoping the work, not assuming it's trivial.
Happy to help test against a real MATLAB corpus if that's useful once there's a WIP branch.
Activity
catalystdream commentedon Jul 6, 2026
Correction/sharpening after digging into the actual source — the diagnosis is more specific than "no MATLAB support," and the fix path is more precedented than I first thought:
.mis not unhandled — it's claimed by Objective-C.detect.py'sCODE_EXTENSIONSandextract.pyroute.m/.mmtoextract_objc()viatree_sitter_objcunconditionally. There's no content check for.mspecifically.Feeding real MATLAB source through the Objective-C parser produces a broken parse, not a clean skip. Tested directly against one of the files from my original report:
root.has_error = True, with the top-level children coming back as genericdeclaration/expression_statementnodes that don't correspond to any real MATLAB semantics — the parser is just doing its best to force MATLAB syntax into a C-family grammar. This is worse than silently skipping the file: it's a genuine risk of extracting garbage nodes/edges from whatever fragments happen to parse as "valid enough" Objective-C, not just missing coverage.The fix has a direct precedent already in this codebase.
extract.pyalready content-sniffs.hfiles to route betweenextract_cppandextract_objcrather than trusting the extension alone (see the comments around line 12093/12383: "a.hmay route to either extract_cpp or extract_objc by content"). The natural fix for.mis the same pattern: content-sniff for Objective-C markers (@interface,@implementation,@end,#import) vs. MATLAB markers (function ... endblock structure,%/%{ %}comment style), and route non-Objective-C.mfiles to a newextract_matlab()built ontree-sitter-matlab(still needs writing, per my original report, but the dispatch half of this is a small, idiomatic addition matching existing code).Happy to share the two-line repro above against a larger MATLAB sample set if useful for testing the content-sniff heuristic.
fix(extract): don't force-parse MATLAB .m through the Objective-C gra…
safishamsi commentedon Jul 7, 2026
Thanks to @catalystdream for the sharpened diagnosis — the content-sniff precedent (
.hrouting to extract_cpp vs extract_objc) was exactly the right pointer.On
v8(next release) I've fixed the garbage-parse half:.mis now content-sniffed like.h. A genuine Objective-C.m(carrying@implementation/@interface/@import/#import) still routes to extract_objc; a.mwithout any ObjC directive (MATLAB, Octave) no longer gets force-parsed by the Objective-C grammar intoroot.has_errorgarbage — it gets no extractor and is surfaced by the no-AST-extractor warning (#1689) instead of silently mis-parsed..mmis unambiguously Objective-C++ and is untouched. Regression tests cover ObjC.m-> objc, MATLAB function/classdef.m-> no extractor, and.mm-> objc.Leaving this issue open for the primary ask — a real
tree-sitter-matlabextractor (functions,classdef, calls). Now that.mwon't produce wrong data in the meantime, that's a clean additive follow-up, and I'll take you up on the offer to test against a real MATLAB corpus when there's a WIP branch.Release 0.9.9
fix(extract): don't force-parse MATLAB .m through the Objective-C gra…
Release 0.9.9
mgcooper commentedon Sep 24, 2026
Is MATLAB extraction still planned? PR #1888 ("feat(matlab): add first-class MATLAB extraction support") was closed unmerged on 2026-09-12, and its fork branch is gone, but refs/pull/1888/head still resolves (fbc69dd). Issue #2935 asks for the same extractor. We run graphify on MATLAB repositories and can test a successor branch against a MATLAB dependency-analysis oracle and report per-class recall. Is a successor branch planned, or should we test #1888's head?
SyedFahad7 commentedon Oct 2, 2026
Yes. A new branch is the way to go, not #1888's head. That PR was closed by the author and the branch is gone, so that commit will just be behind current v8.
The extractor is still the open part of this issue.
tree-sitter-matlabis already on PyPI, and the.msniff is already in: MATLAB files are skipped instead of parsed as Objective-C. What's left is the reader (functions,classdef, calls) wired to those.mfiles.If you open a PR against
v8and link this issue, the test you described is the useful part. Per-class recall against your MATLAB dependency oracle is exactly what this thread asked for once there's a branch.feat: ArkTS (.ets) and HarmonyOS project-config extraction