Skip to content

Commit 7c3edbf

Browse files
diningPhilosopher64prabhakk-mw
authored andcommitted
Addressed review comments and file formatting
1 parent 172fdb1 commit 7c3edbf

File tree

11 files changed

+23
-22
lines changed

11 files changed

+23
-22
lines changed

src/jupyter_matlab_kernel/kernels/base_kernel.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
)
2828
from jupyter_matlab_kernel.mwi_exceptions import MATLABConnectionError
2929

30-
from jupyter_matlab_kernel.kernels.labextension_comm import LabExtensionCommunication
30+
from jupyter_matlab_kernel.kernels.comms import LabExtensionCommunication
3131

3232

3333
_MATLAB_STARTUP_TIMEOUT = mwi_settings.get_process_startup_timeout()
@@ -145,6 +145,9 @@ def __init__(self, *args, **kwargs):
145145

146146
self.labext_comm = LabExtensionCommunication(self)
147147

148+
# Custom handling of comm messages for jupyterlab extension communication.
149+
# https://jupyter-client.readthedocs.io/en/latest/messaging.html#custom-messages
150+
148151
# Override only comm handlers to keep implementation clean by separating
149152
# JupyterLab extension communication logic from core kernel functionality.
150153
# Other handlers (interrupt_request, execute_request, etc.) remain in base class.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copyright 2025 The MathWorks, Inc.
2+
3+
from .labextension import LabExtensionCommunication

src/jupyter_matlab_kernel/kernels/labextension_comm/communication.py renamed to src/jupyter_matlab_kernel/kernels/comms/labextension.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright 2025 The MathWorks, Inc.
22

33
from ipykernel.comm import Comm
4-
import time
54

65

76
class LabExtensionCommunication:

src/jupyter_matlab_kernel/kernels/labextension_comm/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/jupyter_matlab_labextension/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"import/no-webpack-loader-syntax": "warn",
3737
"node/no-callback-literal": ["off", "warn"],
3838
"node/handle-callback-err": ["off", "warn"],
39-
"node/no-deprecated-api": ["off", "warn"]
39+
"node/no-deprecated-api": ["off", "warn"],
40+
"no-multiple-empty-lines": "warn"
4041
}
4142
}

src/jupyter_matlab_labextension/src/codemirror-lang-matlab/indent-matlab.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ export function lineIndent (
2525
currentLineText.match(/^(?:\s*)(case)\b$/) &&
2626
previousLineText.match(/^(?:\s*)(switch)\b/)
2727
) {
28-
// First case in a switch statement.
28+
// First case in a switch statement.
2929
return prevLineIndent + indentUnit;
3030
} else if (currentLineText.match(/^(?:\s*)(end)\b$/)) {
31-
// Treat "end" separately to avoid mistakenly correcting the end of a switch statement.
31+
// Treat "end" separately to avoid mistakenly correcting the end of a switch statement.
3232
const currentLeadingWhitespace = currentLineText.match(
3333
leadingWhitespacePattern
3434
);
@@ -44,7 +44,7 @@ export function lineIndent (
4444
return 0;
4545
}
4646
} else {
47-
// Other cases
47+
// Other cases
4848
let lineIndent = prevLineIndent;
4949
const indentMatch = previousLineText.match(indentPattern);
5050
if (indentMatch !== null) {

src/jupyter_matlab_labextension/src/plugins/matlabCommunication.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,22 +163,20 @@ implements
163163
}
164164

165165
// A unique token for the comm service
166-
export const CommunicationService = new Token<MatlabCommunicationExtension>(
167-
'@mathworks/MatlabCommPlugin'
168-
);
166+
export const IMatlabCommunication = new Token<ICommunicationService>('@mathworks/matlab-comm:IMatlabCommunication');
169167

170168
export const matlabCommPlugin: JupyterFrontEndPlugin<MatlabCommunicationExtension> =
171169
{
172170
id: '@mathworks/matlabCommPlugin',
173171
autoStart: true,
174172
requires: [INotebookTracker],
175-
provides: CommunicationService,
173+
provides: IMatlabCommunication,
176174
activate: (app: JupyterFrontEnd): MatlabCommunicationExtension => {
177175
const matlabCommExtension = new MatlabCommunicationExtension();
178176
app.docRegistry.addWidgetExtension('Notebook', matlabCommExtension);
179177

180178
// Dispose resources created by this plugin when the page unloads.
181-
// Need to add this seperately if the jupyterlab tab is closed directly.
179+
// Need to handle this separately for the case when jupyterlab tab is closed directly
182180
window.addEventListener('beforeunload', () => {
183181
matlabCommExtension.deleteComms();
184182
});

src/jupyter_matlab_labextension/src/plugins/matlabFiles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ function registerMFiles (
2727
) {
2828
const { commands } = app;
2929
const createNewMatlabFile = async (args: ReadonlyPartialJSONObject) => {
30-
/** Get the directory in which the MATLAB file must be created;
31-
* otherwise take the current filebrowser directory. */
30+
/** Get the directory in which the MATLAB file must be created;
31+
* otherwise take the current filebrowser directory. */
3232
const cwd = args.cwd;
3333

3434
/** Create a new untitled MATLAB file. */

src/jupyter_matlab_labextension/src/plugins/matlabToolbarButton.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ implements DocumentRegistry.IWidgetExtension<NotebookPanel, INotebookModel> {
3333
panel: NotebookPanel,
3434
context: DocumentRegistry.IContext<INotebookModel>
3535
): IDisposable {
36-
/** Create the toolbar button to open MATLAB in a browser. */
36+
/** Create the toolbar button to open MATLAB in a browser. */
3737
const matlabToolbarButton = new ToolbarButton({
3838
className: 'openMATLABButton',
3939
icon: matlabIcon,

src/jupyter_matlab_labextension/src/utils/notebook.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ export class NotebookInfo {
7070
resolve();
7171
}
7272
};
73-
this._panel!.sessionContext.session?.kernel?.statusChanged.connect(
74-
onStatusChanged
75-
);
73+
this._panel!.sessionContext.session?.kernel?.statusChanged.connect(
74+
onStatusChanged
75+
);
7676
}
7777
});
7878
}

0 commit comments

Comments
 (0)