-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathsetupShadows.m
More file actions
50 lines (42 loc) · 1.6 KB
/
Copy pathsetupShadows.m
File metadata and controls
50 lines (42 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function setupShadows(languageServerFolder)
currentDirectory = pwd;
cleanup = onCleanup(@() cd(currentDirectory));
try
addRestoreDefaultPathShadow(languageServerFolder);
addEditShadow(languageServerFolder);
addClcShadow(languageServerFolder);
addInputShadow(languageServerFolder);
catch ME
disp('Error while attempting to add shadow directories to path')
disp(ME.message)
end
end
function addRestoreDefaultPathShadow(languageServerFolder)
cd(fullfile(matlabroot, 'toolbox', 'local'));
originalRestoreDefaultPath = @restoredefaultpath;
cd(matlabroot);
addpath(fullfile(languageServerFolder, 'shadows', 'restoredefaultpath'));
restoredefaultpath('__SET__', originalRestoreDefaultPath, @handleReset);
function handleReset()
addpath(languageServerFolder)
matlabls.setupShadows(languageServerFolder)
end
end
function addEditShadow(languageServerFolder)
cd(fullfile(matlabroot, 'toolbox', 'matlab', 'codetools'));
originalEdit = @edit;
cd(matlabroot);
addpath(fullfile(languageServerFolder, 'shadows', 'edit'));
% Need to pass the originalEdit function handle in within a cell array
% to avoid @function_handle/edit being used instead.
edit('__SET__', {originalEdit});
end
function addClcShadow(languageServerFolder)
% Only need to do this for <R2023a
if isMATLABReleaseOlderThan('R2023a')
addpath(fullfile(languageServerFolder, 'shadows', 'clc'));
end
end
function addInputShadow(languageServerFolder)
addpath(fullfile(languageServerFolder, 'shadows', 'input'));
end