Skip to content

Commit

Permalink
Merge pull request #3773 from portalgun/matlab-setget
Browse files Browse the repository at this point in the history
MatLab: return appropriate tags for set get methods + unit
  • Loading branch information
masatake authored Jul 17, 2023
2 parents a571edc + a53c1e2 commit caeb22a
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Units/parser-matlab.r/matlab_setget.m.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sort=no

16 changes: 16 additions & 0 deletions Units/parser-matlab.r/matlab_setget.m.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
input input.m /^classdef input < handle$/;" c
get.myproperty input.m /^ function out=get.myproperty(obj)$/;" f
set.myproperty input.m /^ function out=set.myproperty(obj,val)$/;" f
classfunc1 input.m /^ function [x,y,z] = classfunc1$/;" f
classfunc2 input.m /^ function x = classfunc2()$/;" f
x input.m /^ x = func2(1);$/;" v
classfunc3 input.m /^ function classfunc3;$/;" f
func1 input.m /^function [x,y,z] = func1() % Silly function with multiple outputs$/;" f
x input.m /^ x = 1;$/;" v
y input.m /^ y = 2;$/;" v
z input.m /^ z = 3;$/;" v
func2 input.m /^function x = func2(arg)$/;" f
x input.m /^ x = arg;$/;" v
func3 input.m /^function func3()$/;" f
A input.m /^ A = magic(4);$/;" v
R input.m /^ R = randn(3,4,5);$/;" v
1 change: 1 addition & 0 deletions Units/parser-matlab.r/matlab_setget.m.d/features
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
regex
45 changes: 45 additions & 0 deletions Units/parser-matlab.r/matlab_setget.m.d/input.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
classdef input < handle
properties
myproperty
end
properties(Hidden)
myproperty_
end
function out=get.myproperty(obj)
out=myproperty_;
end
function out=set.myproperty(obj,val)
myproperty_=val;
end
methods(Static)
function [x,y,z] = classfunc1
[x, y, z] = func1();
end
function x = classfunc2()
x = func2(1);
end
function classfunc3;
func3();
end
end
end

function [x,y,z] = func1() % Silly function with multiple outputs
x = 1;
y = 2;
z = 3;
end
function x = func2(arg)
x = arg;
end
function func3()
% Silly function without any arguments
A = magic(4);
R = randn(3,4,5);

disp('A:');
disp(A);

disp('R:');
disp(R);
end
6 changes: 3 additions & 3 deletions parsers/matlab.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

static tagRegexTable matlabTagRegexTable [] = {
/* function [x,y,z] = asdf */
{ "^[ \t]*function[ \t]*\\[.*\\][ \t]*=[ \t]*([a-zA-Z0-9_]+)",
{ "^[ \t]*function[ \t]*\\[.*\\][ \t]*=[ \t]*([.a-zA-Z0-9_]+)",
"\\1", "f,function", NULL},
/* function x = asdf */
{"^[ \t]*function[ \t]*[a-zA-Z0-9_]+[ \t]*=[ \t]*([a-zA-Z0-9_]+)",
{"^[ \t]*function[ \t]*[a-zA-Z0-9_]+[ \t]*=[ \t]*([.a-zA-Z0-9_]+)",
"\\1", "f,function", NULL},
/* function asdf */
{"^[ \t]*function[ \t]*([a-zA-Z0-9_]+)[^=]*$", "\\1",
{"^[ \t]*function[ \t]*([.a-zA-Z0-9_]+)[^=]*$", "\\1",
"f,function", NULL},
/* variables */
{"^[ \t]*([a-zA-Z0-9_]+)[ \t]*=[ \t]", "\\1",
Expand Down

0 comments on commit caeb22a

Please sign in to comment.