Skip to content

Commit 54ad364

Browse files
authored
Merge pull request #284 from aeisenberg/aeisenberg/log-files
feat: Save log files per query
2 parents a9eb0a4 + 66e9272 commit 54ad364

24 files changed

+558
-127
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
if: matrix.os == 'windows-latest'
8181
run: |
8282
cd extensions/ql-vscode
83-
$env:CODEQL_PATH=$(Join-Path $env:GITHUB_WORKSPACE -ChildPath 'codeql-home/codeql/codeql.cmd')
83+
$env:CODEQL_PATH=$(Join-Path $env:GITHUB_WORKSPACE -ChildPath 'codeql-home/codeql/codeql.exe')
8484
npm run test
8585
8686
- name: Run integration tests (Linux)

.vscode/launch.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"request": "launch",
99
"runtimeExecutable": "${execPath}",
1010
"args": [
11-
"--extensionDevelopmentPath=${workspaceRoot}/dist/vscode-codeql"
11+
"--extensionDevelopmentPath=${workspaceRoot}/dist/vscode-codeql",
12+
"${workspaceRoot}/../vscode-codeql-starter/vscode-codeql-starter.code-workspace"
1213
],
1314
"stopOnEntry": false,
1415
"sourceMaps": true,

common/config/rush/pnpm-lock.yaml

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

extensions/ql-vscode/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
ecmaFeatures: {
77
modules: true,
88
},
9+
project: ['tsconfig.json', './src/**/tsconfig.json'],
910
},
1011
plugins: ['@typescript-eslint'],
1112
env: {

extensions/ql-vscode/package.json

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"scope": "machine",
100100
"type": "string",
101101
"default": "",
102-
"description": "Path to the CodeQL executable that should be used by the CodeQL extension. The executable is named `codeql` on Linux/Mac and `codeql.cmd` on Windows. This overrides all other CodeQL CLI settings."
102+
"description": "Path to the CodeQL executable that should be used by the CodeQL extension. The executable is named `codeql` on Linux/Mac and `codeql.exe` on Windows. This overrides all other CodeQL CLI settings."
103103
},
104104
"codeQL.runningQueries.numberOfThreads": {
105105
"type": "integer",
@@ -208,6 +208,10 @@
208208
"command": "codeQLQueryHistory.itemClicked",
209209
"title": "Query History Item"
210210
},
211+
{
212+
"command": "codeQLQueryHistory.showQueryLog",
213+
"title": "Show Query Log"
214+
},
211215
{
212216
"command": "codeQLQueryResults.nextPathStep",
213217
"title": "CodeQL: Show Next Step on Path"
@@ -272,6 +276,11 @@
272276
"group": "9_qlCommands",
273277
"when": "view == codeQLQueryHistory"
274278
},
279+
{
280+
"command": "codeQLQueryHistory.showQueryLog",
281+
"group": "9_qlCommands",
282+
"when": "view == codeQLQueryHistory"
283+
},
275284
{
276285
"command": "codeQLTests.showOutputDifferences",
277286
"group": "qltest@1",
@@ -328,6 +337,10 @@
328337
"command": "codeQLQueryHistory.itemClicked",
329338
"when": "false"
330339
},
340+
{
341+
"command": "codeQLQueryHistory.showQueryLog",
342+
"when": "false"
343+
},
331344
{
332345
"command": "codeQLQueryHistory.setLabel",
333346
"when": "false"
@@ -447,6 +460,11 @@
447460
"@typescript-eslint/eslint-plugin": "~2.23.0",
448461
"@typescript-eslint/parser": "~2.23.0",
449462
"chai-as-promised": "~7.1.1",
450-
"@types/chai-as-promised": "~7.1.2"
463+
"@types/chai-as-promised": "~7.1.2",
464+
"@types/sinon": "~7.5.2",
465+
"sinon-chai": "~3.5.0",
466+
"@types/sinon-chai": "~3.2.3",
467+
"proxyquire": "~2.1.3",
468+
"@types/proxyquire": "~1.3.28"
451469
}
452470
}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ export type Entry = File | Directory;
5151
*/
5252
export type DirectoryHierarchyMap = Map<string, Map<string, vscode.FileType>>;
5353

54-
export type ZipFileReference = { sourceArchiveZipPath: string, pathWithinSourceArchive: string };
54+
export type ZipFileReference = {
55+
sourceArchiveZipPath: string;
56+
pathWithinSourceArchive: string;
57+
};
5558

