Skip to content

Commit 37b6ea7

Browse files
Scott DoverScott Dover
authored andcommitted
Merge branch 'feat/sas-server-2' of github.com-ghp:sassoftware/vscode-sas-extension into feat/sas-server-2
2 parents 405e5ec + 0cc24fe commit 37b6ea7

File tree

27 files changed

+448
-315
lines changed

27 files changed

+448
-315
lines changed

.github/workflows/package.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Package VSIX
1+
name: Package and Publish VSIX
22

33
on:
44
workflow_dispatch:
@@ -21,3 +21,21 @@ jobs:
2121
with:
2222
path: ./*.vsix
2323
retention-days: 5
24+
25+
- uses: johnnybenson/[email protected]
26+
id: package-json
27+
with:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
- run: echo "vsixPath=sas-lsp-${{ steps.package-json.outputs.version }}.vsix" >> "$GITHUB_OUTPUT"
30+
id: vsixPath
31+
if: steps.package-json.outputs.has-updated == 'true'
32+
- run: npx @vscode/vsce publish -i ${{ steps.vsixPath.outputs.vsixPath }}
33+
if: steps.package-json.outputs.has-updated == 'true'
34+
env:
35+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
36+
- run: npx ovsx publish ${{ steps.vsixPath.outputs.vsixPath }} -p ${{ secrets.OVSX_PAT }}
37+
if: steps.package-json.outputs.has-updated == 'true'
38+
- run: |
39+
git tag -f v${{ steps.package-json.outputs.version }}
40+
git push -f origin v${{ steps.package-json.outputs.version }}
41+
if: steps.package-json.outputs.has-updated == 'true'

client/package-lock.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"vscode": "^1.82.0"
1010
},
1111
"dependencies": {
12-
"ag-grid-community": "^32.1.0",
13-
"ag-grid-react": "^32.1.0",
14-
"axios": "^1.7.5",
12+
"ag-grid-community": "^32.2.0",
13+
"ag-grid-react": "^32.2.0",
14+
"axios": "^1.7.7",
1515
"media-typer": "^1.1.0",
1616
"react": "^18.3.1",
1717
"react-dom": "^18.3.1",

client/src/commands/run.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ import {
1212
} from "vscode";
1313
import type { BaseLanguageClient } from "vscode-languageclient";
1414

15+
import { basename, extname } from "path";
16+
1517
import { showResult } from "../components/ResultPanel";
1618
import {
1719
appendExecutionLogFn,
1820
appendSessionLogFn,
21+
setFileName,
1922
} from "../components/logViewer";
2023
import { sasDiagnostic } from "../components/logViewer/sasDiagnostics";
2124
import { SASCodeDocument } from "../components/utils/SASCodeDocument";
@@ -112,6 +115,12 @@ async function runCode(selected?: boolean, uri?: Uri) {
112115
session.onExecutionLogFn = onExecutionLogFn;
113116
session.onSessionLogFn = appendSessionLogFn;
114117

118+
const fileName = basename(
119+
codeDoc.getFileName(),
120+
extname(codeDoc.getFileName()),
121+
);
122+
setFileName(fileName);
123+
115124
await session.setup();
116125

117126
await window.withProgress(
@@ -222,6 +231,12 @@ async function _runTask(
222231
);
223232
session.onSessionLogFn = appendSessionLogFn;
224233

234+
const fileName = basename(
235+
codeDoc.getFileName(),
236+
extname(codeDoc.getFileName()),
237+
);
238+
setFileName(fileName);
239+
225240
messageEmitter.fire(`${l10n.t("Connecting to SAS session...")}\r\n`);
226241
!cancelled && (await session.setup(true));
227242

client/src/components/logViewer/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type { OnLogFn } from "../../connection";
1212
import { useLogStore, useRunStore } from "../../store";
1313
import { logSelectors, runSelectors } from "../../store/selectors";
1414
import {
15+
clearLogOnExecutionStart,
1516
showLogOnExecutionFinish,
1617
showLogOnExecutionStart,
1718
} from "../utils/settings";
@@ -20,6 +21,7 @@ const { setProducedExecutionLogOutput } = useLogStore.getState();
2021

2122
let outputChannel: OutputChannel;
2223
let data: string[] = [];
24+
let fileName = "";
2325

2426
export const legend = {
2527
tokenTypes: ["error", "warning", "note"],
@@ -66,9 +68,16 @@ export const appendLogToken = (type: string): void => {
6668
data.push(type);
6769
};
6870

71+
export const setFileName = (name: string) => {
72+
fileName = name;
73+
};
74+
6975
const appendLogLines: OnLogFn = (logs) => {
7076
if (!outputChannel) {
71-
outputChannel = window.createOutputChannel(l10n.t("SAS Log"), "sas-log");
77+
const name = clearLogOnExecutionStart()
78+
? l10n.t("SAS Log: {name}", { name: fileName })
79+
: l10n.t("SAS Log");
80+
outputChannel = window.createOutputChannel(name, "sas-log");
7281
}
7382
for (const line of logs) {
7483
appendLogToken(line.type);
@@ -100,6 +109,12 @@ useRunStore.subscribe(
100109
}
101110
} else if (isExecuting && !prevIsExecuting) {
102111
setProducedExecutionLogOutput(false);
112+
113+
if (clearLogOnExecutionStart() && outputChannel) {
114+
outputChannel.dispose();
115+
outputChannel = undefined;
116+
data = [];
117+
}
103118
}
104119
},
105120
);

client/src/components/logViewer/logParser.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ import {
99
isSourceCodeLineAfterLineWrapping,
1010
} from "./ProblemProcessor";
1111

12-
export function parseLog(
13-
logs: LogLine[],
14-
logStartFlag: string,
15-
): Problem[] | null {
12+
export function parseLog(logs: LogLine[], logStartFlag: string): Problem[] {
1613
if (logs.length === 0 || logStartFlag.trim() === "") {
17-
return null;
14+
return [];
1815
}
1916

2017
// logs cleaning
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright © 2024, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
import { NotebookCell, window, workspace } from "vscode";
4+
5+
export const exportNotebook = async () => {
6+
const notebook = window.activeNotebookEditor?.notebook;
7+
8+
if (!notebook) {
9+
return;
10+
}
11+
12+
const uri = await window.showSaveDialog({
13+
filters: { SAS: ["sas"] },
14+
});
15+
16+
if (!uri) {
17+
return;
18+
}
19+
20+
const content = notebook
21+
.getCells()
22+
.map((cell) => exportCell(cell) + "\n")
23+
.join("\n");
24+
25+
workspace.fs.writeFile(uri, Buffer.from(content));
26+
};
27+
28+
const exportCell = (cell: NotebookCell) => {
29+
const text = cell.document.getText();
30+
switch (cell.document.languageId) {
31+
case "sas":
32+
return text;
33+
case "python":
34+
return wrapPython(text);
35+
case "sql":
36+
return wrapSQL(text);
37+
case "markdown":
38+
return `/*\n${text}\n*/`;
39+
}
40+
};
41+
42+
const wrapSQL = (code: string) => {
43+
if (!code.trimEnd().endsWith(";")) {
44+
code = `${code};`;
45+
}
46+
return `proc sql;
47+
${code}
48+
quit;`;
49+
};
50+
51+
const wrapPython = (code: string) => {
52+
return `proc python;
53+
submit;
54+
${code}
55+
endsubmit;
56+
run;`;
57+
};

client/src/components/tasks/SasTasks.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export async function runSasFileTask(
4747

4848
const textDocument = await getTextDocumentFromFile(file);
4949
const parameters = getCodeDocumentConstructionParameters(textDocument, {
50+
selections:
51+
file === undefined || file.trim() === ""
52+
? window.activeTextEditor?.selections
53+
: undefined,
5054
preamble,
5155
postamble,
5256
});

client/src/components/utils/SASCodeDocument.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export class SASCodeDocument {
3838
return this.parameters.uri;
3939
}
4040

41+
public getFileName(): string {
42+
return this.parameters.fileName;
43+
}
44+
4145
public wrappedCodeLineAt(lineNumber: number) {
4246
return this.getWrappedCode().split("\n")[lineNumber];
4347
}

client/src/components/utils/settings.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export function showLogOnExecutionFinish(): boolean {
2626
return workspace.getConfiguration("SAS").get("log.showOnExecutionFinish");
2727
}
2828

29+
export function clearLogOnExecutionStart(): boolean {
30+
return workspace.getConfiguration("SAS").get("log.clearOnExecutionStart");
31+
}
32+
2933
export function isShowProblemsFromSASLogEnabled(): boolean {
3034
return workspace.getConfiguration("SAS").get("problems.log.enabled");
3135
}

0 commit comments

Comments
 (0)