Skip to content

Commit

Permalink
Merge pull request #187 from mathworks/dklilley/release/1.2.7
Browse files Browse the repository at this point in the history
MATLAB extension for VS Code - v1.2.7
  • Loading branch information
dklilley authored Nov 7, 2024
2 parents 4d08291 + fa0ca8e commit 1046abf
Show file tree
Hide file tree
Showing 14 changed files with 775 additions and 26 deletions.
8 changes: 7 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ server/.git
server/.github
server/.gitattributes
server/.gitignore
server/webpack.config.js
server/webpack.config.js

# Skip packaging the the source code in licensing/gui folder as it is already built and moved into
# out/ directory by the "compile" script in server/package.json.

# The server/src/licensing/*.ts files compilation is already handled by server/tsconfig.json
server/src/licensing/
17 changes: 14 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.7] - 2024-11-07

### Added
- Visual indication of code sections
- Enable browser-based sign in using the `signIn` setting
- Specify the maximum file size for code analysis using the new `maxFileSizeForAnalysis` setting
- Linting support in untitled files and in MATLAB files with different file extensions

### Fixed
- The `installPath` setting no longer syncs between machines

## [1.2.6] - 2024-09-20

### Fixed
Expand All @@ -18,7 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Symbol rename support
- Enables users to hide "feature not available" error popups
- Enable hiding "feature not available" error popups
- Provides context menu option to add selected folder and subfolders to the path

### Fixed
Expand All @@ -27,7 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.2.4] - 2024-07-12

### Added
- Enable users to specify workspace-specific MATLAB install paths
- Enable specifying workspace-specific MATLAB install paths
- Improvements to code folding (requires MATLAB R2024b or later)

### Fixed
Expand All @@ -42,7 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- This extension will no longer support MATLAB R2021a in a future release. To make use of the advanced features of the extension or run MATLAB code, you will need to have MATLAB R2021b or later installed.

### Added
- Popups will be shown to inform the user when the connected MATLAB is not supported by the extension, or if support is planned to be removed in a future update.
- Popups will be shown to inform when the connected MATLAB is not supported by the extension, or if support is planned to be removed in a future update.

### Fixed
- Resolved issue with connecting to Intel MATLAB installation on Apple Silicon machines
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,17 @@ You can help improve the extension by sending user experience information to Mat