5659
/** Encodes a reference to a source file within a zipped source archive into a single URI. */
5760
export function encodeSourceArchiveUri(ref: ZipFileReference): vscode.Uri {
@@ -169,7 +172,7 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
169172
async readDirectory(uri: vscode.Uri): Promise<[string, vscode.FileType][]> {
170173
const ref = decodeSourceArchiveUri(uri);
171174
const archive = await this.getArchive(ref.sourceArchiveZipPath);
172-
let contents = archive.dirMap.get(ref.pathWithinSourceArchive);
175+
const contents = archive.dirMap.get(ref.pathWithinSourceArchive);
173176
const result = contents === undefined ? [] : Array.from(contents.entries());
174177
if (result === undefined) {
175178
throw vscode.FileSystemError.FileNotFound(uri);
@@ -239,7 +242,7 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
239242
}
240243

241244
private async _lookupAsFile(uri: vscode.Uri): Promise<File> {
242-
let entry = await this._lookup(uri);
245+
const entry = await this._lookup(uri);
243246
if (entry instanceof File) {
244247
return entry;
245248
}

extensions/ql-vscode/src/cli.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,12 @@ export class CodeQLCliServer implements Disposable {
243243
// Kill the process if it isn't already dead.
244244
this.killProcessIfRunning();
245245
// Report the error (if there is a stderr then use that otherwise just report the error cod or nodejs error)
246-
if (stderrBuffers.length == 0) {
247-
throw new Error(`${description} failed: ${err}`)
248-
} else {
249-
throw new Error(`${description} failed: ${Buffer.concat(stderrBuffers).toString("utf8")}`);
250-
}
246+
const newError =
247+
stderrBuffers.length == 0
248+
? new Error(`${description} failed: ${err}`)
249+
: new Error(`${description} failed: ${Buffer.concat(stderrBuffers).toString("utf8")}`);
250+
newError.stack += (err.stack || '');
251+
throw newError;
251252
} finally {
252253
this.logger.log(Buffer.concat(stderrBuffers).toString("utf8"));
253254
// Remove the listeners we set up.
@@ -604,7 +605,7 @@ export class CodeQLCliServer implements Disposable {
604605
resolveQlpacks(additionalPacks: string[], searchPath?: string[]): Promise<QlpacksInfo> {
605606
const args = ['--additional-packs', additionalPacks.join(path.delimiter)];
606607
if (searchPath !== undefined) {
607-
args.push('--search-path', searchPath.join(path.delimiter));
608+
args.push('--search-path', path.join(...searchPath));
608609
}
609610

610611
return this.runJsonCodeQlCliCommand<QlpacksInfo>(

extensions/ql-vscode/src/config.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,19 @@ const DEBUG_SETTING = new Setting('debug', RUNNING_QUERIES_SETTING);
6464
const QUERY_SERVER_RESTARTING_SETTINGS = [NUMBER_OF_THREADS_SETTING, MEMORY_SETTING, DEBUG_SETTING];
6565

6666
export interface QueryServerConfig {
67-
codeQlPath: string,
68-
debug: boolean,
69-
numThreads: number,
70-
queryMemoryMb?: number,
71-
timeoutSecs: number,
67+
codeQlPath: string;
68+
debug: boolean;
69+
numThreads: number;
70+
queryMemoryMb?: number;
71+
timeoutSecs: number;
7272
onDidChangeQueryServerConfiguration?: Event<void>;
7373
}
7474

7575
/** When these settings change, the query history should be refreshed. */
7676
const QUERY_HISTORY_SETTINGS = [QUERY_HISTORY_FORMAT_SETTING];
7777

7878
export interface QueryHistoryConfig {
79-
format: string,
79+
format: string;
8080
onDidChangeQueryHistoryConfiguration: Event<void>;
8181
}
8282

@@ -111,15 +111,15 @@ abstract class ConfigListener extends DisposableObject {
111111

112112
export class DistributionConfigListener extends ConfigListener implements DistributionConfig {
113113
public get customCodeQlPath(): string | undefined {
114-
return CUSTOM_CODEQL_PATH_SETTING.getValue() ? CUSTOM_CODEQL_PATH_SETTING.getValue() : undefined;
114+
return CUSTOM_CODEQL_PATH_SETTING.getValue() || undefined;
115115
}
116116

117117
public get includePrerelease(): boolean {
118118
return INCLUDE_PRERELEASE_SETTING.getValue();
119119
}
120120

121121
public get personalAccessToken(): string | undefined {
122-
return PERSONAL_ACCESS_TOKEN_SETTING.getValue() ? PERSONAL_ACCESS_TOKEN_SETTING.getValue() : undefined;
122+
return PERSONAL_ACCESS_TOKEN_SETTING.getValue() || undefined;
123123
}
124124

125125
public get onDidChangeDistributionConfiguration(): Event<void> {

0 commit comments

Comments
 (0)