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
2 changes: 2 additions & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [UNRELEASED]

- Fix a bug where invoking _View AST_ from the file explorer would not view the selected file. Instead it would view the active editor. Also, prevent the _View AST_ from appearing if the current selection includes a directory or multiple files. [#1113](https://github.com/github/vscode-codeql/pull/1113)

## 1.5.10 - 25 January 2022

- Fix a bug where the results view moved column even when it was already visible. [#1070](https://github.com/github/vscode-codeql/pull/1070)
Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@
{
"command": "codeQL.viewAst",
"group": "9_qlCommands",
"when": "resourceScheme == codeql-zip-archive"
"when": "resourceScheme == codeql-zip-archive && !explorerResourceIsFolder && !listMultiSelection"
},
{
"command": "codeQL.runQueries",
Expand Down
11 changes: 6 additions & 5 deletions extensions/ql-vscode/src/contextual/templateProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TextDocument,
Uri
} from 'vscode';
import * as path from 'path';

import { decodeSourceArchiveUri, encodeArchiveBasePath, zipArchiveScheme } from '../archive-filesystem-provider';
import { CodeQLCliServer } from '../cli';
Expand Down Expand Up @@ -142,19 +143,19 @@ export class TemplatePrintAstProvider {
async provideAst(
progress: ProgressCallback,
token: CancellationToken,
document?: TextDocument
fileUri?: Uri
): Promise<AstBuilder | undefined> {
if (!document) {
if (!fileUri) {
throw new Error('Cannot view the AST. Please select a valid source file inside a CodeQL database.');
}
const { query, dbUri } = this.shouldCache()
? await this.cache.get(document.uri.toString(), progress, token)
: await this.getAst(document.uri.toString(), progress, token);
? await this.cache.get(fileUri.toString(), progress, token)
: await this.getAst(fileUri.toString(), progress, token);

return new AstBuilder(
query, this.cli,
this.dbm.findDatabaseItem(dbUri)!,
document.fileName
path.basename(fileUri.fsPath),
);
}

Expand Down
13 changes: 8 additions & 5 deletions extensions/ql-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -968,9 +968,11 @@ async function activateWithInstalledDistribution(
}
));

commands.registerCommand('codeQL.showLogs', () => {
logger.show();
});
ctx.subscriptions.push(
commandRunner('codeQL.showLogs', async () => {
logger.show();
})
);

void logger.log('Starting language server.');
ctx.subscriptions.push(client.start());
Expand All @@ -993,12 +995,13 @@ async function activateWithInstalledDistribution(
ctx.subscriptions.push(astViewer);
ctx.subscriptions.push(commandRunnerWithProgress('codeQL.viewAst', async (
progress: ProgressCallback,
token: CancellationToken
token: CancellationToken,
selectedFile: Uri
) => {
const ast = await templateProvider.provideAst(
progress,
token,
window.activeTextEditor?.document,
selectedFile ?? window.activeTextEditor?.document.uri,
);
if (ast) {
astViewer.updateRoots(await ast.getRoots(), ast.db, ast.fileName);
Expand Down