For more information, see the [MathWorks Privacy Policy](https://www.mathworks.com/company/aboutus/policies_statements.html).

### MATLAB Show Feature Not Available Error
### MATLAB Show Feature Not Available Error Setting
By default, the extension displays an error when a feature requires MATLAB and MATLAB is unable to start. To not display an error, set the `matlab.showFeatureNotAvailableError` setting to `false`.

### MATLAB Max File Size for Analysis Setting
By default, the extension analyzes all files, regardless of their size, for features such as linting, code navigation, and symbol renaming. To limit the maximum number of characters a file can contain, set the `matlab.maxFileSizeForAnalysis` setting. For example, to limit the number of characters to 50,000, set the `matlab.maxFileSizeForAnalysis` setting to `50000`. If a file contains more than the maximum number of characters, features such as linting, code navigation, and symbol renaming are disabled for that file. To remove the limit and analyze all files regardless of their size, set the `matlab.maxFileSizeForAnalysis` setting to `0`.

### MATLAB Sign In Setting
By default, the extension assumes that the MATLAB installation specified in the Install Path setting is activated.

To enable browser-based sign in to your MathWorks account using the Online License Manager or a Network License Manager, set the `matlab.signIn` setting to true. When this setting is enabled, the extension prompts you to sign in when it starts MATLAB.

## Troubleshooting
If the MATLAB install path is not properly configured, you get an error when you try to use certain advanced features, such as document formatting and code navigation.

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 20 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Edit MATLAB code with syntax highlighting, linting, navigation support, and more",
"icon": "public/L-Membrane_RGB_128x128.png",
"license": "MIT",
"version": "1.2.6",
"version": "1.2.7",
"engines": {
"vscode": "^1.67.0"
},
Expand Down Expand Up @@ -61,6 +61,10 @@
"command": "matlab.changeDirectory",
"title": "MATLAB: Change current directory"
},
{
"command": "matlab.enableSignIn",
"title": "MATLAB: Manage Sign In Options"
},
{
"command": "matlab.resetDeprecationPopups",
"title": "MATLAB: Reset Deprecation Warning Popups"
Expand Down Expand Up @@ -156,7 +160,7 @@
"MATLAB.installPath": {
"type": "string",
"markdownDescription": "The full path to the top-level directory of the MATLAB installation you want to use with this extension. You can determine the full path to your MATLAB installation using the `matlabroot` command in MATLAB. For more information, refer to the [README](https://github.com/mathworks/MATLAB-extension-for-vscode/blob/main/README.md). This setting can be specified for both the user and workspace setting scopes using the User and Workspace tabs above.",
"scope": "window"
"scope": "machine-overridable"
},
"MATLAB.matlabConnectionTiming": {
"type": "string",
Expand Down Expand Up @@ -190,14 +194,27 @@
"usesOnlineServices"
]
},
"MATLAB.signIn": {
"type": "boolean",
"default": false,
"markdownDescription": "Enable this option to present Sign In Options for unactivated MATLAB installations.",
"scope": "machine"
},
"MATLAB.showFeatureNotAvailableError": {
"type": "boolean",
"default": true,
"description": "Display an error when a feature requires MATLAB and MATLAB is unable to start.",
"scope": "window"
},
"MATLAB.maxFileSizeForAnalysis": {
"type": "number",
"default": 0,
"markdownDescription": "The maximum number of characters a file can contain for features such as linting, code navigation, and symbol renaming to be enabled. Use `0` for no limit.",
"scope": "window"
}
}
},

"languages": [
{
"id": "matlab",
Expand Down Expand Up @@ -276,11 +293,5 @@
"dependencies": {
"node-fetch": "^2.6.6",
"vscode-languageclient": "^8.0.2"
},
"__metadata": {
"id": "a41a2325-daf7-4cf4-beee-6c76190ad9fc",
"publisherDisplayName": "MathWorks",
"publisherId": "77ca8d5e-8b29-492a-8efb-4bd3de0c10c2",
"isPreReleaseVersion": false
}
}
}
2 changes: 1 addition & 1 deletion server
Submodule server updated 107 files
11 changes: 10 additions & 1 deletion src/Notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ enum Notification {
MVMStateChange = 'mvmStateChange',

// Telemetry
LogTelemetryData = 'telemetry/logdata'
LogTelemetryData = 'telemetry/logdata',

// Sections generated for Section Styling
MatlabSections = 'matlab/sections',

// Licensing
LicensingServerUrl = 'licensing/server/url',
LicensingData = 'licensing/data',
LicensingDelete = 'licensing/delete',
LicensingError = 'licensing/error'
}

export default Notification
118 changes: 110 additions & 8 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { Notifier } from './commandwindow/Utilities'
import TerminalService from './commandwindow/TerminalService'
import Notification from './Notifications'
import ExecutionCommandProvider from './commandwindow/ExecutionCommandProvider'
import * as LicensingUtils from './utils/LicensingUtils'
import DeprecationPopupService from './DeprecationPopupService'

import SectionStylingService from './styling/SectionStylingService'
let client: LanguageClient

const OPEN_SETTINGS_ACTION = 'workbench.action.openSettings'
const MATLAB_INSTALL_PATH_SETTING = 'matlab.installPath'

