Skip to content

MATLAB language server - v1.2.7 #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ MATLAB language server supports these editors by installing the corresponding ex

### Unreleased

### 1.2.7
Release date: 2024-11-07

Added:
* Allow specifying the maximum file size for code analysis through the `maxFileSizeForAnalysis` setting
* Linting support in untitled files and in MATLAB files with different file extensions

### 1.2.6
Release date: 2024-09-20

Expand Down
14 changes: 14 additions & 0 deletions build/copyLicensingToOut.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2024 The MathWorks, Inc.
const fs = require('fs')
const path = require('path')

const sourceDir = path.join(__dirname, '..', 'src', 'licensing', 'gui', 'build')
const targetDir = path.join(__dirname, '..', 'out', 'licensing', 'static')

fs.cp(sourceDir, targetDir, { recursive: true }, (err) => {
if (err) {
console.error('Error copying files: ', err)
} else {
console.log('Files copied successfully.')
}
})
13 changes: 13 additions & 0 deletions build/makeLicensingOut.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2024 The MathWorks, Inc.
const fs = require('fs')
const path = require('path')

const dirPath = path.join(__dirname, '..', 'out', 'licensing', 'static')

fs.mkdir(dirPath, { recursive: true }, (err) => {
if (err) {
console.error('Error creating directory: ', err)
} else {
console.log('Directory created successfully: ', dirPath)
}
})
28 changes: 15 additions & 13 deletions matlab/+matlabls/+handlers/IndexingHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ function handleDocumentIndexRequest (this, msg)

code = msg.code;
filePath = msg.filePath;
analysisLimit = msg.analysisLimit;

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

responseChannel = strcat(this.DocumentIndexingResponseChannel, '/', msg.channelId);
matlabls.internal.CommunicationManager.publish(responseChannel, codeData)
Expand All @@ -36,9 +37,10 @@ function handleFolderIndexRequest (this, msg)
% Indexes M-files the provided folders

folders = msg.folders;
analysisLimit = msg.analysisLimit;

files = this.getAllMFilesToIndex(folders);
this.parseFiles(msg.channelId, files)
this.parseFiles(msg.channelId, files, analysisLimit)
end

function filesToIndex = getAllMFilesToIndex (~, folders)
Expand All @@ -56,30 +58,30 @@ function handleFolderIndexRequest (this, msg)
end
end

function parseFiles (this, requestId, files)
function parseFiles (this, requestId, files, analysisLimit)
% Processes the given list of files and sends the data back to the language server.

if isMATLABReleaseOlderThan('R2021b')
% If backgroundPool doesn't exist, leverage a timer to avoid blocking thread
this.doParseFilesWithTimer(this, requestId, files);
this.doParseFilesWithTimer(this, requestId, files, analysisLimit);
else
parfeval(backgroundPool, @this.doParseFiles, 0, requestId, files);
parfeval(backgroundPool, @this.doParseFiles, 0, requestId, files, analysisLimit);
end
end

function doParseFilesWithTimer (this, requestId, files, index)
function doParseFilesWithTimer (this, requestId, files, analysisLimit, index)
% This leverages a timer to achieve an "asynchronous" looping effect, allowing
% other operations to take place between parsing each file. This prevents the MATLAB®
% thread from becomming blocked for an extended period of time.

if nargin == 3
if nargin == 4
index = 1;
end

filePath = files(index);
isLastFile = index == numel(files);

this.parseFile(requestId, filePath, isLastFile);
this.parseFile(requestId, filePath, isLastFile, analysisLimit);

if ~isLastFile
% More files - queue next file to parse
Expand All @@ -93,26 +95,26 @@ function timerCallback (t, ~)
t.delete();

% Parse next file
this.parseFiles(requestId, files, index + 1);
this.doParseFilesWithTimer(requestId, files, analysisLimit, index + 1);
end
end

function doParseFiles (this, requestId, files)
function doParseFiles (this, requestId, files, analysisLimit)
% This can be executed in a separate thread (e.g. parfeval) to avoid blocking the
% MATLAB thread.

for n = 1:numel(files)
filePath = files{n};
isLastFile = n == numel(files);
this.parseFile(requestId, filePath, isLastFile);
this.parseFile(requestId, filePath, isLastFile, analysisLimit);
end
end

function parseFile (this, requestId, filePath, isLastFile)
function parseFile (this, requestId, filePath, isLastFile, analysisLimit)
% Parses the given file and sends its data back to the language server

code = fileread(filePath);
codeData = matlabls.internal.computeCodeData(code, filePath);
codeData = matlabls.internal.computeCodeData(code, filePath, analysisLimit);

% Send data for this file
msg.filePath = filePath;
Expand Down
Binary file modified matlab/+matlabls/+internal/computeCodeData.p
Binary file not shown.
Loading