Skip to content

Commit 073aaa1

Browse files
authored
Merge pull request #57 from mathworks/dklilley/release/1.3.2
MATLAB language server - v1.3.2
2 parents 02ff685 + 41d556f commit 073aaa1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1936
-903
lines changed

.vscode/launch.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"args": [
6+
"-u",
7+
"bdd",
8+
"--timeout",
9+
"999999",
10+
"--colors",
11+
"${workspaceFolder}/tests/**/*.test.ts",
12+
],
13+
"internalConsoleOptions": "openOnSessionStart",
14+
"name": "Mocha Tests",
15+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
16+
"request": "launch",
17+
"skipFiles": [
18+
"<node_internals>/**"
19+
],
20+
"type": "node"
21+
}
22+
23+
]
24+
}

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ MATLAB language server supports these editors by installing the corresponding ex
2626

2727
### Unreleased
2828

29+
### 1.3.2
30+
Release date: 2025-03-06
31+
32+
Fixed:
33+
* Resolves errors with adding workspace folders to the MATLAB path on macOS and Linux systems
34+
2935
### 1.3.1
3036
Release date: 2025-01-23
3137

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function completionsData = getCompletions(code, fileName, cursorPosition)
2+
% GETCOMPLETIONS Retrieves the data for the possible completions at the cursor position in the given code.
3+
4+
% Copyright 2025 The MathWorks, Inc.
5+
6+
completionResultsStr = matlabls.internal.getCompletionsData(code, fileName, cursorPosition);
7+
completionsData = filterCompletionResults(completionResultsStr);
8+
end
9+
10+
function compResultsStruct = filterCompletionResults (completionResultsStr)
11+
completionResults = jsondecode(completionResultsStr);
12+
13+
compResultsStruct = struct;
14+
propsToKeep = ["widgetData", "widgetType", "signatures"];
15+
16+
for prop = propsToKeep
17+
if isfield(completionResults, prop)
18+
compResultsStruct.(prop) = completionResults.(prop);
19+
end
20+
end
21+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function foldingRanges = getFoldingRanges(code)
2+
% GETFOLDINGRANGES Retrieves the code folding ranges for the given code.
3+
4+
% Copyright 2025 The MathWorks, Inc.
5+
6+
foldingRanges = matlabls.internal.getFoldingRanges(code);
7+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
function formattedCode = formatCode (codeToFormat, options)
2+
% FORMATCODE Formats the given MATLAB code according to the specified options.
3+
4+
% Copyright 2025 The MathWorks, Inc.
5+
6+
s = settings;
7+
8+
% Update settings (temporarily) for formatting
9+
cleanupObj1 = setTemporaryValue(s.matlab.editor.tab.InsertSpaces, options.insertSpaces); %#ok<NASGU>
10+
cleanupObj2 = setTemporaryValue(s.matlab.editor.tab.TabSize, options.tabSize); %#ok<NASGU>
11+
cleanupObj3 = setTemporaryValue(s.matlab.editor.tab.IndentSize, options.tabSize); %#ok<NASGU>
12+
13+
% Format code
14+
formattedCode = indentcode(codeToFormat);
15+
end
16+
17+
function cleanupObj = setTemporaryValue (setting, tempValue)
18+
if setting.hasTemporaryValue
19+
originalValue = setting.TemporaryValue;
20+
cleanupObj = onCleanup(@() setTempValue(setting, originalValue));
21+
else
22+
cleanupObj = onCleanup(@() setting.clearTemporaryValue);
23+
end
24+
25+
setTempValue(setting, tempValue);
26+
27+
function setTempValue (setting, tempValue)
28+
setting.TemporaryValue = tempValue;
29+
end
30+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function codeData = parseInfoFromDocument (code, filePath, analysisLimit)
2+
% PARSEINFOFROMDOCUMENT Parses the given MATLAB code and extracts information about
3+
% variables, functions, etc.
4+
5+
% Copyright 2025 The MathWorks, Inc.
6+
7+
codeData = matlabls.internal.computeCodeData(code, filePath, analysisLimit);
8+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
function parseInfoFromFolder (folders, analysisLimit, responseChannel)
2+
% PARSEINFOFROMFOLDER Parses the MATLAB files in the provided folders and extracts
3+
% information about variables, functions, etc.
4+
%
5+
% Instead of returning the parsed results, this function will stream those results
6+
% over the response channel. This allows for these files to be processed without
7+
% blocking the MATLAB thread for the full duration.
8+
9+
% Copyright 2025 The MathWorks, Inc.
10+
11+
filesToParse = getAllMFilesToParse(folders);
12+
parfeval(backgroundPool, @doParseFiles, 0, filesToParse, analysisLimit, responseChannel);
13+
end
14+
15+
function filesToParse = getAllMFilesToParse (folders)
16+
% Gathers a list of all M files within the given folders
17+
18+
filesToParse = [];
19+
20+
for n = 1:numel(folders)
21+
fileListing = dir([folders{n} '/**/*.m']);
22+
fileNames = strings(numel(fileListing), 1);
23+
for m = 1:numel(fileListing)
24+
fileNames(m) = fullfile(fileListing(m).folder, fileListing(m).name);
25+
end
26+
filesToParse = [filesToParse; fileNames]; %#ok<AGROW>
27+
end
28+
end
29+
30+
function doParseFiles (filesToParse, analysisLimit, responseChannel)
31+
% Processes the given list of files.
32+
%
33+
% This can be executed in a separate thread (e.g. parfeval) to avoid blocking
34+
% the MATLAB thread.
35+
36+
for n = 1:numel(filesToParse)
37+
filePath = filesToParse{n};
38+
isLastFile = (n == numel(filesToParse));
39+
parseFile(filePath, isLastFile, analysisLimit, responseChannel);
40+
end
41+
end
42+
43+
function parseFile (filePath, isLastFile, analysisLimit, responseChannel)
44+
% Parses an individual file and publishes the results over the response channel.
45+
%
46+
% If the file to be parsed is the last file, an `isDone` flag on the results is
47+
% set to true to indicate that the parsing process has completed.
48+
49+
code = fileread(filePath);
50+
codeData = matlabls.handlers.indexing.parseInfoFromDocument(code, filePath, analysisLimit);
51+
52+
% Send data for this file
53+
msg.filePath = filePath;
54+
msg.codeData = codeData;
55+
msg.isDone = isLastFile;
56+
57+
matlabls.internal.CommunicationManager.publish(responseChannel, msg);
58+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function lintData = getLintData(code, fileName)
2+
% GETLINTDATA Gathers linting data for the provided MATLAB® code.
3+
4+
% Copyright 2025 The MathWorks, Inc.
5+
6+
lintData = checkcode('-text', code, fileName, '-id', '-severity', '-fix', '-string');
7+
lintData = split(deblank(lintData), newline);
8+
lintData(cellfun(@isempty, lintData)) = [];
9+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function suppressionEdits = getSuppressionEdits(code, diagnosticId, diagnosticLine, suppressInFile)
2+
% GETSUPPRESSIONEDITS Gets the edits required to suppress the given linting diagnostic.
3+
4+
% Copyright 2025 The MathWorks, Inc.
5+
6+
if suppressInFile
7+
diagnosticId = strcat('*', diagnosticId);
8+
end
9+
10+
suppressionEdits = matlabls.internal.getDiagnosticSuppressionEdits(code, diagnosticId, diagnosticLine);
11+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
function resolvedPath = resolveNameToPath(name, contextFile)
2+
% RESOLVENAMETOPATH Resolves a name (e.g. "plot") to the respective file path which
3+
% corresponds to the definition of that name.
4+
5+
% Copyright 2025 The MathWorks, Inc.
6+
7+
resolvedPath = resolvePath(name, contextFile);
8+
9+
% If the name is not found, try CDing to the context file's
10+
% directory and searching again
11+
if strlength(resolvedPath) == 0
12+
returnDir = cdToPackageRoot(contextFile);
13+
resolvedPath = resolvePath(name, contextFile);
14+
cd(returnDir);
15+
end
16+
end
17+
18+
function resolvedPath = resolvePath (name, contextFile)
19+
if isMATLABReleaseOlderThan('R2023b')
20+
% For usage in R2023a and earlier
21+
[isFound, resolvedPath] = matlabls.internal.resolvePath(name, contextFile);
22+
elseif isMATLABReleaseOlderThan('R2024a')
23+
% For usage in R2023b only
24+
[isFound, resolvedPath] = matlab.internal.language.introspective.resolveFile(name, []);
25+
elseif isMATLABReleaseOlderThan('R2024b')
26+
% For usage in R2024a only
27+
ec = matlab.lang.internal.introspective.ExecutionContext;
28+
[isFound, resolvedPath] = matlab.lang.internal.introspective.resolveFile(name, ec);
29+
else
30+
% For usage in R2024b and later
31+
ic = matlab.lang.internal.introspective.IntrospectiveContext.caller;
32+
[isFound, resolvedPath] = matlab.lang.internal.introspective.resolveFile(name, ic);
33+
end
34+
35+
if ~isFound
36+
resolvedPath = '';
37+
end
38+
end
39+
40+
function returnDir = cdToPackageRoot (filePath)
41+
% Given a file path, CDs to the directory at the root-level of the
42+
% file's package structure. If the file is not within a package,
43+
% this CDs to the file's directory.
44+
45+
splitDirs = strsplit(fileparts(filePath), filesep);
46+
47+
% Determine how far up the path we need to CD
48+
lastInd = numel(splitDirs);
49+
while lastInd > 1
50+
if ~startsWith(splitDirs(lastInd), '+')
51+
break;
52+
end
53+
lastInd = lastInd - 1;
54+
end
55+
56+
returnDir = cd(strjoin(splitDirs(1:lastInd), filesep));
57+
end

matlab/+matlabls/+handlers/CompletionSupportHandler.m

-47
This file was deleted.

matlab/+matlabls/+handlers/FeatureHandler.m

-19
This file was deleted.

matlab/+matlabls/+handlers/FoldingSupportHandler.m

-33
This file was deleted.

0 commit comments

Comments
 (0)