Skip to content

Commit 55d1a4a

Browse files
author
Dave Bartolomeo
committed
Merge from master
2 parents 2f9a314 + d4f3c91 commit 55d1a4a

28 files changed

Lines changed: 248 additions & 81 deletions

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,5 @@ jobs:
108108
title: Bump version to ${{ steps.bump-patch-version.outputs.next_version }}
109109
body: This PR was automatically generated by the GitHub Actions release workflow in this repository.
110110
branch: ${{ format('version/bump-to-{0}', steps.bump-patch-version.outputs.next_version) }}
111-
branch-suffix: none
111+
branch-suffix: none
112+
base: master

configs/typescript-config/common.tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"preserveWatchOutput": true,
1616
"newLine": "lf",
1717
"noImplicitReturns": true,
18-
"experimentalDecorators": true
18+
"experimentalDecorators": true,
19+
"noUnusedLocals": true,
20+
"noUnusedParameters": true
1921
},
2022
"include": [
2123
"../../src/**/*.ts"

extensions/ql-vscode/CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# CodeQL for Visual Studio Code: Changelog
22

3+
## 1.0.2 - 13 December 2019
4+
5+
- Fix rendering of negative numbers in results.
6+
- Allow customization of query history labels from settings and from
7+
query history view context menu.
8+
- Show number of results in results view.
9+
- Add commands `CodeQL: Show Next Step on Path` and `CodeQL: Show
10+
Previous Step on Path` for navigating the steps on the currently
11+
shown path result.
12+
313
## 1.0.1 - 21 November 2019
414

515
- Change `codeQL.cli.executablePath` to a per-machine setting, so it can no longer be set at the user or workspace level. This helps prevent arbitrary code execution when using a VS Code workspace from an untrusted source.
@@ -11,4 +21,4 @@
1121

1222
## 1.0.0 - 14 November 2019
1323

14-
Initial release of CodeQL for Visual Studio Code.
24+
Initial release of CodeQL for Visual Studio Code.
1.79 KB
Loading

extensions/ql-vscode/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@
122122
"default": false,
123123
"description": "Enable debug logging and tuple counting when running CodeQL queries. This information is useful for debugging query performance."
124124
},
125+
"codeQL.queryHistory.format": {
126+
"type": "string",
127+
"default": "[%t] %q on %d - %s",
128+
"description": "Default string for how to label query history items. %t is the time of the query, %q is the query name, %d is the database name, and %s is a status string."
129+
},
125130
"codeQL.tests.semmleCoreDistributionPath": {
126131
"scope": "window",
127132
"type": "string",
@@ -205,6 +210,10 @@
205210
"command": "codeQLQueryResults.previousPathStep",
206211
"title": "CodeQL: Show Previous Step on Path"
207212
},
213+
{
214+
"command": "codeQLQueryHistory.setLabel",
215+
"title": "Set Label"
216+
},
208217
{
209218
"command": "codeQLTests.showOutputDifferences",
210219
"title": "CodeQL: Show Test Output Differences"
@@ -248,6 +257,11 @@
248257
"group": "9_qlCommands",
249258
"when": "view == codeQLQueryHistory"
250259
},
260+
{
261+
"command": "codeQLQueryHistory.setLabel",
262+
"group": "9_qlCommands",
263+
"when": "view == codeQLQueryHistory"
264+
},
251265
{
252266
"command": "codeQLTests.showOutputDifferences",
253267
"group": "qltest@1",
@@ -303,6 +317,10 @@
303317
{
304318
"command": "codeQLQueryHistory.itemClicked",
305319
"when": "false"
320+
},
321+
{
322+
"command": "codeQLQueryHistory.setLabel",
323+
"when": "false"
306324
}
307325
],
308326
"editor/context": [

extensions/ql-vscode/src/archive-filesystem-provider.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
163163
// metadata
164164

165165
async stat(uri: vscode.Uri): Promise<vscode.FileStat> {
166-
return await this._lookup(uri, false);
166+
return await this._lookup(uri);
167167
}
168168

169169
async readDirectory(uri: vscode.Uri): Promise<[string, vscode.FileType][]> {
@@ -180,7 +180,7 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
180180
// file contents
181181

182182
async readFile(uri: vscode.Uri): Promise<Uint8Array> {
183-
const data = (await this._lookupAsFile(uri, false)).data;
183+
const data = (await this._lookupAsFile(uri)).data;
184184
if (data) {
185185
return data;
186186
}
@@ -189,25 +189,25 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
189189

190190
// write operations, all disabled
191191

192-
writeFile(uri: vscode.Uri, content: Uint8Array, options: { create: boolean, overwrite: boolean }): void {
192+
writeFile(_uri: vscode.Uri, _content: Uint8Array, _options: { create: boolean, overwrite: boolean }): void {
193193
throw this.readOnlyError;
194194
}
195195

196-
rename(oldUri: vscode.Uri, newUri: vscode.Uri, options: { overwrite: boolean }): void {
196+
rename(_oldUri: vscode.Uri, _newUri: vscode.Uri, _options: { overwrite: boolean }): void {
197197
throw this.readOnlyError;
198198
}
199199

200-
delete(uri: vscode.Uri): void {
200+
delete(_uri: vscode.Uri): void {
201201
throw this.readOnlyError;
202202
}
203203

204-
createDirectory(uri: vscode.Uri): void {
204+
createDirectory(_uri: vscode.Uri): void {
205205
throw this.readOnlyError;
206206
}
207207

208208
// content lookup
209209

210-
private async _lookup(uri: vscode.Uri, silent: boolean): Promise<Entry> {
210+
private async _lookup(uri: vscode.Uri): Promise<Entry> {
211211
const ref = decodeSourceArchiveUri(uri);
212212
const archive = await this.getArchive(ref.sourceArchiveZipPath);
213213

@@ -238,8 +238,8 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
238238
throw vscode.FileSystemError.FileNotFound(uri);
239239
}
240240

241-
private async _lookupAsFile(uri: vscode.Uri, silent: boolean): Promise<File> {
242-
let entry = await this._lookup(uri, silent);
241+
private async _lookupAsFile(uri: vscode.Uri): Promise<File> {
242+
let entry = await this._lookup(uri);
243243
if (entry instanceof File) {
244244
return entry;
245245
}

extensions/ql-vscode/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class CodeQLCliServer implements Disposable {
161161
if (!config) {
162162
throw new Error("Failed to find codeql distribution")
163163
}
164-
return spawnServer(config, "CodeQL CLI Server", ["execute", "cli-server"], [], this.logger, data => { })
164+
return spawnServer(config, "CodeQL CLI Server", ["execute", "cli-server"], [], this.logger, _data => {})
165165
}
166166

167167
private async runCodeQlCliInternal(command: string[], commandArgs: string[], description: string): Promise<string> {

extensions/ql-vscode/src/config.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const DISTRIBUTION_SETTING = new Setting('cli', ROOT_SETTING);
3737
const CUSTOM_CODEQL_PATH_SETTING = new Setting('executablePath', DISTRIBUTION_SETTING);
3838
const INCLUDE_PRERELEASE_SETTING = new Setting('includePrerelease', DISTRIBUTION_SETTING);
3939
const PERSONAL_ACCESS_TOKEN_SETTING = new Setting('personalAccessToken', DISTRIBUTION_SETTING);
40+
const QUERY_HISTORY_SETTING = new Setting('queryHistory', ROOT_SETTING);
41+
const QUERY_HISTORY_FORMAT_SETTING = new Setting('format', QUERY_HISTORY_SETTING);
4042

4143
/** When these settings change, the distribution should be updated. */
4244
const DISTRIBUTION_CHANGE_SETTINGS = [CUSTOM_CODEQL_PATH_SETTING, INCLUDE_PRERELEASE_SETTING, PERSONAL_ACCESS_TOKEN_SETTING];
@@ -70,6 +72,14 @@ export interface QueryServerConfig {
7072
onDidChangeQueryServerConfiguration?: Event<void>;
7173
}
7274

75+
/** When these settings change, the query history should be refreshed. */
76+
const QUERY_HISTORY_SETTINGS = [QUERY_HISTORY_FORMAT_SETTING];
77+
78+
export interface QueryHistoryConfig {
79+
format: string,
80+
onDidChangeQueryHistoryConfiguration: Event<void>;
81+
}
82+
7383
abstract class ConfigListener extends DisposableObject {
7484
protected readonly _onDidChangeConfiguration = this.push(new EventEmitter<void>());
7585

@@ -176,3 +186,17 @@ export class QueryServerConfigListener extends ConfigListener implements QuerySe
176186
this.handleDidChangeConfigurationForRelevantSettings(QUERY_SERVER_RESTARTING_SETTINGS, e);
177187
}
178188
}
189+
190+
export class QueryHistoryConfigListener extends ConfigListener implements QueryHistoryConfig {
191+
protected handleDidChangeConfiguration(e: ConfigurationChangeEvent): void {
192+
this.handleDidChangeConfigurationForRelevantSettings(QUERY_HISTORY_SETTINGS, e);
193+
}
194+
195+
public get onDidChangeQueryHistoryConfiguration(): Event<void> {
196+
return this._onDidChangeConfiguration.event;
197+
}
198+
199+
public get format(): string {
200+
return QUERY_HISTORY_FORMAT_SETTING.getValue<string>();
201+
}
202+
}

extensions/ql-vscode/src/databases-ui.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class DatabaseTreeDataProvider extends DisposableObject
9090
}
9191
}
9292

93-
public getParent(element: DatabaseItem): ProviderResult<DatabaseItem> {
93+
public getParent(_element: DatabaseItem): ProviderResult<DatabaseItem> {
9494
return null;
9595
}
9696

@@ -128,7 +128,7 @@ async function chooseDatabaseDir(): Promise<Uri | undefined> {
128128
}
129129

130130
export class DatabaseUI extends DisposableObject {
131-
public constructor(private ctx: ExtensionContext, private cliserver: cli.CodeQLCliServer, private databaseManager: DatabaseManager,
131+
public constructor(ctx: ExtensionContext, private cliserver: cli.CodeQLCliServer, private databaseManager: DatabaseManager,
132132
private readonly queryServer: qsClient.QueryServerClient | undefined) {
133133

134134
super();

extensions/ql-vscode/src/databases.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ export interface DatabaseItem {
227227
resolveSourceFile(file: string | undefined): vscode.Uri;
228228

229229
/**
230-
* Holds if the database item has a `.dbinfo` file.
230+
* Holds if the database item has a `.dbinfo` or `codeql-database.yml` file.
231231
*/
232-
hasDbInfo(): boolean;
232+
hasMetadataFile(): Promise<boolean>;
233233

234234
/**
235235
* Returns `sourceLocationPrefix` of exported database.
@@ -359,9 +359,11 @@ class DatabaseItemImpl implements DatabaseItem {
359359
/**
360360
* Holds if the database item refers to an exported snapshot
361361
*/
362-
public hasDbInfo(): boolean {
363-
return fs.existsSync(path.join(this.databaseUri.fsPath, '.dbinfo'))
364-
|| fs.existsSync(path.join(this.databaseUri.fsPath, 'codeql-database.yml'));;
362+
public async hasMetadataFile(): Promise<boolean> {
363+
return (await Promise.all([
364+
fs.pathExists(path.join(this.databaseUri.fsPath, '.dbinfo')),
365+
fs.pathExists(path.join(this.databaseUri.fsPath, 'codeql-database.yml'))
366+
])).some(x => x);
365367
}
366368

367369
/**
@@ -413,7 +415,7 @@ class DatabaseItemImpl implements DatabaseItem {
413415
* >1000ms) log a warning, and resolve to undefined.
414416
*/
415417
function eventFired<T>(event: vscode.Event<T>, timeoutMs: number = 1000): Promise<T | undefined> {
416-
return new Promise((res, rej) => {
418+
return new Promise((res, _rej) => {
417419
let timeout: NodeJS.Timeout | undefined;
418420
let disposable: vscode.Disposable | undefined;
419421
function dispose() {

0 commit comments

Comments
 (0)