Skip to content

Commit c25ac7c

Browse files
committed
Merge branch 'main' of github.mathworks.com:development/matlab-language-server
2 parents afd0d2d + 400eb43 commit c25ac7c

File tree

7 files changed

+811
-523
lines changed

7 files changed

+811
-523
lines changed

matlab/+matlabls/+internal/computeCodeData.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,24 @@
196196
ranges = getRangeForNodes(functionCalls);
197197
functions = functionCalls.strings();
198198

199+
%% Get variable info from script
200+
functionAndClassSubtree = mt.mtfind('Kind', {'FUNCTION', 'CLASSDEF'}).subtree;
201+
script = mt - functionAndClassSubtree;
202+
vars = script.mtfind('Isvar', true);
203+
var_ranges = getRangeForNodes(vars);
204+
var_names = vars.strings();
205+
199206
% Pre-allocate some space in the references array to improve performance
200207
startIndex = numel(functionReferences);
201-
functionReferences = [functionReferences cell(1, numel(functions))];
208+
functionReferences = [functionReferences cell(1, numel(functions) + numel(var_names))];
202209
for k = 1:numel(functions)
203210
functionName = functions{k};
204211
functionReferences{startIndex + k} = { functionName, ranges(k) };
205212
end
213+
for k = 1:numel(var_names)
214+
varName = var_names{k};
215+
functionReferences{startIndex + numel(functions) + k} = { varName, var_ranges(k) };
216+
end
206217

207218
%% Getting Section Data
208219
sections = {};

0 commit comments

Comments
 (0)