Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## Removed

- Removed the "Show AST" and "Show named AST" commands from right-click

## 1.14.0 - 2025-08-22

## Fixed
Expand Down
21 changes: 0 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@
"command": "semgrep.refreshRules",
"title": "Semgrep: Update rules"
},
{
"command": "semgrep.showAst",
"title": "Semgrep: Show AST"
},
{
"command": "semgrep.showAstNamed",
"title": "Semgrep: Show named AST",
"when": "semgrep.cli.minor >= 36 || config.semgrep.ignoreCliVersion"
},
{
"command": "semgrep.search",
"title": "Semgrep: Search by pattern",
Expand Down Expand Up @@ -236,18 +227,6 @@
]
},
"menus": {
"editor/context": [
{
"command": "semgrep.showAst",
"when": "editorTextFocus",
"group": "navigation"
},
{
"command": "semgrep.showAstNamed",
"when": "editorTextFocus",
"group": "navigation"
}
],
"commandPalette": [
{
"command": "semgrep.login",
Expand Down
60 changes: 0 additions & 60 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
logout,
refreshRules,
scanWorkspace,
showAst,
} from "./lspExtensions";
import { handleSearch } from "./search";
import { encodeUri } from "./showAstDocument";
import { applyFixAndSave, isRealFileEditor, replaceAll } from "./utils";

Check warning on line 15 in src/commands.ts

View workflow job for this annotation

GitHub Actions / vsce-test (ubuntu-latest)

'isRealFileEditor' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 15 in src/commands.ts

View workflow job for this annotation

GitHub Actions / vsce-test (ubuntu-latest)

'isRealFileEditor' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 15 in src/commands.ts

View workflow job for this annotation

GitHub Actions / vsce-test (macos-latest)

'isRealFileEditor' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 15 in src/commands.ts

View workflow job for this annotation

GitHub Actions / vsce-test (macos-latest)

'isRealFileEditor' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 15 in src/commands.ts

View workflow job for this annotation

GitHub Actions / vsce-test-windows

'isRealFileEditor' is defined but never used. Allowed unused vars must match /^_/u
import type { ViewResults } from "./webviews/types/results";
import { setupMcp } from "./mcp";
import fs from "fs";
Expand All @@ -33,26 +31,6 @@
See `package.json` which also defines where some of these commands are used.
*/

/*****************************************************************************/
/* Helpers */
/*****************************************************************************/

// We need to do this, or openTextDocument will open the same text document, if previously
// opened. This means that running showAst twice will always show the same thing.
async function replaceAndOpenUriContent(
uri: vscode.Uri,
content: string,
active_editor: vscode.TextEditor,
): Promise<void> {
const doc = await vscode.workspace.openTextDocument(uri);
const edit = new vscode.WorkspaceEdit();
edit.replace(uri, new vscode.Range(0, 0, doc.lineCount, 0), content);
vscode.workspace.applyEdit(edit);
if (active_editor.viewColumn) {
vscode.window.showTextDocument(doc, active_editor.viewColumn + 1 || 0);
}
}

/*****************************************************************************/
/* Commands */
/*****************************************************************************/
Expand Down Expand Up @@ -178,44 +156,6 @@
return "Refreshed rules";
}),

/************/
/* SHOW AST */
/************/

vscode.commands.registerCommand("semgrep.showAstNamed", async () => {
if (
!isRealFileEditor(vscode.window.activeTextEditor) ||
!vscode.window.activeTextEditor
) {
return;
}
if (env.client) {
const ast_text = await env.client.sendRequest(showAst, {
named: true,
uri: vscode.window.activeTextEditor?.document.uri.fsPath,
});
const uri = encodeUri(vscode.window.activeTextEditor.document.uri);

replaceAndOpenUriContent(uri, ast_text, vscode.window.activeTextEditor);
}
}),
vscode.commands.registerCommand("semgrep.showAst", async () => {
if (
!isRealFileEditor(vscode.window.activeTextEditor) ||
!vscode.window.activeTextEditor
) {
return;
}
if (env.client) {
const ast_text = await env.client.sendRequest(showAst, {
named: false,
uri: vscode.window.activeTextEditor?.document.uri.fsPath,
});
const uri = encodeUri(vscode.window.activeTextEditor.document.uri);
replaceAndOpenUriContent(uri, ast_text, vscode.window.activeTextEditor);
}
}),

