Skip to content

Commit afc590d

Browse files
authored
Merge pull request #36 from mathworks/dklilley-release-1.2.0
MATLAB language server - v1.2.0
2 parents 0e2ce5f + 4f4f1f2 commit afc590d

27 files changed

+203
-56
lines changed

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
"@typescript-eslint"
1919
],
2020
"rules": {
21+
"@typescript-eslint/semi": "off",
22+
"@typescript-eslint/no-inferrable-types": "off",
23+
"@typescript-eslint/promise-function-async": "off",
2124
"@typescript-eslint/indent": ["error", 4, {
2225
"SwitchCase": 1,
2326
"VariableDeclarator": 1,

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ MATLAB language server supports these editors by installing the corresponding ex
2525

2626
### Unreleased
2727

28+
### 1.2.0
29+
Release date: 2024-03-05
30+
31+
Added:
32+
* Code execution support
33+
34+
Fixed:
35+
* Prevent responses from MATLAB being intercepted by the incorrect request callback
36+
* Fixed linting diagnostic suppression with MATLAB R2024a
37+
2838
### 1.1.8
2939
Release date: 2024-01-16
3040

matlab/+matlabls/+handlers/CompletionSupportHandler.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
% COMPLETIONSUPPORTHANDLER The feature handler for tab completion and function
33
% signature support.
44

5-
% Copyright 2022 - 2023 The MathWorks, Inc.
5+
% Copyright 2022 - 2024 The MathWorks, Inc.
66

77
properties (Access = private)
88
RequestChannel = "/matlabls/completions/request"
@@ -29,7 +29,8 @@ function handleCompletionRequest (this, msg)
2929
completionResultsStr = matlabls.internal.getCompletionsData(code, fileName, cursorPosition);
3030
filteredResults = this.filterCompletionResults(completionResultsStr);
3131

32-
message.publish(this.ResponseChannel, filteredResults)
32+
responseChannel = strcat(this.ResponseChannel, '/', msg.channelId);
33+
this.CommManager.publish(responseChannel, filteredResults)
3334
end
3435

3536
function compResultsStruct = filterCompletionResults (this, completionResultsStr)

matlab/+matlabls/+handlers/FormatSupportHandler.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
% FORMATSUPPORTHANDLER The feature handler for the "Format Document" feature.
33
% In the future, this may be expanded to include the "Format Selection" feature as well.
44

5-
% Copyright 2022 - 2023 The MathWorks, Inc.
5+
% Copyright 2022 - 2024 The MathWorks, Inc.
66

77
properties (Access = private)
88
RequestChannel = "/matlabls/formatDocument/request"
@@ -32,7 +32,8 @@ function handleFormatRequest (this, msg)
3232
response.data = indentcode(codeToFormat, 'matlab'); % This will pull from the user's MATLAB® settings.
3333

3434
% Send formatted code
35-
this.CommManager.publish(this.ResponseChannel, response)
35+
responseChannel = strcat(this.ResponseChannel, '/', msg.channelId);
36+
this.CommManager.publish(responseChannel, response)
3637
end
3738
end
3839
end

matlab/+matlabls/+handlers/IndexingHandler.m

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
% INDEXINGHANDLER The feature handler for indexing documents for variable,
33
% function, and class references and definitions.
44

5-
% Copyright 2022 - 2023 The MathWorks, Inc.
5+
% Copyright 2022 - 2024 The MathWorks, Inc.
66

77
properties (Access = private)
88
DocumentIndexingRequestChannel = '/matlabls/indexDocument/request'
9-
DocumentIndexingResponseChannel = '/matlabls/indexDocument/response/' % Needs to be appended with requestId
9+
DocumentIndexingResponseChannel = '/matlabls/indexDocument/response'
1010

1111
FolderIndexingRequestChannel = '/matlabls/indexFolders/request'
12-
FolderIndexingResponseChannel = '/matlabls/indexFolders/response/' % Needs to be appended with requestId
12+
FolderIndexingResponseChannel = '/matlabls/indexFolders/response'
1313
end
1414

1515
methods
@@ -26,22 +26,20 @@ function handleDocumentIndexRequest (this, msg)
2626

2727
code = msg.code;
2828
filePath = msg.filePath;
29-
requestId = num2str(msg.requestId);
3029

3130
codeData = matlabls.internal.computeCodeData(code, filePath);
3231

33-
responseChannel = strcat(this.DocumentIndexingResponseChannel, requestId);
32+
responseChannel = strcat(this.DocumentIndexingResponseChannel, '/', msg.channelId);
3433
this.CommManager.publish(responseChannel, codeData)
3534
end
3635

3736
function handleFolderIndexRequest (this, msg)
3837
% Indexes M-files the provided folders
3938

4039
folders = msg.folders;
41-
requestId = num2str(msg.requestId);
4240

4341
files = this.getAllMFilesToIndex(folders);
44-
this.parseFiles(requestId, files)
42+
this.parseFiles(msg.channelId, files)
4543
end
4644

4745
function filesToIndex = getAllMFilesToIndex (~, folders)
@@ -127,7 +125,7 @@ function parseFile (this, requestId, filePath, isLastFile)
127125
msg.isDone = false;
128126
end
129127

130-
responseChannel = strcat(this.FolderIndexingResponseChannel, requestId);
128+
responseChannel = strcat(this.FolderIndexingResponseChannel, '/', requestId);
131129
this.CommManager.publish(responseChannel, msg);
132130
end
133131
end

matlab/+matlabls/+handlers/LintingSupportHandler.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
classdef (Hidden) LintingSupportHandler < matlabls.handlers.FeatureHandler
22
% LINTINGSUPPORTHANDLER The feature handler for linting MATLAB® code.
33

4-
% Copyright 2022 - 2023 The MathWorks, Inc.
4+
% Copyright 2022 - 2024 The MathWorks, Inc.
55

66
properties (Access = private)
77
LintingRequestChannel = '/matlabls/linting/request'
@@ -30,7 +30,8 @@ function handleLintingRequest (this, msg)
3030
response.lintData = split(deblank(response.lintData), newline);
3131
response.lintData(cellfun(@isempty, response.lintData)) = [];
3232

33-
this.CommManager.publish(this.LintingResponseChannel, response)
33+
responseChannel = strcat(this.LintingResponseChannel, '/', msg.channelId);
34+
this.CommManager.publish(responseChannel, response)
3435
end
3536

3637
function handleDiagnosticSuppressionRequest (this, msg)
@@ -47,7 +48,8 @@ function handleDiagnosticSuppressionRequest (this, msg)
4748

4849
response.suppressionEdits = matlabls.internal.getDiagnosticSuppressionEdits(code, diagnosticId, diagnosticLine);
4950

50-
this.CommManager.publish(this.SuppressDiagnosticResponseChannel, response);
51+
responseChannel = strcat(this.SuppressDiagnosticResponseChannel, '/', msg.channelId);
52+
this.CommManager.publish(responseChannel, response);
5153
end
5254
end
5355
end

matlab/+matlabls/+handlers/NavigationSupportHandler.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ function handleResolvePathRequest (this, msg)
4646
cd(returnDir);
4747
end
4848

49-
this.CommManager.publish(this.ResolvePathResponseChannel, response);
49+
responseChannel = strcat(this.ResolvePathResponseChannel, '/', msg.channelId);
50+
this.CommManager.publish(responseChannel, response);
5051
end
5152
end
5253
end
0 Bytes
Binary file not shown.
55 Bytes
Binary file not shown.

matlab/initmatlabls.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ function initmatlabls (outFile)
1111
fprintf("matlabls: matlabroot is \n%s\n", matlabroot)
1212

1313
% Ensure the language server code is on the path
14-
addpath(fileparts(mfilename("fullpath")))
14+
folder = fileparts(mfilename("fullpath"));
15+
addpath(folder)
16+
17+
if isMATLABReleaseOlderThan('R2023a')
18+
addpath(fullfile(folder, 'shadows', 'clc'));
19+
end
1520

1621
% Create matlabls helper for calculating language server operations
1722
persistent matlablsHelper %#ok<PUSE>

0 commit comments

Comments
 (0)