Expand All @@ -27,10 +27,15 @@ export const CONNECTION_STATUS_LABELS = {
const CONNECTION_STATUS_COMMAND = 'matlab.changeMatlabConnection'
export let connectionStatusNotification: vscode.StatusBarItem

// Command to enable or disable Sign In options for MATLAB
const MATLAB_ENABLE_SIGN_IN_COMMAND = 'matlab.enableSignIn'

let telemetryLogger: TelemetryLogger

let deprecationPopupService: DeprecationPopupService

let sectionStylingService: SectionStylingService;

let mvm: MVM;
let terminalService: TerminalService;
let executionCommandProvider: ExecutionCommandProvider;
Expand All @@ -53,9 +58,20 @@ export async function activate (context: vscode.ExtensionContext): Promise<void>
connectionStatusNotification.text = CONNECTION_STATUS_LABELS.NOT_CONNECTED
connectionStatusNotification.command = CONNECTION_STATUS_COMMAND
connectionStatusNotification.show()
context.subscriptions.push(connectionStatusNotification)

context.subscriptions.push(connectionStatusNotification)
context.subscriptions.push(vscode.commands.registerCommand(CONNECTION_STATUS_COMMAND, () => handleChangeMatlabConnection()))
// Event handler when VSCode configuration is changed by the user and executes corresponding functions for specific settings.
context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(() => {
const configuration = vscode.workspace.getConfiguration('MATLAB')

// Updates the licensing status bar item and listeners based on the 'signIn' setting.
if (configuration.get<boolean>(LicensingUtils.LICENSING_SETTING_NAME) ?? false) {
LicensingUtils.setupLicensingListeners(client)
} else {
LicensingUtils.removeLicensingListeners()
}
}))

// Set up langauge server
const serverModule: string = context.asAbsolutePath(
Expand Down Expand Up @@ -102,7 +118,6 @@ export async function activate (context: vscode.ExtensionContext): Promise<void>
client.onNotification(Notification.MatlabFeatureUnavailable, () => handleFeatureUnavailable())
client.onNotification(Notification.MatlabFeatureUnavailableNoMatlab, () => handleFeatureUnavailableWithNoMatlab())
client.onNotification(Notification.LogTelemetryData, (data: TelemetryEvent) => handleTelemetryReceived(data))

mvm = new MVM(client as Notifier);
terminalService = new TerminalService(client as Notifier, mvm);
executionCommandProvider = new ExecutionCommandProvider(mvm, terminalService, telemetryLogger);
Expand All @@ -115,32 +130,114 @@ export async function activate (context: vscode.ExtensionContext): Promise<void>
context.subscriptions.push(vscode.commands.registerCommand('matlab.addFolderAndSubfoldersToPath', async (uri: vscode.Uri) => await executionCommandProvider.handleAddFolderAndSubfoldersToPath(uri)))
context.subscriptions.push(vscode.commands.registerCommand('matlab.changeDirectory', async (uri: vscode.Uri) => await executionCommandProvider.handleChangeDirectory(uri)))

// Register a custom command which allows the user enable / disable Sign In options.
// Using this custom command would be an alternative approach to going to enabling the setting.
context.subscriptions.push(vscode.commands.registerCommand(MATLAB_ENABLE_SIGN_IN_COMMAND, async () => await handleEnableSignIn()))

// Setup listeners only if licensing workflows are enabled.
// Any further changes to the configuration settings will be handled by configChangeListener.
if (LicensingUtils.isSignInSettingEnabled()) {
LicensingUtils.setupLicensingListeners(client)
}

deprecationPopupService = new DeprecationPopupService(context)
deprecationPopupService.initialize(client)

sectionStylingService = new SectionStylingService(context)
sectionStylingService.initialize(client);

await client.start()
}