/**********/
/* SEARCH */
/**********/
Expand Down
5 changes: 1 addition & 4 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from "vscode";
import type { LanguageClient } from "vscode-languageclient/node";
import { VSCODE_CONFIG_KEY, VSCODE_EXT_NAME } from "./constants";
import { SemgrepDocumentProvider } from "./showAstDocument";
import { Logger } from "./utils";
import type { SemgrepSearchWebviewProvider } from "./views/webview";
import { NodeSDK } from "@opentelemetry/sdk-node";
Expand Down Expand Up @@ -107,7 +106,6 @@ export class Environment {
private _provider: SemgrepSearchWebviewProvider | null = null;
private constructor(
readonly context: ExtensionContext,
readonly documentView: SemgrepDocumentProvider,
readonly channel: OutputChannel,
readonly logger: Logger,
public config: Config,
Expand Down Expand Up @@ -211,8 +209,7 @@ export class Environment {
const config = await Environment.loadConfig(context);
const channel = window.createOutputChannel(VSCODE_EXT_NAME);
const logger = new Logger(config.trace, channel);
const documentView = new SemgrepDocumentProvider();
return new Environment(context, documentView, channel, logger, config);
return new Environment(context, channel, logger, config);
}

static async loadConfig(context: ExtensionContext): Promise<Config> {
Expand Down
8 changes: 0 additions & 8 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import { type ConfigurationChangeEvent, type ExtensionContext } from "vscode";
import { registerCommands } from "./commands";
import { VSCODE_CONFIG_KEY } from "./constants";
import { DeploymentInfo, Environment } from "./env";

Check warning on line 6 in src/extension.ts

View workflow job for this annotation

GitHub Actions / vsce-test (ubuntu-latest)

'DeploymentInfo' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 6 in src/extension.ts

View workflow job for this annotation

GitHub Actions / vsce-test (ubuntu-latest)

'DeploymentInfo' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 6 in src/extension.ts

View workflow job for this annotation

GitHub Actions / vsce-test (macos-latest)

'DeploymentInfo' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 6 in src/extension.ts

View workflow job for this annotation

GitHub Actions / vsce-test (macos-latest)

'DeploymentInfo' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 6 in src/extension.ts

View workflow job for this annotation

GitHub Actions / vsce-test-windows

'DeploymentInfo' is defined but never used. Allowed unused vars must match /^_/u
import { activateLsp, deactivateLsp, restartLsp } from "./lsp";
import { SemgrepDocumentProvider } from "./showAstDocument";
import { createStatusBar } from "./statusBar";
import { initTelemetry, stopTelemetry } from "./telemetry/telemetry";
import { deregisterExistingOtel, withSpan } from "./utilities/tracing";
Expand Down Expand Up @@ -69,13 +68,6 @@
),
);

// register content provider for the AST showing document
context.subscriptions.push(
vscode.workspace.registerTextDocumentContentProvider(
SemgrepDocumentProvider.scheme,
env.documentView,
),
);
// Handle configuration changes
context.subscriptions.push(
vscode.workspace.onDidChangeConfiguration(
Expand Down
9 changes: 0 additions & 9 deletions src/lspExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ export interface ScanWorkspaceParams {
full?: boolean;
}

export type ShowAstParams = {
named: boolean;
uri: string;
};

export const scanWorkspace = new lc.NotificationType<ScanWorkspaceParams>(
"semgrep/scanWorkspace",
);
Expand Down Expand Up @@ -85,7 +80,3 @@ export const search = new lc.RequestType<LspSearchParams, SearchResults, void>(
export const searchOngoing = new lc.RequestType0<SearchResults, void>(
"semgrep/searchOngoing",
);

export const showAst = new lc.RequestType<ShowAstParams, string, void>(
"semgrep/showAst",
);
25 changes: 0 additions & 25 deletions src/showAstDocument.ts

This file was deleted.

Loading