@@ -25,8 +25,9 @@ function handleDocumentIndexRequest (this, msg)
25
25
26
26
code = msg .code ;
27
27
filePath = msg .filePath ;
28
+ analysisLimit = msg .analysisLimit ;
28
29
29
- codeData = matlabls .internal .computeCodeData(code , filePath );
30
+ codeData = matlabls .internal .computeCodeData(code , filePath , analysisLimit );
30
31
31
32
responseChannel = strcat(this .DocumentIndexingResponseChannel , ' /' , msg .channelId );
32
33
matlabls .internal .CommunicationManager .publish(responseChannel , codeData )
@@ -36,9 +37,10 @@ function handleFolderIndexRequest (this, msg)
36
37
% Indexes M-files the provided folders
37
38
38
39
folders = msg .folders ;
40
+ analysisLimit = msg .analysisLimit ;
39
41
40
42
files = this .getAllMFilesToIndex(folders );
41
- this .parseFiles(msg .channelId , files )
43
+ this .parseFiles(msg .channelId , files , analysisLimit )
42
44
end
43
45
44
46
function filesToIndex = getAllMFilesToIndex (~, folders )
@@ -56,30 +58,30 @@ function handleFolderIndexRequest (this, msg)
56
58
end
57
59
end
58
60
59
- function parseFiles (this , requestId , files )
61
+ function parseFiles (this , requestId , files , analysisLimit )
60
62
% Processes the given list of files and sends the data back to the language server.
61
63
62
64
if isMATLABReleaseOlderThan(' R2021b' )
63
65
% If backgroundPool doesn't exist, leverage a timer to avoid blocking thread
64
- this .doParseFilesWithTimer(this , requestId , files );
66
+ this .doParseFilesWithTimer(this , requestId , files , analysisLimit );
65
67
else
66
- parfeval(backgroundPool , @this .doParseFiles , 0 , requestId , files );
68
+ parfeval(backgroundPool , @this .doParseFiles , 0 , requestId , files , analysisLimit );
67
69
end
68
70
end
69
71
70
- function doParseFilesWithTimer (this , requestId , files , index )
72
+ function doParseFilesWithTimer (this , requestId , files , analysisLimit , index )
71
73
% This leverages a timer to achieve an "asynchronous" looping effect, allowing
72
74
% other operations to take place between parsing each file. This prevents the MATLAB®
73
75
% thread from becomming blocked for an extended period of time.
74
76
75
- if nargin == 3
77
+ if nargin == 4
76
78
index = 1 ;
77
79
end
78
80
79
81
filePath = files(index );
80
82
isLastFile = index == numel(files );
81
83
82
- this .parseFile(requestId , filePath , isLastFile );
84
+ this .parseFile(requestId , filePath , isLastFile , analysisLimit );
83
85
84
86
if ~isLastFile
85
87
% More files - queue next file to parse
@@ -93,26 +95,26 @@ function timerCallback (t, ~)
93
95
t .delete();
94
96
95
97
% Parse next file
96
- this .parseFiles (requestId , files , index + 1 );
98
+ this .doParseFilesWithTimer (requestId , files , analysisLimit , index + 1 );
97
99
end
98
100
end
99
101
100
- function doParseFiles (this , requestId , files )
102
+ function doParseFiles (this , requestId , files , analysisLimit )
101
103
% This can be executed in a separate thread (e.g. parfeval) to avoid blocking the
102
104
% MATLAB thread.
103
105
104
106
for n = 1 : numel(files )
105
107
filePath = files{n };
106
108
isLastFile = n == numel(files );
107
- this .parseFile(requestId , filePath , isLastFile );
109
+ this .parseFile(requestId , filePath , isLastFile , analysisLimit );
108
110
end
109
111
end
110
112
111
- function parseFile (this , requestId , filePath , isLastFile )
113
+ function parseFile (this , requestId , filePath , isLastFile , analysisLimit )
112
114
% Parses the given file and sends its data back to the language server
113
115
114
116
code = fileread(filePath );
115
- codeData = matlabls .internal .computeCodeData(code , filePath );
117
+ codeData = matlabls .internal .computeCodeData(code , filePath , analysisLimit );
116
118
117
119
% Send data for this file
118
120
msg.filePath = filePath ;
0 commit comments