/**
* Handles enabling MATLAB licensing workflows.
*
* Checks if the `signIn` setting is enabled. If it is not enabled,
* updates the setting to enable it and displays a message indicating the workflows
* have been enabled. If it is already enabled, displays a message indicating that.
*
* @param context - The context in which the extension is running.
* @returns A promise that resolves when the operation is complete.
*/
async function handleEnableSignIn (): Promise<void> {
const configuration = vscode.workspace.getConfiguration('MATLAB');
const enable = 'Enable'
const disable = 'Disable';

const choices = LicensingUtils.isSignInSettingEnabled() ? [disable] : [enable]

const choice = await vscode.window.showQuickPick(choices, {
placeHolder: 'Manage Sign In Options'
})

if (choice == null) {
return
}

if (choice === 'Enable') {
await configuration.update(LicensingUtils.LICENSING_SETTING_NAME, true, vscode.ConfigurationTarget.Global);
void vscode.window.showInformationMessage('Sign In Options enabled.')
} else if (choice === 'Disable') {
await configuration.update(LicensingUtils.LICENSING_SETTING_NAME, false, vscode.ConfigurationTarget.Global);
void vscode.window.showInformationMessage('Sign In Options disabled.')
}
}

/**
* Handles user input about whether to connect or disconnect from MATLAB®
*/
function handleChangeMatlabConnection (): void {
void vscode.window.showQuickPick(['Connect to MATLAB', 'Disconnect from MATLAB'], {
const connect = 'Connect to MATLAB';
const disconnect = 'Disconnect from MATLAB';
const options = [connect, disconnect]

const isSignInEnabled = LicensingUtils.isSignInSettingEnabled()
const signOut = 'Sign Out of MATLAB'
const isLicensed = LicensingUtils.getMinimalLicensingInfo() !== ''
const isMatlabConnecting = connectionStatusNotification.text === CONNECTION_STATUS_LABELS.CONNECTING

// Only show signout option when signin setting is enabled, MATLAB is connected and is licensed
if (isSignInEnabled && isLicensed && isMatlabConnected()) {
options.push(signOut)
}

void vscode.window.showQuickPick(options, {
placeHolder: 'Change MATLAB Connection'
}).then(choice => {
if (choice == null) {
return
}

if (choice === 'Connect to MATLAB') {
if (choice === connect) {
// Opens the browser tab with licensing URL.
// This will only occur when the tab is accidentally closed by the user and wants to
// connect to MATLAB
if (isSignInEnabled && !isLicensed && isMatlabConnecting) {
void client.sendNotification(Notification.LicensingServerUrl)
}
sendConnectionActionNotification('connect')
} else if (choice === 'Disconnect from MATLAB') {
} else if (choice === disconnect) {
sendConnectionActionNotification('disconnect')
terminalService.closeTerminal();
} else if (choice === signOut) {
void client.sendNotification(Notification.LicensingDelete)
sendConnectionActionNotification('disconnect')
}
})
}

/**
* Checks if a connection to MATLAB is currently established.
*
* This function determines the connection status by checking if the connection status
* notification text includes a specific label indicating a successful connection.
*
* @returns `true` if MATLAB is connected, otherwise `false`.
*/
function isMatlabConnected (): boolean {
return connectionStatusNotification.text.includes(CONNECTION_STATUS_LABELS.CONNECTED)
}

/**
* Handles the notifiaction that the connection to MATLAB has changed (either has connected,
* disconnected, or is in the process of connecting)
Expand All @@ -150,9 +247,14 @@ function handleChangeMatlabConnection (): void {
function handleConnectionStatusChange (data: { connectionStatus: string }): void {
if (data.connectionStatus === 'connected') {
connectionStatusNotification.text = CONNECTION_STATUS_LABELS.CONNECTED
const licensingInfo = LicensingUtils.getMinimalLicensingInfo()

if (LicensingUtils.isSignInSettingEnabled() && licensingInfo !== '') {
connectionStatusNotification.text += licensingInfo
}
} else if (data.connectionStatus === 'disconnected') {
terminalService.closeTerminal();
if (connectionStatusNotification.text === CONNECTION_STATUS_LABELS.CONNECTED) {
if (isMatlabConnected()) {
const message = NotificationConstants.MATLAB_CLOSED.message
const options = NotificationConstants.MATLAB_CLOSED.options
vscode.window.showWarningMessage(message, ...options
Expand Down
Loading

0 comments on commit 1046abf

Please sign in to comment.