@@ -25,8 +25,9 @@ function handleDocumentIndexRequest (this, msg)
2525
2626 code = msg .code ;
2727 filePath = msg .filePath ;
28+ analysisLimit = msg .analysisLimit ;
2829
29- codeData = matlabls .internal .computeCodeData(code , filePath );
30+ codeData = matlabls .internal .computeCodeData(code , filePath , analysisLimit );
3031
3132 responseChannel = strcat(this .DocumentIndexingResponseChannel , ' /' , msg .channelId );
3233 matlabls .internal .CommunicationManager .publish(responseChannel , codeData )
@@ -36,9 +37,10 @@ function handleFolderIndexRequest (this, msg)
3637 % Indexes M-files the provided folders
3738
3839 folders = msg .folders ;
40+ analysisLimit = msg .analysisLimit ;
3941
4042 files = this .getAllMFilesToIndex(folders );
41- this .parseFiles(msg .channelId , files )
43+ this .parseFiles(msg .channelId , files , analysisLimit )
4244 end
4345
4446 function filesToIndex = getAllMFilesToIndex (~, folders )
@@ -56,30 +58,30 @@ function handleFolderIndexRequest (this, msg)
5658 end
5759 end
5860
59- function parseFiles (this , requestId , files )
61+ function parseFiles (this , requestId , files , analysisLimit )
6062 % Processes the given list of files and sends the data back to the language server.
6163
6264 if isMATLABReleaseOlderThan(' R2021b' )
6365 % 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 );
6567 else
66- parfeval(backgroundPool , @this .doParseFiles , 0 , requestId , files );
68+ parfeval(backgroundPool , @this .doParseFiles , 0 , requestId , files , analysisLimit );
6769 end
6870 end
6971
70- function doParseFilesWithTimer (this , requestId , files , index )
72+ function doParseFilesWithTimer (this , requestId , files , analysisLimit , index )
7173 % This leverages a timer to achieve an "asynchronous" looping effect, allowing
7274 % other operations to take place between parsing each file. This prevents the MATLAB®
7375 % thread from becomming blocked for an extended period of time.
7476
75- if nargin == 3
77+ if nargin == 4
7678 index = 1 ;
7779 end
7880
7981 filePath = files(index );
8082 isLastFile = index == numel(files );
8183
82- this .parseFile(requestId , filePath , isLastFile );
84+ this .parseFile(requestId , filePath , isLastFile , analysisLimit );
8385
8486 if ~isLastFile
8587 % More files - queue next file to parse
@@ -93,26 +95,26 @@ function timerCallback (t, ~)
9395 t .delete();
9496
9597 % Parse next file
96- this .parseFiles (requestId , files , index + 1 );
98+ this .doParseFilesWithTimer (requestId , files , analysisLimit , index + 1 );
9799 end
98100 end
99101
100- function doParseFiles (this , requestId , files )
102+ function doParseFiles (this , requestId , files , analysisLimit )
101103 % This can be executed in a separate thread (e.g. parfeval) to avoid blocking the
102104 % MATLAB thread.
103105
104106 for n = 1 : numel(files )
105107 filePath = files{n };
106108 isLastFile = n == numel(files );
107- this .parseFile(requestId , filePath , isLastFile );
109+ this .parseFile(requestId , filePath , isLastFile , analysisLimit );
108110 end
109111 end
110112
111- function parseFile (this , requestId , filePath , isLastFile )
113+ function parseFile (this , requestId , filePath , isLastFile , analysisLimit )
112114 % Parses the given file and sends its data back to the language server
113115
114116 code = fileread(filePath );
115- codeData = matlabls .internal .computeCodeData(code , filePath );
117+ codeData = matlabls .internal .computeCodeData(code , filePath , analysisLimit );
116118
117119 % Send data for this file
118120 msg.filePath = filePath ;
0 commit comments