Skip to content

Commit 9860504

Browse files
review cleanup
1 parent fd074ef commit 9860504

7 files changed

Lines changed: 34 additions & 79 deletions

File tree

src/client/datascience/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ export enum Telemetry {
125125
GetPasswordAttempt = 'DATASCIENCE.GET_PASSWORD_ATTEMPT',
126126
GetPasswordFailure = 'DATASCIENCE.GET_PASSWORD_FAILURE',
127127
GetPasswordSuccess = 'DATASCIENCE.GET_PASSWORD_SUCCESS',
128-
OpenPlotViewer = 'DATASCIENCE.OPEN_PLOT_VIEWER'
128+
OpenPlotViewer = 'DATASCIENCE.OPEN_PLOT_VIEWER',
129+
DebugCurrentCell = 'DATASCIENCE.DEBUG_CURRENT_CELL'
129130
}
130131

131132
export namespace HelpLinks {

src/client/datascience/datascience.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,20 @@ export class DataScience implements IDataScience {
287287
}
288288
}
289289

290+
private async debugCurrentCell(): Promise<void> {
291+
this.dataScienceSurveyBanner.showBanner().ignoreErrors();
292+
293+
const currentCodeLens = this.getCurrentCodeLens();
294+
if (currentCodeLens) {
295+
const activeCodeWatcher = this.getCurrentCodeWatcher();
296+
if (activeCodeWatcher) {
297+
return activeCodeWatcher.debugCurrentCell();
298+
}
299+
} else {
300+
return Promise.resolve();
301+
}
302+
}
303+
290304
private validateURI = (testURI: string): string | undefined | null => {
291305
try {
292306
// tslint:disable-next-line:no-unused-expression
@@ -331,21 +345,6 @@ export class DataScience implements IDataScience {
331345
return this.dataScienceCodeLensProvider.getCodeWatcher(activeEditor.document);
332346
}
333347

334-
private async debugCurrentCell(): Promise<void> {
335-
this.dataScienceSurveyBanner.showBanner().ignoreErrors();
336-
337-
const currentCodeLens = this.getCurrentCodeLens();
338-
if (currentCodeLens) {
339-
const activeCodeWatcher = this.getCurrentCodeWatcher();
340-
if (activeCodeWatcher) {
341-
//return activeCodeWatcher.runCellAndAllBelow(currentCodeLens.range.start.line, currentCodeLens.range.start.character);
342-
return activeCodeWatcher.debugCurrentCell();
343-
}
344-
} else {
345-
return Promise.resolve();
346-
}
347-
}
348-
349348
private registerCommands(): void {
350349
let disposable = this.commandManager.registerCommand(Commands.RunAllCells, this.runAllCells, this);
351350
this.disposableRegistry.push(disposable);

src/client/datascience/editor-integration/codewatcher.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class CodeWatcher implements ICodeWatcher {
9393
return this.codeLenses;
9494
}
9595

96-
// IANHU: Add Telemetry
96+
@captureTelemetry(Telemetry.DebugCurrentCell)
9797
public async debugCurrentCell() {
9898
if (!this.documentManager.activeTextEditor || !this.documentManager.activeTextEditor.document) {
9999
return Promise.resolve();
@@ -260,42 +260,6 @@ export class CodeWatcher implements ICodeWatcher {
260260
}
261261
}
262262

263-
// IANHU: Duplicating too much with run commands, perhaps debug is a parameter on run?
264-
//private async debugMatchingCell(range: Range, advance?: boolean) {
265-
//const currentRunCellLens = this.getCurrentCellLens(range.start);
266-
//const nextRunCellLens = this.getNextCellLens(range.start);
267-
268-
//if (currentRunCellLens) {
269-
//// Move the next cell if allowed.
270-
//if (advance) {
271-
//// Either use the next cell that we found, or add a new one into the document
272-
//let nextRange: Range;
273-
//if (!nextRunCellLens) {
274-
//nextRange = this.createNewCell(currentRunCellLens.range);
275-
//} else {
276-
//nextRange = nextRunCellLens.range;
277-
//}
278-
279-
//if (nextRange) {
280-
//this.advanceToRange(nextRange);
281-
//}
282-
//}
283-
284-
//// Run the cell after moving the selection
285-
//if (this.document) {
286-
//// Use that to get our code.
287-
//const code = this.document.getText(currentRunCellLens.range);
288-
289-
//try {
290-
//const activeInteractiveWindow = await this.interactiveWindowProvider.getOrCreateActive();
291-
//await activeInteractiveWindow.addCode(code, this.getFileName(), range.start.line, this.documentManager.activeTextEditor, true);
292-
//} catch (err) {
293-
//this.handleError(err);
294-
//}
295-
//}
296-
//}
297-
//}
298-
299263
private async runMatchingCell(range: Range, advance?: boolean, debug?: boolean) {
300264
const currentRunCellLens = this.getCurrentCellLens(range.start);
301265
const nextRunCellLens = this.getNextCellLens(range.start);

src/client/datascience/interactive-window/interactiveWindow.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -774,17 +774,16 @@ export class InteractiveWindow extends WebViewHost<IInteractiveWindowMapping> im
774774
// Wait for the cell to finish
775775
await finishedAddingCode.promise;
776776
traceInfo(`Finished execution for ${id}`);
777-
778-
// IANHU: Right spot here?
779-
if (debug) {
780-
this.debuggerDetach();
781-
}
782777
}
783778
} catch (err) {
784779
status.dispose();
785780

786781
const message = localize.DataScience.executingCodeFailure().format(err);
787782
this.applicationShell.showErrorMessage(message);
783+
} finally {
784+
if (debug) {
785+
this.debuggerDetach();
786+
}
788787
}
789788
}
790789

@@ -804,13 +803,13 @@ export class InteractiveWindow extends WebViewHost<IInteractiveWindowMapping> im
804803
};
805804

806805
await this.debugService.startDebugging(undefined, config);
807-
}
808806

