Skip to content

Commit 08db8b2

Browse files
committed
fix: setup to establishConnection
Signed-off-by: Shuguang Sun <[email protected]>
1 parent 34f219a commit 08db8b2

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

client/src/connection/saspy/index.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Uri, workspace } from "vscode";
44

55
import { ChildProcessWithoutNullStreams, spawn } from "child_process";
66

7-
import { BaseConfig, RunResult } from "..";
7+
import { BaseConfig, LogLineTypeEnum, RunResult } from "..";
88
import {
99
getGlobalStorageUri
1010
} from "../../components/ExtensionContext";
@@ -14,6 +14,19 @@ import { Session } from "../session";
1414
// import { scriptContent } from "./script";
1515
import { LineCodes } from "./types";
1616

17+
const LogLineTypes: LogLineTypeEnum[] = [
18+
"normal",
19+
"hilighted",
20+
"source",
21+
"title",
22+
"byline",
23+
"footnote",
24+
"error",
25+
"warning",
26+
"note",
27+
"message",
28+
];
29+
1730
let sessionInstance: SASPYSession;
1831

1932
/**
@@ -32,7 +45,8 @@ export class SASPYSession extends Session {
3245
private _runReject: ((reason?) => void) | undefined;
3346
private _workDirectory: string;
3447
private _pollingForLogResults: boolean;
35-
48+
private _logLineType = 0;
49+
3650
public set config(value: Config) {
3751
this._config = value;
3852
}
@@ -41,7 +55,7 @@ export class SASPYSession extends Session {
4155
* Initialization logic that should be performed prior to execution.
4256
* @returns void promise.
4357
*/
44-
public setup = async (): Promise<void> => {
58+
protected establishConnection = async (): Promise<void> => {
4559
const setupPromise = new Promise<void>((resolve, reject) => {
4660
this._runResolve = resolve;
4761
this._runReject = reject;
@@ -133,7 +147,6 @@ ll=sas.submit(vscode_saspy_code)
133147
this._shellProcess.stdin.write(`sas\n`);
134148

135149
if (this._config.sasOptions?.length > 0) {
136-
// console.log('sas option');
137150
const sasOptsInput = `$sasOpts=${this.formatSASOptions(
138151
this._config.sasOptions,
139152
)}\n`;
@@ -309,9 +322,9 @@ ${codeWithEnd}
309322
);
310323

311324
if (this._workDirectory) {
312-
this._onExecutionLogFn?.([{ type: "normal", line }]);
325+
this._onExecutionLogFn?.([{ type: this.getLogLineType(), line }]);
313326
} else {
314-
this._onSessionLogFn?.([{ type: "normal", line }]);
327+
this._onSessionLogFn?.([{ type: this.getLogLineType(), line }]);
315328
}
316329
}
317330
});
@@ -334,9 +347,22 @@ ${codeWithEnd}
334347
return true;
335348
}
336349

350+
if (line.includes(LineCodes.LogLineType)) {
351+
const start =
352+
line.indexOf(LineCodes.LogLineType) + LineCodes.LogLineType.length + 1;
353+
this._logLineType = parseInt(line.slice(start, start + 1));
354+
return true;
355+
}
356+
337357
return false;
338358
}
339359

360+
private getLogLineType(): LogLineTypeEnum {
361+
const result = LogLineTypes[this._logLineType];
362+
this._logLineType = 0;
363+
return result;
364+
}
365+
340366
/**
341367
* Generic call for use on stdin write completion.
342368
* @param err The error encountered on the write attempt. Undefined if no error occurred.

client/src/connection/saspy/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export enum LineCodes {
66
RunCancelledCode = "--vscode-sas-extension-run-cancelled--",
77
RunEndCode = "--vscode-sas-extension-submit-end--",
88
SessionCreatedCode = "--vscode-sas-extension-session-created--",
9+
LogLineType = "--vscode-sas-extension-log-line-type--",
910
}

0 commit comments

Comments
 (0)