Skip to content

Commit 3427c1d

Browse files
authored
chore: kill show AST commands (#262)
* kill show AST commands * changelog * remove more show ast stuff * remove show ast bloat * fix changelog
1 parent a35b5c5 commit 3427c1d

File tree

7 files changed

+5
-127
lines changed

7 files changed

+5
-127
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## Removed
11+
12+
- Removed the "Show AST" and "Show named AST" commands from right-click
13+
1014
## 1.14.0 - 2025-08-22
1115

1216
## Fixed

package.json

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,6 @@
5959
"command": "semgrep.refreshRules",
6060
"title": "Semgrep: Update rules"
6161
},
62-
{
63-
"command": "semgrep.showAst",
64-
"title": "Semgrep: Show AST"
65-
},
66-
{
67-
"command": "semgrep.showAstNamed",
68-
"title": "Semgrep: Show named AST",
69-
"when": "semgrep.cli.minor >= 36 || config.semgrep.ignoreCliVersion"
70-
},
7162
{
7263
"command": "semgrep.search",
7364
"title": "Semgrep: Search by pattern",
@@ -236,18 +227,6 @@
236227
]
237228
},
238229
"menus": {
239-
"editor/context": [
240-
{
241-
"command": "semgrep.showAst",
242-
"when": "editorTextFocus",
243-
"group": "navigation"
244-
},
245-
{
246-
"command": "semgrep.showAstNamed",
247-
"when": "editorTextFocus",
248-
"group": "navigation"
249-
}
250-
],
251230
"commandPalette": [
252231
{
253232
"command": "semgrep.login",

src/commands.ts

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ import {
1010
logout,
1111
refreshRules,
1212
scanWorkspace,
13-
showAst,
1413
} from "./lspExtensions";
1514
import { handleSearch } from "./search";
16-
import { encodeUri } from "./showAstDocument";
1715
import { applyFixAndSave, isRealFileEditor, replaceAll } from "./utils";
1816
import type { ViewResults } from "./webviews/types/results";
1917
import { setupMcp } from "./mcp";
@@ -33,26 +31,6 @@ import path from "node:path";
3331
See `package.json` which also defines where some of these commands are used.
3432
*/
3533

36-
/*****************************************************************************/
37-
/* Helpers */
38-
/*****************************************************************************/
39-
40-
// We need to do this, or openTextDocument will open the same text document, if previously
41-
// opened. This means that running showAst twice will always show the same thing.
42-
async function replaceAndOpenUriContent(
43-
uri: vscode.Uri,
44-
content: string,
45-
active_editor: vscode.TextEditor,
46-
): Promise<void> {
47-
const doc = await vscode.workspace.openTextDocument(uri);
48-
const edit = new vscode.WorkspaceEdit();
49-
edit.replace(uri, new vscode.Range(0, 0, doc.lineCount, 0), content);
50-
vscode.workspace.applyEdit(edit);
51-
if (active_editor.viewColumn) {
52-
vscode.window.showTextDocument(doc, active_editor.viewColumn + 1 || 0);
53-
}
54-
}
55-
5634
/*****************************************************************************/
5735
/* Commands */
5836
/*****************************************************************************/
@@ -178,44 +156,6 @@ export function registerCommands(env: Environment): Disposable[] {
178156
return "Refreshed rules";
179157
}),
180158

181-
/************/
182-
/* SHOW AST */
183-
/************/
184-
185-
vscode.commands.registerCommand("semgrep.showAstNamed", async () => {
186-
if (
187-
!isRealFileEditor(vscode.window.activeTextEditor) ||
188-
!vscode.window.activeTextEditor
189-
) {
190-
return;
191-
}
192-
if (env.client) {
193-
const ast_text = await env.client.sendRequest(showAst, {
194-
named: true,
195-
uri: vscode.window.activeTextEditor?.document.uri.fsPath,
196-
});
197-
const uri = encodeUri(vscode.window.activeTextEditor.document.uri);
198-
199-
replaceAndOpenUriContent(uri, ast_text, vscode.window.activeTextEditor);
200-
}
201-
}),
202-
vscode.commands.registerCommand("semgrep.showAst", async () => {
203-
if (
204-
!isRealFileEditor(vscode.window.activeTextEditor) ||
205-
!vscode.window.activeTextEditor
206-
) {
207-
return;
208-
}
209-
if (env.client) {
210-
const ast_text = await env.client.sendRequest(showAst, {
211-
named: false,
212-
uri: vscode.window.activeTextEditor?.document.uri.fsPath,
213-
});
214-
const uri = encodeUri(vscode.window.activeTextEditor.document.uri);
215-
replaceAndOpenUriContent(uri, ast_text, vscode.window.activeTextEditor);
216-
}
217-
}),
218-
219159
/**********/
220160
/* SEARCH */
221161
/**********/

src/env.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
} from "vscode";
1212
import type { LanguageClient } from "vscode-languageclient/node";
1313
import { VSCODE_CONFIG_KEY, VSCODE_EXT_NAME } from "./constants";
14-
import { SemgrepDocumentProvider } from "./showAstDocument";
1514
import { Logger } from "./utils";
1615
import type { SemgrepSearchWebviewProvider } from "./views/webview";
1716
import { NodeSDK } from "@opentelemetry/sdk-node";
@@ -107,7 +106,6 @@ export class Environment {
107106
private _provider: SemgrepSearchWebviewProvider | null = null;
108107
private constructor(
109108
readonly context: ExtensionContext,
110-
readonly documentView: SemgrepDocumentProvider,
111109
readonly channel: OutputChannel,
112110
readonly logger: Logger,
113111
public config: Config,
@@ -211,8 +209,7 @@ export class Environment {
211209
const config = await Environment.loadConfig(context);
212210
const channel = window.createOutputChannel(VSCODE_EXT_NAME);
213211
const logger = new Logger(config.trace, channel);
214-
const documentView = new SemgrepDocumentProvider();
215-
return new Environment(context, documentView, channel, logger, config);
212+
return new Environment(context, channel, logger, config);
216213
}
217214

218215
static async loadConfig(context: ExtensionContext): Promise<Config> {

src/extension.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { registerCommands } from "./commands";
55
import { VSCODE_CONFIG_KEY } from "./constants";
66
import { DeploymentInfo, Environment } from "./env";
77
import { activateLsp, deactivateLsp, restartLsp } from "./lsp";
8-
import { SemgrepDocumentProvider } from "./showAstDocument";
98
import { createStatusBar } from "./statusBar";
109
import { initTelemetry, stopTelemetry } from "./telemetry/telemetry";
1110
import { deregisterExistingOtel, withSpan } from "./utilities/tracing";
@@ -69,13 +68,6 @@ async function afterClientStart(context: ExtensionContext, env: Environment) {
6968
),
7069
);
7170

72-
// register content provider for the AST showing document
73-
context.subscriptions.push(
74-
vscode.workspace.registerTextDocumentContentProvider(
75-
SemgrepDocumentProvider.scheme,
76-
env.documentView,
77-
),
78-
);
7971
// Handle configuration changes
8072
context.subscriptions.push(
8173
vscode.workspace.onDidChangeConfiguration(

src/lspExtensions.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ export interface ScanWorkspaceParams {
1212
full?: boolean;
1313
}
1414

15-
export type ShowAstParams = {
16-
named: boolean;
17-
uri: string;
18-
};
19-
2015
export const scanWorkspace = new lc.NotificationType<ScanWorkspaceParams>(
2116
"semgrep/scanWorkspace",
2217
);
@@ -85,7 +80,3 @@ export const search = new lc.RequestType<LspSearchParams, SearchResults, void>(
8580
export const searchOngoing = new lc.RequestType0<SearchResults, void>(
8681
"semgrep/searchOngoing",
8782
);
88-
89-
export const showAst = new lc.RequestType<ShowAstParams, string, void>(
90-
"semgrep/showAst",
91-
);

src/showAstDocument.ts

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

0 commit comments

Comments
 (0)