809-
// tslint:disable-next-line:no-multiline-string
810-
await this.jupyterServer.execute(`import ptvsd\r\nptvsd.wait_for_attach()`, Identifiers.EmptyFileName, 0, uuid(), undefined, true);
807+
// tslint:disable-next-line:no-multiline-string
808+
await this.jupyterServer.execute(`import ptvsd\r\nptvsd.wait_for_attach()`, Identifiers.EmptyFileName, 0, uuid(), undefined, true);
811809

812-
// Then enable tracing
813-
await this.jupyterServer.setDebugTracing(true);
810+
// Then enable tracing
811+
await this.jupyterServer.setDebugTracing(true);
812+
}
814813
}
815814
}
816815

@@ -820,9 +819,8 @@ export class InteractiveWindow extends WebViewHost<IInteractiveWindowMapping> im
820819
await this.jupyterServer.setDebugTracing(false);
821820
}
822821

823-
// Stop our debugging UI session
824-
// IANHU: await not needed here?
825-
await this.commandManager.executeCommand('workbench.action.debug.stop');
822+
// Stop our debugging UI session, no await as we just want it stopped
823+
this.commandManager.executeCommand('workbench.action.debug.stop');
826824
}
827825

828826
private setStatus = (message: string): Disposable => {

src/client/datascience/jupyter/jupyterServer.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,16 +567,16 @@ export class JupyterServerBase implements INotebookServer {
567567
// If our setting for this is turned on, then import the debugger and enable it to attach
568568
if (this.launchInfo && this.launchInfo.enableDebugging) {
569569
this.debuggerConnectInfo = await this.enableDebugging();
570-
traceInfo(this.debuggerConnectInfo.hostName);
571570
}
572571
} catch (e) {
573572
traceWarning(e);
574573
}
575574
}
576575

577-
private async enableDebugging(): Promise<IDebuggerConnectInfo> {
576+
private async enableDebugging(): Promise<IDebuggerConnectInfo | undefined> {
578577
// tslint:disable-next-line:no-multiline-string
579578
const enableDebuggerResults = await this.executeSilently(`import sys\r\nsys.path.append('d:/ptvsd-drop/kdrop/src')\r\nimport os\r\nos.environ["PTVSD_LOG_DIR"] = "d:/note_dbg/logs"\r\nimport ptvsd\r\nptvsd.enable_attach(('localhost', 0))`);
579+
//const enableDebuggerResults = await this.executeSilently(`import ptvsd\r\nptvsd.enable_attach(('localhost', 0))`);
580580

581581
const enableAttachString = enableDebuggerResults.length > 0 ? this.extractStreamOutput(enableDebuggerResults[0]).trimQuotes() : '';
582582
traceInfo(enableAttachString);
@@ -588,8 +588,7 @@ export class JupyterServerBase implements INotebookServer {
588588
return { hostName: debugInfoMatch[1], port: parseInt(debugInfoMatch[2], 10) };
589589
}
590590

591-
// undefined here?
592-
return { hostName: 'localhost', port: 5678 };
591+
return undefined;
593592
}
594593

595594
private combineObservables = (...args: Observable<ICell>[]): Observable<ICell[]> => {

src/client/datascience/types.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,13 @@ export enum InterruptResult {
5050
}
5151

5252
// Information needed to attach our debugger instance
53-
// IANHU Make this a part of launch info?
54-
export interface IDebuggerConnectInfo
55-
{
53+
export interface IDebuggerConnectInfo {
5654
hostName: string;
5755
port: number;
5856
}
5957

6058
// Information used to launch a notebook server
61-
export interface INotebookServerLaunchInfo
62-
{
59+
export interface INotebookServerLaunchInfo {
6360
connectionInfo: IConnection;
6461
currentInterpreter: PythonInterpreter | undefined;
6562
uri: string | undefined; // Different from the connectionInfo as this is the setting used, not the result
@@ -95,7 +92,6 @@ export interface INotebookServer extends IAsyncDisposable {
9592
getSysInfo() : Promise<ICell | undefined>;
9693
setMatplotLibStyle(useDark: boolean) : Promise<void>;
9794
setDebugTracing(tracingOn: boolean): Promise<void>;
98-
// IANHU: Combine with something else
9995
getDebuggerInfo(): Promise<IDebuggerConnectInfo | undefined>;
10096
}
10197

@@ -179,9 +175,6 @@ export interface IInteractiveWindow extends Disposable {
179175
onExecutedCode: Event<string>;
180176
show() : Promise<void>;
181177
addCode(code: string, file: string, line: number, editor?: TextEditor, debug?: boolean) : Promise<void>;
182-
// IANHU combine with add code
183-
//debugCode(code: string, file: string, line: number, editor?: TextEditor): Promise<void>;
184-
// tslint:disable-next-line:no-any
185178
startProgress(): void;
186179
stopProgress(): void;
187180
undoCells(): void;

src/client/telemetry/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ export interface IEventNamePropertyMapping {
338338
[Telemetry.ConnectRemoteSelfCertFailedJupyter]: never | undefined;
339339
[Telemetry.CopySourceCode]: never | undefined;
340340
[Telemetry.DataScienceSettings]: JSONObject;
341+
[Telemetry.DebugCurrentCell]: never | undefined;
341342
[Telemetry.DeleteAllCells]: never | undefined;
342343
[Telemetry.DeleteCell]: never | undefined;
343344
[Telemetry.DisableInteractiveShiftEnter]: never | undefined;

0 commit comments

Comments
 (0)