add MATLAB tags to enable repo map support

This commit is contained in:
Matthew Tofano 2025-06-23 21:24:52 +01:00
parent fdb49e18cd
commit 20429b6852
4 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1,10 @@
(class_definition
name: (identifier) @name.definition.class) @definition.class
(function_definition
name: (identifier) @name.definition.function) @definition.function
(function_call
name: (identifier) @name.reference.call) @reference.call
(command (command_name) @name.reference.call) @reference.call

View file

@ -0,0 +1,10 @@
(class_definition
name: (identifier) @name.definition.class) @definition.class
(function_definition
name: (identifier) @name.definition.function) @definition.function
(function_call
name: (identifier) @name.reference.call) @reference.call
(command (command_name) @name.reference.call) @reference.call

View file

@ -388,6 +388,9 @@ class TestRepoMapAllLanguages(unittest.TestCase):
def test_language_ocaml_interface(self):
self._test_language_repo_map("ocaml_interface", "mli", "Greeter")
def test_language_matlab(self):
self._test_language_repo_map("matlab", "m", "Person")
def _test_language_repo_map(self, lang, key, symbol):
"""Helper method to test repo map generation for a specific language."""
# Get the fixture file path and name based on language

42
tests/fixtures/languages/matlab/test.m vendored Normal file
View file

@ -0,0 +1,42 @@
classdef Person
properties
name (1,1) string
age (1,1) double
end
methods
function obj = Person(name, age)
arguments
name (1,1) string
age (1,1) double = NaN
end
% Constructor for Person class
obj.name = name;
obj.age = age;
end
function greeting = greet(obj,formal)
arguments
obj
formal (1,1) logical = false
end
if formal
prefix = "Good day";
else
prefix = "Hello";
end
greeting = sprintf("%s, %s!", prefix, obj.name);
end
end
end
function greetings = create_greeting_list(people)
arguments
people (1,:) Person
end
% Create greetings for a list of people.
greetings = string(numel(people), 0);
for i = 1:numel(people)
greetings(i) = people(i).greet();
end
end