Re-apply formatting to all files
This commit is contained in:
@@ -580,7 +580,7 @@
|
||||
"integration": "node ./out/vscode-tests/run-integration-tests.js",
|
||||
"update-vscode": "node ./node_modules/vscode/bin/install",
|
||||
"postinstall": "npm rebuild && node ./node_modules/vscode/bin/install",
|
||||
"format": "tsfmt -r",
|
||||
"format": "tsfmt -r && eslint src test --ext .ts,.tsx --fix",
|
||||
"lint": "eslint src test --ext .ts,.tsx --max-warnings=0",
|
||||
"format-staged": "lint-staged"
|
||||
},
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import { DisposableObject } from "semmle-vscode-utils";
|
||||
import { DisposableObject } from '@github/codeql-vscode-utils';
|
||||
import {
|
||||
WebviewPanel,
|
||||
ExtensionContext,
|
||||
window as Window,
|
||||
ViewColumn,
|
||||
Uri,
|
||||
} from "vscode";
|
||||
import * as path from "path";
|
||||
} from 'vscode';
|
||||
import * as path from 'path';
|
||||
|
||||
import { tmpDir } from "../run-queries";
|
||||
import { CompletedQuery } from "../query-results";
|
||||
import { tmpDir } from '../run-queries';
|
||||
import { CompletedQuery } from '../query-results';
|
||||
import {
|
||||
FromCompareViewMessage,
|
||||
ToCompareViewMessage,
|
||||
QueryCompareResult,
|
||||
} from "../interface-types";
|
||||
import { Logger } from "../logging";
|
||||
import { CodeQLCliServer } from "../cli";
|
||||
import { DatabaseManager } from "../databases";
|
||||
import { getHtmlForWebview, jumpToLocation } from "../interface-utils";
|
||||
import { adaptSchema, adaptBqrs, RawResultSet } from "../adapt";
|
||||
import { BQRSInfo } from "../bqrs-cli-types";
|
||||
import resultsDiff from "./resultsDiff";
|
||||
} from '../interface-types';
|
||||
import { Logger } from '../logging';
|
||||
import { CodeQLCliServer } from '../cli';
|
||||
import { DatabaseManager } from '../databases';
|
||||
import { getHtmlForWebview, jumpToLocation } from '../interface-utils';
|
||||
import { adaptSchema, adaptBqrs, RawResultSet } from '../adapt';
|
||||
import { BQRSInfo } from '../bqrs-cli-types';
|
||||
import resultsDiff from './resultsDiff';
|
||||
|
||||
interface ComparePair {
|
||||
from: CompletedQuery;
|
||||
@@ -67,7 +67,7 @@ export class CompareInterfaceManager extends DisposableObject {
|
||||
);
|
||||
if (currentResultSetName) {
|
||||
await this.postMessage({
|
||||
t: "setComparisons",
|
||||
t: 'setComparisons',
|
||||
stats: {
|
||||
fromQuery: {
|
||||
// since we split the description into several rows
|
||||
@@ -100,8 +100,8 @@ export class CompareInterfaceManager extends DisposableObject {
|
||||
if (this.panel == undefined) {
|
||||
const { ctx } = this;
|
||||
const panel = (this.panel = Window.createWebviewPanel(
|
||||
"compareView",
|
||||
"Compare CodeQL Query Results",
|
||||
'compareView',
|
||||
'Compare CodeQL Query Results',
|
||||
{ viewColumn: ViewColumn.Active, preserveFocus: true },
|
||||
{
|
||||
enableScripts: true,
|
||||
@@ -109,7 +109,7 @@ export class CompareInterfaceManager extends DisposableObject {
|
||||
retainContextWhenHidden: true,
|
||||
localResourceRoots: [
|
||||
Uri.file(tmpDir.name),
|
||||
Uri.file(path.join(this.ctx.extensionPath, "out")),
|
||||
Uri.file(path.join(this.ctx.extensionPath, 'out')),
|
||||
],
|
||||
}
|
||||
));
|
||||
@@ -123,11 +123,11 @@ export class CompareInterfaceManager extends DisposableObject {
|
||||
);
|
||||
|
||||
const scriptPathOnDisk = Uri.file(
|
||||
ctx.asAbsolutePath("out/compareView.js")
|
||||
ctx.asAbsolutePath('out/compareView.js')
|
||||
);
|
||||
|
||||
const stylesheetPathOnDisk = Uri.file(
|
||||
ctx.asAbsolutePath("out/resultsView.css")
|
||||
ctx.asAbsolutePath('out/resultsView.css')
|
||||
);
|
||||
|
||||
panel.webview.html = getHtmlForWebview(
|
||||
@@ -158,21 +158,21 @@ export class CompareInterfaceManager extends DisposableObject {
|
||||
msg: FromCompareViewMessage
|
||||
): Promise<void> {
|
||||
switch (msg.t) {
|
||||
case "compareViewLoaded":
|
||||
case 'compareViewLoaded':
|
||||
this.panelLoaded = true;
|
||||
this.panelLoadedCallBacks.forEach((cb) => cb());
|
||||
this.panelLoadedCallBacks = [];
|
||||
break;
|
||||
|
||||
case "changeCompare":
|
||||
case 'changeCompare':
|
||||
this.changeTable(msg.newResultSetName);
|
||||
break;
|
||||
|
||||
case "viewSourceFile":
|
||||
case 'viewSourceFile':
|
||||
await jumpToLocation(msg, this.databaseManager, this.logger);
|
||||
break;
|
||||
|
||||
case "openQuery":
|
||||
case 'openQuery':
|
||||
await this.openQuery(msg.kind);
|
||||
break;
|
||||
}
|
||||
@@ -193,10 +193,10 @@ export class CompareInterfaceManager extends DisposableObject {
|
||||
const toSchemas = await this.cliServer.bqrsInfo(
|
||||
to.query.resultsPaths.resultsPath
|
||||
);
|
||||
const fromSchemaNames = fromSchemas["result-sets"].map(
|
||||
const fromSchemaNames = fromSchemas['result-sets'].map(
|
||||
(schema) => schema.name
|
||||
);
|
||||
const toSchemaNames = toSchemas["result-sets"].map(
|
||||
const toSchemaNames = toSchemas['result-sets'].map(
|
||||
(schema) => schema.name
|
||||
);
|
||||
const commonResultSetNames = fromSchemaNames.filter((name) =>
|
||||
@@ -238,7 +238,7 @@ export class CompareInterfaceManager extends DisposableObject {
|
||||
resultSetName: string,
|
||||
resultsPath: string
|
||||
): Promise<RawResultSet> {
|
||||
const schema = bqrsInfo["result-sets"].find(
|
||||
const schema = bqrsInfo['result-sets'].find(
|
||||
(schema) => schema.name === resultSetName
|
||||
);
|
||||
if (!schema) {
|
||||
@@ -260,9 +260,9 @@ export class CompareInterfaceManager extends DisposableObject {
|
||||
return resultsDiff(fromResults, toResults);
|
||||
}
|
||||
|
||||
private openQuery(kind: "from" | "to") {
|
||||
private openQuery(kind: 'from' | 'to') {
|
||||
const toOpen =
|
||||
kind === "from" ? this.comparePair?.from : this.comparePair?.to;
|
||||
kind === 'from' ? this.comparePair?.from : this.comparePair?.to;
|
||||
if (toOpen) {
|
||||
this.showQueryResultsCallback(toOpen);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { RawResultSet } from "../adapt";
|
||||
import { QueryCompareResult } from "../interface-types";
|
||||
import { RawResultSet } from '../adapt';
|
||||
import { QueryCompareResult } from '../interface-types';
|
||||
|
||||
/**
|
||||
* Compare the rows of two queries. Use deep equality to determine if
|
||||
@@ -25,15 +25,15 @@ export default function resultsDiff(
|
||||
): QueryCompareResult {
|
||||
|
||||
if (fromResults.schema.columns.length !== toResults.schema.columns.length) {
|
||||
throw new Error("CodeQL Compare: Columns do not match.");
|
||||
throw new Error('CodeQL Compare: Columns do not match.');
|
||||
}
|
||||
|
||||
if (!fromResults.rows.length) {
|
||||
throw new Error("CodeQL Compare: Source query has no results.");
|
||||
throw new Error('CodeQL Compare: Source query has no results.');
|
||||
}
|
||||
|
||||
if (!toResults.rows.length) {
|
||||
throw new Error("CodeQL Compare: Target query has no results.");
|
||||
throw new Error('CodeQL Compare: Target query has no results.');
|
||||
}
|
||||
|
||||
const results = {
|
||||
@@ -45,7 +45,7 @@ export default function resultsDiff(
|
||||
fromResults.rows.length === results.from.length &&
|
||||
toResults.rows.length === results.to.length
|
||||
) {
|
||||
throw new Error("CodeQL Compare: No overlap between the selected queries.");
|
||||
throw new Error('CodeQL Compare: No overlap between the selected queries.');
|
||||
}
|
||||
|
||||
return results;
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import * as React from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import * as Rdom from "react-dom";
|
||||
import * as React from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import * as Rdom from 'react-dom';
|
||||
|
||||
import RawTableHeader from "../../view/RawTableHeader";
|
||||
import RawTableHeader from '../../view/RawTableHeader';
|
||||
import {
|
||||
ToCompareViewMessage,
|
||||
SetComparisonsMessage,
|
||||
} from "../../interface-types";
|
||||
import CompareSelector from "./CompareSelector";
|
||||
import { vscode } from "../../view/vscode-api";
|
||||
import RawTableRow from "../../view/RawTableRow";
|
||||
import { ResultRow } from "../../adapt";
|
||||
import { className } from "../../view/result-table-utils";
|
||||
} from '../../interface-types';
|
||||
import CompareSelector from './CompareSelector';
|
||||
import { vscode } from '../../view/vscode-api';
|
||||
import RawTableRow from '../../view/RawTableRow';
|
||||
import { ResultRow } from '../../adapt';
|
||||
import { className } from '../../view/result-table-utils';
|
||||
|
||||
const emptyComparison: SetComparisonsMessage = {
|
||||
t: "setComparisons",
|
||||
t: 'setComparisons',
|
||||
stats: {},
|
||||
rows: {
|
||||
from: [],
|
||||
@@ -22,8 +22,8 @@ const emptyComparison: SetComparisonsMessage = {
|
||||
},
|
||||
columns: [],
|
||||
commonResultSetNames: [],
|
||||
currentResultSetName: "",
|
||||
datebaseUri: "",
|
||||
currentResultSetName: '',
|
||||
datebaseUri: '',
|
||||
};
|
||||
|
||||
export function Compare(props: {}): JSX.Element {
|
||||
@@ -32,10 +32,10 @@ export function Compare(props: {}): JSX.Element {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("message", (evt: MessageEvent) => {
|
||||
window.addEventListener('message', (evt: MessageEvent) => {
|
||||
const msg: ToCompareViewMessage = evt.data;
|
||||
switch (msg.t) {
|
||||
case "setComparisons":
|
||||
case 'setComparisons':
|
||||
setComparison(msg);
|
||||
}
|
||||
});
|
||||
@@ -53,7 +53,7 @@ export function Compare(props: {}): JSX.Element {
|
||||
availableResultSets={comparison.commonResultSetNames}
|
||||
currentResultSetName={comparison.currentResultSetName}
|
||||
updateResultSet={(newResultSetName: string) =>
|
||||
vscode.postMessage({ t: "changeCompare", newResultSetName })
|
||||
vscode.postMessage({ t: 'changeCompare', newResultSetName })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
@@ -62,7 +62,7 @@ export function Compare(props: {}): JSX.Element {
|
||||
<tr>
|
||||
<td>
|
||||
<a
|
||||
onClick={() => openQuery("from")}
|
||||
onClick={() => openQuery('from')}
|
||||
className="vscode-codeql__compare-open"
|
||||
>
|
||||
{comparison.stats.fromQuery?.name}
|
||||
@@ -70,7 +70,7 @@ export function Compare(props: {}): JSX.Element {
|
||||
</td>
|
||||
<td>
|
||||
<a
|
||||
onClick={() => openQuery("to")}
|
||||
onClick={() => openQuery('to')}
|
||||
className="vscode-codeql__compare-open"
|
||||
>
|
||||
{comparison.stats.toQuery?.name}
|
||||
@@ -119,9 +119,9 @@ export function Compare(props: {}): JSX.Element {
|
||||
}
|
||||
}
|
||||
|
||||
async function openQuery(kind: "from" | "to") {
|
||||
async function openQuery(kind: 'from' | 'to') {
|
||||
vscode.postMessage({
|
||||
t: "openQuery",
|
||||
t: 'openQuery',
|
||||
kind,
|
||||
});
|
||||
}
|
||||
@@ -143,7 +143,7 @@ function createRows(rows: ResultRow[], databaseUri: string) {
|
||||
|
||||
Rdom.render(
|
||||
<Compare />,
|
||||
document.getElementById("root"),
|
||||
document.getElementById('root'),
|
||||
// Post a message to the extension when fully loaded.
|
||||
() => vscode.postMessage({ t: "compareViewLoaded" })
|
||||
() => vscode.postMessage({ t: 'compareViewLoaded' })
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as React from "react";
|
||||
import * as React from 'react';
|
||||
|
||||
interface Props {
|
||||
availableResultSets: string[];
|
||||
|
||||
@@ -281,17 +281,17 @@ async function activateWithInstalledDistribution(
|
||||
// of activation.
|
||||
errorStubs.forEach((stub) => stub.dispose());
|
||||
|
||||
logger.log("Initializing configuration listener...");
|
||||
logger.log('Initializing configuration listener...');
|
||||
const qlConfigurationListener = await QueryServerConfigListener.createQueryServerConfigListener(
|
||||
distributionManager
|
||||
);
|
||||
ctx.subscriptions.push(qlConfigurationListener);
|
||||
|
||||
logger.log("Initializing CodeQL cli server...");
|
||||
logger.log('Initializing CodeQL cli server...');
|
||||
const cliServer = new CodeQLCliServer(distributionManager, logger);
|
||||
ctx.subscriptions.push(cliServer);
|
||||
|
||||
logger.log("Initializing query server client.");
|
||||
logger.log('Initializing query server client.');
|
||||
const qs = new qsClient.QueryServerClient(
|
||||
qlConfigurationListener,
|
||||
cliServer,
|
||||
@@ -300,17 +300,17 @@ async function activateWithInstalledDistribution(
|
||||
},
|
||||
(task) =>
|
||||
Window.withProgress(
|
||||
{ title: "CodeQL query server", location: ProgressLocation.Window },
|
||||
{ title: 'CodeQL query server', location: ProgressLocation.Window },
|
||||
task
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(qs);
|
||||
await qs.startQueryServer();
|
||||
|
||||
logger.log("Initializing database manager.");
|
||||
logger.log('Initializing database manager.');
|
||||
const dbm = new DatabaseManager(ctx, qlConfigurationListener, logger);
|
||||
ctx.subscriptions.push(dbm);
|
||||
logger.log("Initializing database panel.");
|
||||
logger.log('Initializing database panel.');
|
||||
const databaseUI = new DatabaseUI(
|
||||
ctx,
|
||||
cliServer,
|
||||
@@ -320,7 +320,7 @@ async function activateWithInstalledDistribution(
|
||||
);
|
||||
ctx.subscriptions.push(databaseUI);
|
||||
|
||||
logger.log("Initializing query history manager.");
|
||||
logger.log('Initializing query history manager.');
|
||||
const queryHistoryConfigurationListener = new QueryHistoryConfigListener();
|
||||
const showResults = async (item: CompletedQuery) =>
|
||||
showResultsForCompletedQuery(item, WebviewReveal.Forced);
|
||||
@@ -332,11 +332,11 @@ async function activateWithInstalledDistribution(
|
||||
async (from: CompletedQuery, to: CompletedQuery) =>
|
||||
showResultsForComparison(from, to),
|
||||
);
|
||||
logger.log("Initializing results panel interface.");
|
||||
logger.log('Initializing results panel interface.');
|
||||
const intm = new InterfaceManager(ctx, dbm, cliServer, queryServerLogger);
|
||||
ctx.subscriptions.push(intm);
|
||||
|
||||
logger.log("Initializing compare panel interface.");
|
||||
logger.log('Initializing compare panel interface.');
|
||||
const cmpm = new CompareInterfaceManager(
|
||||
ctx,
|
||||
dbm,
|
||||
@@ -346,7 +346,7 @@ async function activateWithInstalledDistribution(
|
||||
);
|
||||
ctx.subscriptions.push(cmpm);
|
||||
|
||||
logger.log("Initializing source archive filesystem provider.");
|
||||
logger.log('Initializing source archive filesystem provider.');
|
||||
archiveFilesystemProvider.activate(ctx);
|
||||
|
||||
async function showResultsForComparison(
|
||||
@@ -375,7 +375,7 @@ async function activateWithInstalledDistribution(
|
||||
try {
|
||||
const dbItem = await databaseUI.getDatabaseItem();
|
||||
if (dbItem === undefined) {
|
||||
throw new Error("Can't run query without a selected database");
|
||||
throw new Error('Can\'t run query without a selected database');
|
||||
}
|
||||
const info = await compileAndRunQueryAgainstDatabase(
|
||||
cliServer,
|
||||
@@ -400,17 +400,17 @@ async function activateWithInstalledDistribution(
|
||||
|
||||
ctx.subscriptions.push(tmpDirDisposal);
|
||||
|
||||
logger.log("Initializing CodeQL language server.");
|
||||
logger.log('Initializing CodeQL language server.');
|
||||
const client = new LanguageClient(
|
||||
"CodeQL Language Server",
|
||||
'CodeQL Language Server',
|
||||
() => spawnIdeServer(qlConfigurationListener),
|
||||
{
|
||||
documentSelector: [
|
||||
{ language: "ql", scheme: "file" },
|
||||
{ language: "yaml", scheme: "file", pattern: "**/qlpack.yml" },
|
||||
{ language: 'ql', scheme: 'file' },
|
||||
{ language: 'yaml', scheme: 'file', pattern: '**/qlpack.yml' },
|
||||
],
|
||||
synchronize: {
|
||||
configurationSection: "codeQL",
|
||||
configurationSection: 'codeQL',
|
||||
},
|
||||
// Ensure that language server exceptions are logged to the same channel as its output.
|
||||
outputChannel: ideServerLogger.outputChannel,
|
||||
@@ -418,7 +418,7 @@ async function activateWithInstalledDistribution(
|
||||
true
|
||||
);
|
||||
|
||||
logger.log("Initializing QLTest interface.");
|
||||
logger.log('Initializing QLTest interface.');
|
||||
const testExplorerExtension = extensions.getExtension<TestHub>(
|
||||
testExplorerExtensionId
|
||||
);
|
||||
@@ -431,58 +431,58 @@ async function activateWithInstalledDistribution(
|
||||
ctx.subscriptions.push(testUIService);
|
||||
}
|
||||
|
||||
logger.log("Registering top-level command palette commands.");
|
||||
logger.log('Registering top-level command palette commands.');
|
||||
ctx.subscriptions.push(
|
||||
commands.registerCommand(
|
||||
"codeQL.runQuery",
|
||||
'codeQL.runQuery',
|
||||
async (uri: Uri | undefined) => await compileAndRunQuery(false, uri)
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
commands.registerCommand(
|
||||
"codeQL.quickEval",
|
||||
'codeQL.quickEval',
|
||||
async (uri: Uri | undefined) => await compileAndRunQuery(true, uri)
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
commands.registerCommand("codeQL.quickQuery", async () =>
|
||||
commands.registerCommand('codeQL.quickQuery', async () =>
|
||||
displayQuickQuery(ctx, cliServer, databaseUI)
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
commands.registerCommand("codeQL.restartQueryServer", async () => {
|
||||
commands.registerCommand('codeQL.restartQueryServer', async () => {
|
||||
await qs.restartQueryServer();
|
||||
helpers.showAndLogInformationMessage("CodeQL Query Server restarted.", {
|
||||
helpers.showAndLogInformationMessage('CodeQL Query Server restarted.', {
|
||||
outputLogger: queryServerLogger,
|
||||
});
|
||||
})
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
commands.registerCommand("codeQL.chooseDatabaseFolder", () =>
|
||||
commands.registerCommand('codeQL.chooseDatabaseFolder', () =>
|
||||
databaseUI.handleChooseDatabaseFolder()
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
commands.registerCommand("codeQL.chooseDatabaseArchive", () =>
|
||||
commands.registerCommand('codeQL.chooseDatabaseArchive', () =>
|
||||
databaseUI.handleChooseDatabaseArchive()
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
commands.registerCommand("codeQL.chooseDatabaseLgtm", () =>
|
||||
commands.registerCommand('codeQL.chooseDatabaseLgtm', () =>
|
||||
databaseUI.handleChooseDatabaseLgtm()
|
||||
)
|
||||
);
|
||||
ctx.subscriptions.push(
|
||||
commands.registerCommand("codeQL.chooseDatabaseInternet", () =>
|
||||
commands.registerCommand('codeQL.chooseDatabaseInternet', () =>
|
||||
databaseUI.handleChooseDatabaseInternet()
|
||||
)
|
||||
);
|
||||
|
||||
logger.log("Starting language server.");
|
||||
logger.log('Starting language server.');
|
||||
ctx.subscriptions.push(client.start());
|
||||
|
||||
// Jump-to-definition and find-references
|
||||
logger.log("Registering jump-to-definition handlers.");
|
||||
logger.log('Registering jump-to-definition handlers.');
|
||||
languages.registerDefinitionProvider(
|
||||
{ scheme: archiveFilesystemProvider.zipArchiveScheme },
|
||||
new TemplateQueryDefinitionProvider(cliServer, qs, dbm)
|
||||
@@ -492,7 +492,7 @@ async function activateWithInstalledDistribution(
|
||||
new TemplateQueryReferenceProvider(cliServer, qs, dbm)
|
||||
);
|
||||
|
||||
logger.log("Successfully finished extension initialization.");
|
||||
logger.log('Successfully finished extension initialization.');
|
||||
}
|
||||
|
||||
function getContextStoragePath(ctx: ExtensionContext) {
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import * as sarif from "sarif";
|
||||
import * as sarif from 'sarif';
|
||||
import {
|
||||
ResolvableLocationValue,
|
||||
ColumnSchema,
|
||||
ResultSetSchema,
|
||||
} from "semmle-bqrs";
|
||||
import { ResultRow, ParsedResultSets, RawResultSet } from "./adapt";
|
||||
} from 'semmle-bqrs';
|
||||
import { ResultRow, ParsedResultSets, RawResultSet } from './adapt';
|
||||
|
||||
/**
|
||||
* This module contains types and code that are shared between
|
||||
* the webview and the extension.
|
||||
*/
|
||||
|
||||
export const SELECT_TABLE_NAME = "#select";
|
||||
export const ALERTS_TABLE_NAME = "alerts";
|
||||
export const SELECT_TABLE_NAME = '#select';
|
||||
export const ALERTS_TABLE_NAME = 'alerts';
|
||||
|
||||
export type RawTableResultSet = { t: "RawResultSet" } & RawResultSet;
|
||||
export type RawTableResultSet = { t: 'RawResultSet' } & RawResultSet;
|
||||
export type PathTableResultSet = {
|
||||
t: "SarifResultSet";
|
||||
t: 'SarifResultSet';
|
||||
readonly schema: ResultSetSchema;
|
||||
name: string;
|
||||
} & Interpretation;
|
||||
@@ -87,11 +87,11 @@ export type SortedResultsMap = { [resultSet: string]: SortedResultSetInfo };
|
||||
* As a result of receiving this message, listeners might want to display a loading indicator.
|
||||
*/
|
||||
export interface ResultsUpdatingMsg {
|
||||
t: "resultsUpdating";
|
||||
t: 'resultsUpdating';
|
||||
}
|
||||
|
||||
export interface SetStateMsg {
|
||||
t: "setState";
|
||||
t: 'setState';
|
||||
resultsPath: string;
|
||||
origResultsPaths: ResultsPaths;
|
||||
sortedResultsMap: SortedResultsMap;
|
||||
@@ -115,7 +115,7 @@ export interface SetStateMsg {
|
||||
|
||||
/** Advance to the next or previous path no in the path viewer */
|
||||
export interface NavigatePathMsg {
|
||||
t: "navigatePath";
|
||||
t: 'navigatePath';
|
||||
|
||||
/** 1 for next, -1 for previous */
|
||||
direction: number;
|
||||
@@ -135,13 +135,13 @@ export type FromResultsViewMsg =
|
||||
| ChangePage;
|
||||
|
||||
export interface ViewSourceFileMsg {
|
||||
t: "viewSourceFile";
|
||||
t: 'viewSourceFile';
|
||||
loc: ResolvableLocationValue;
|
||||
databaseUri: string;
|
||||
}
|
||||
|
||||
interface ToggleDiagnostics {
|
||||
t: "toggleDiagnostics";
|
||||
t: 'toggleDiagnostics';
|
||||
databaseUri: string;
|
||||
metadata?: QueryMetadata;
|
||||
origResultsPaths: ResultsPaths;
|
||||
@@ -150,11 +150,11 @@ interface ToggleDiagnostics {
|
||||
}
|
||||
|
||||
interface ResultViewLoaded {
|
||||
t: "resultViewLoaded";
|
||||
t: 'resultViewLoaded';
|
||||
}
|
||||
|
||||
interface ChangePage {
|
||||
t: "changePage";
|
||||
t: 'changePage';
|
||||
pageNumber: number; // 0-indexed, displayed to the user as 1-indexed
|
||||
selectedTable: string;
|
||||
}
|
||||
@@ -169,7 +169,7 @@ export interface RawResultsSortState {
|
||||
sortDirection: SortDirection;
|
||||
}
|
||||
|
||||
export type InterpretedResultsSortColumn = "alert-message";
|
||||
export type InterpretedResultsSortColumn = 'alert-message';
|
||||
|
||||
export interface InterpretedResultsSortState {
|
||||
sortBy: InterpretedResultsSortColumn;
|
||||
@@ -177,7 +177,7 @@ export interface InterpretedResultsSortState {
|
||||
}
|
||||
|
||||
interface ChangeRawResultsSortMsg {
|
||||
t: "changeSort";
|
||||
t: 'changeSort';
|
||||
resultSetName: string;
|
||||
/**
|
||||
* sortState being undefined means don't sort, just present results in the order
|
||||
@@ -187,7 +187,7 @@ interface ChangeRawResultsSortMsg {
|
||||
}
|
||||
|
||||
interface ChangeInterpretedResultsSortMsg {
|
||||
t: "changeInterpretedSort";
|
||||
t: 'changeInterpretedSort';
|
||||
/**
|
||||
* sortState being undefined means don't sort, just present results in the order
|
||||
* they appear in the sarif file.
|
||||
@@ -202,23 +202,23 @@ export type FromCompareViewMessage =
|
||||
| OpenQueryMessage;
|
||||
|
||||
interface CompareViewLoadedMessage {
|
||||
t: "compareViewLoaded";
|
||||
t: 'compareViewLoaded';
|
||||
}
|
||||
|
||||
export interface OpenQueryMessage {
|
||||
readonly t: "openQuery";
|
||||
readonly kind: "from" | "to";
|
||||
readonly t: 'openQuery';
|
||||
readonly kind: 'from' | 'to';
|
||||
}
|
||||
|
||||
interface ChangeCompareMessage {
|
||||
t: "changeCompare";
|
||||
t: 'changeCompare';
|
||||
newResultSetName: string;
|
||||
}
|
||||
|
||||
export type ToCompareViewMessage = SetComparisonsMessage;
|
||||
|
||||
export interface SetComparisonsMessage {
|
||||
readonly t: "setComparisons";
|
||||
export interface SetComparisonsMessage {
|
||||
readonly t: 'setComparisons';
|
||||
readonly stats: {
|
||||
fromQuery?: {
|
||||
name: string;
|
||||
@@ -239,9 +239,9 @@ export type ToCompareViewMessage = SetComparisonsMessage;
|
||||
}
|
||||
|
||||
export enum DiffKind {
|
||||
Add = "Add",
|
||||
Remove = "Remove",
|
||||
Change = "Change",
|
||||
Add = 'Add',
|
||||
Remove = 'Remove',
|
||||
Change = 'Change',
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as crypto from "crypto";
|
||||
import * as crypto from 'crypto';
|
||||
import {
|
||||
Uri,
|
||||
Location,
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
Selection,
|
||||
TextEditorRevealType,
|
||||
ThemeColor,
|
||||
} from "vscode";
|
||||
} from 'vscode';
|
||||
import {
|
||||
FivePartLocation,
|
||||
LocationStyle,
|
||||
@@ -19,10 +19,10 @@ import {
|
||||
tryGetResolvableLocation,
|
||||
WholeFileLocation,
|
||||
ResolvableLocationValue,
|
||||
} from "semmle-bqrs";
|
||||
import { DatabaseItem, DatabaseManager } from "./databases";
|
||||
import { ViewSourceFileMsg } from "./interface-types";
|
||||
import { Logger } from "./logging";
|
||||
} from 'semmle-bqrs';
|
||||
import { DatabaseItem, DatabaseManager } from './databases';
|
||||
import { ViewSourceFileMsg } from './interface-types';
|
||||
import { Logger } from './logging';
|
||||
|
||||
/**
|
||||
* This module contains functions and types that are sharedd between
|
||||
@@ -31,7 +31,7 @@ import { Logger } from "./logging";
|
||||
|
||||
/** Gets a nonce string created with 128 bits of entropy. */
|
||||
export function getNonce(): string {
|
||||
return crypto.randomBytes(16).toString("base64");
|
||||
return crypto.randomBytes(16).toString('base64');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,9 +189,9 @@ export async function showLocation(
|
||||
}
|
||||
}
|
||||
|
||||
const findMatchBackground = new ThemeColor("editor.findMatchBackground");
|
||||
const findMatchBackground = new ThemeColor('editor.findMatchBackground');
|
||||
const findRangeHighlightBackground = new ThemeColor(
|
||||
"editor.findRangeHighlightBackground"
|
||||
'editor.findRangeHighlightBackground'
|
||||
);
|
||||
|
||||
export const shownLocationDecoration = Window.createTextEditorDecorationType({
|
||||
@@ -220,7 +220,7 @@ export async function jumpToLocation(
|
||||
if (e instanceof Error) {
|
||||
if (e.message.match(/File not found/)) {
|
||||
Window.showErrorMessage(
|
||||
`Original file of this result is not in the database's source archive.`
|
||||
'Original file of this result is not in the database\'s source archive.'
|
||||
);
|
||||
} else {
|
||||
logger.log(`Unable to handleMsgFromView: ${e.message}`);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as path from "path";
|
||||
import * as Sarif from "sarif";
|
||||
import { DisposableObject } from "@github/codeql-vscode-utils";
|
||||
import * as vscode from "vscode";
|
||||
import * as path from 'path';
|
||||
import * as Sarif from 'sarif';
|
||||
import { DisposableObject } from '@github/codeql-vscode-utils';
|
||||
import * as vscode from 'vscode';
|
||||
import {
|
||||
Diagnostic,
|
||||
DiagnosticRelatedInformation,
|
||||
@@ -10,12 +10,12 @@ import {
|
||||
Uri,
|
||||
window as Window,
|
||||
env
|
||||
} from "vscode";
|
||||
import * as cli from "./cli";
|
||||
import { CodeQLCliServer } from "./cli";
|
||||
import { DatabaseItem, DatabaseManager } from "./databases";
|
||||
import { showAndLogErrorMessage } from "./helpers";
|
||||
import { assertNever } from "./helpers-pure";
|
||||
} from 'vscode';
|
||||
import * as cli from './cli';
|
||||
import { CodeQLCliServer } from './cli';
|
||||
import { DatabaseItem, DatabaseManager } from './databases';
|
||||
import { showAndLogErrorMessage } from './helpers';
|
||||
import { assertNever } from './helpers-pure';
|
||||
import {
|
||||
FromResultsViewMsg,
|
||||
Interpretation,
|
||||
@@ -28,19 +28,19 @@ import {
|
||||
InterpretedResultsSortState,
|
||||
SortDirection,
|
||||
RAW_RESULTS_PAGE_SIZE,
|
||||
} from "./interface-types";
|
||||
import { Logger } from "./logging";
|
||||
import * as messages from "./messages";
|
||||
import { CompletedQuery, interpretResults } from "./query-results";
|
||||
import { QueryInfo, tmpDir } from "./run-queries";
|
||||
import { parseSarifLocation, parseSarifPlainTextMessage } from "./sarif-utils";
|
||||
} from './interface-types';
|
||||
import { Logger } from './logging';
|
||||
import * as messages from './messages';
|
||||
import { CompletedQuery, interpretResults } from './query-results';
|
||||
import { QueryInfo, tmpDir } from './run-queries';
|
||||
import { parseSarifLocation, parseSarifPlainTextMessage } from './sarif-utils';
|
||||
import {
|
||||
adaptSchema,
|
||||
adaptBqrs,
|
||||
ParsedResultSets,
|
||||
RawResultSet,
|
||||
} from "./adapt";
|
||||
import { EXPERIMENTAL_BQRS_SETTING } from "./config";
|
||||
} from './adapt';
|
||||
import { EXPERIMENTAL_BQRS_SETTING } from './config';
|
||||
import {
|
||||
WebviewReveal,
|
||||
fileUriToWebviewUri,
|
||||
@@ -49,8 +49,8 @@ import {
|
||||
shownLocationDecoration,
|
||||
shownLocationLineDecoration,
|
||||
jumpToLocation,
|
||||
} from "./interface-utils";
|
||||
import { getDefaultResultSetName } from "./interface-types";
|
||||
} from './interface-utils';
|
||||
import { getDefaultResultSetName } from './interface-types';
|
||||
|
||||
/**
|
||||
* interface.ts
|
||||
@@ -76,13 +76,13 @@ function sortInterpretedResults(
|
||||
if (sortState !== undefined) {
|
||||
const multiplier = sortMultiplier(sortState.sortDirection);
|
||||
switch (sortState.sortBy) {
|
||||
case "alert-message":
|
||||
case 'alert-message':
|
||||
results.sort((a, b) =>
|
||||
a.message.text === undefined
|
||||
? 0
|
||||
: b.message.text === undefined
|
||||
? 0
|
||||
: multiplier * a.message.text?.localeCompare(b.message.text, env.language)
|
||||
? 0
|
||||
: multiplier * a.message.text?.localeCompare(b.message.text, env.language)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
@@ -119,7 +119,7 @@ export class InterfaceManager extends DisposableObject {
|
||||
this.handleSelectionChange.bind(this)
|
||||
)
|
||||
);
|
||||
logger.log("Registering path-step navigation commands.");
|
||||
logger.log('Registering path-step navigation commands.');
|
||||
this.push(
|
||||
vscode.commands.registerCommand(
|
||||
'codeQLQueryResults.nextPathStep',
|
||||
@@ -202,7 +202,7 @@ export class InterfaceManager extends DisposableObject {
|
||||
|
||||
private async handleMsgFromView(msg: FromResultsViewMsg): Promise<void> {
|
||||
switch (msg.t) {
|
||||
case "viewSourceFile": {
|
||||
case 'viewSourceFile': {
|
||||
await jumpToLocation(msg, this.databaseManager, this.logger);
|
||||
break;
|
||||
}
|
||||
@@ -310,7 +310,7 @@ export class InterfaceManager extends DisposableObject {
|
||||
const queryName = results.queryName;
|
||||
const resultPromise = vscode.window.showInformationMessage(
|
||||
`Finished running query ${
|
||||
queryName.length > 0 ? ` "${queryName}"` : ""
|
||||
queryName.length > 0 ? ` "${queryName}"` : ''
|
||||
}.`,
|
||||
showButton
|
||||
);
|
||||
@@ -330,18 +330,18 @@ export class InterfaceManager extends DisposableObject {
|
||||
RAW_RESULTS_PAGE_SIZE
|
||||
);
|
||||
|
||||
const resultSetNames = schemas["result-sets"].map(
|
||||
const resultSetNames = schemas['result-sets'].map(
|
||||
(resultSet) => resultSet.name
|
||||
);
|
||||
|
||||
// This may not wind up being the page we actually show, if there are interpreted results,
|
||||
// but speculatively send it anyway.
|
||||
const selectedTable = getDefaultResultSetName(resultSetNames);
|
||||
const schema = schemas["result-sets"].find(
|
||||
const schema = schemas['result-sets'].find(
|
||||
(resultSet) => resultSet.name == selectedTable
|
||||
)!;
|
||||
if (schema === undefined) {
|
||||
return { t: "WebviewParsed" };
|
||||
return { t: 'WebviewParsed' };
|
||||
}
|
||||
|
||||
const chunk = await this.cliServer.bqrsDecode(
|
||||
@@ -354,7 +354,7 @@ export class InterfaceManager extends DisposableObject {
|
||||
const resultSet = adaptBqrs(adaptedSchema, chunk);
|
||||
|
||||
return {
|
||||
t: "ExtensionParsed",
|
||||
t: 'ExtensionParsed',
|
||||
pageNumber: 0,
|
||||
numPages: numPagesOfResultSet(resultSet),
|
||||
resultSet,
|
||||
@@ -362,7 +362,7 @@ export class InterfaceManager extends DisposableObject {
|
||||
resultSetNames,
|
||||
};
|
||||
} else {
|
||||
return { t: "WebviewParsed" };
|
||||
return { t: 'WebviewParsed' };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -390,7 +390,7 @@ export class InterfaceManager extends DisposableObject {
|
||||
): Promise<void> {
|
||||
const results = this._displayedQuery;
|
||||
if (results === undefined) {
|
||||
throw new Error("trying to view a page of a query that is not loaded");
|
||||
throw new Error('trying to view a page of a query that is not loaded');
|
||||
}
|
||||
|
||||
const sortedResultsMap: SortedResultsMap = {};
|
||||
@@ -404,11 +404,11 @@ export class InterfaceManager extends DisposableObject {
|
||||
RAW_RESULTS_PAGE_SIZE
|
||||
);
|
||||
|
||||
const resultSetNames = schemas["result-sets"].map(
|
||||
const resultSetNames = schemas['result-sets'].map(
|
||||
(resultSet) => resultSet.name
|
||||
);
|
||||
|
||||
const schema = schemas["result-sets"].find(
|
||||
const schema = schemas['result-sets'].find(
|
||||
(resultSet) => resultSet.name == selectedTable
|
||||
)!;
|
||||
if (schema === undefined)
|
||||
@@ -424,7 +424,7 @@ export class InterfaceManager extends DisposableObject {
|
||||
const resultSet = adaptBqrs(adaptedSchema, chunk);
|
||||
|
||||
const parsedResultSets: ParsedResultSets = {
|
||||
t: "ExtensionParsed",
|
||||
t: 'ExtensionParsed',
|
||||
pageNumber,
|
||||
resultSet,
|
||||
numPages: numPagesOfResultSet(resultSet),
|
||||
@@ -504,9 +504,9 @@ export class InterfaceManager extends DisposableObject {
|
||||
sourceArchiveUri === undefined
|
||||
? undefined
|
||||
: {
|
||||
sourceArchive: sourceArchiveUri.fsPath,
|
||||
sourceLocationPrefix,
|
||||
};
|
||||
sourceArchive: sourceArchiveUri.fsPath,
|
||||
sourceLocationPrefix,
|
||||
};
|
||||
interpretation = await this.getTruncatedResults(
|
||||
query.metadata,
|
||||
query.resultsPaths,
|
||||
@@ -538,9 +538,9 @@ export class InterfaceManager extends DisposableObject {
|
||||
sourceArchiveUri === undefined
|
||||
? undefined
|
||||
: {
|
||||
sourceArchive: sourceArchiveUri.fsPath,
|
||||
sourceLocationPrefix,
|
||||
};
|
||||
sourceArchive: sourceArchiveUri.fsPath,
|
||||
sourceLocationPrefix,
|
||||
};
|
||||
const interpretation = await this.getTruncatedResults(
|
||||
metadata,
|
||||
resultsInfo,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { languages } from "vscode";
|
||||
import { languages } from 'vscode';
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as React from "react";
|
||||
import * as React from 'react';
|
||||
|
||||
import { vscode } from "./vscode-api";
|
||||
import { RawResultsSortState, SortDirection } from "../interface-types";
|
||||
import { nextSortDirection } from "./result-table-utils";
|
||||
import { ColumnSchema } from "semmle-bqrs";
|
||||
import { vscode } from './vscode-api';
|
||||
import { RawResultsSortState, SortDirection } from '../interface-types';
|
||||
import { nextSortDirection } from './result-table-utils';
|
||||
import { ColumnSchema } from 'semmle-bqrs';
|
||||
|
||||
interface Props {
|
||||
readonly columns: readonly ColumnSchema[];
|
||||
@@ -35,7 +35,7 @@ function toggleSortStateForColumn(
|
||||
sortDirection: nextDirection,
|
||||
};
|
||||
vscode.postMessage({
|
||||
t: "changeSort",
|
||||
t: 'changeSort',
|
||||
resultSetName: schemaName,
|
||||
sortState: nextSortState,
|
||||
});
|
||||
@@ -60,10 +60,10 @@ export default function RawTableHeader(props: Props) {
|
||||
return (
|
||||
<th
|
||||
className={
|
||||
"sort-" +
|
||||
'sort-' +
|
||||
(sortDirection !== undefined
|
||||
? SortDirection[sortDirection]
|
||||
: "none")
|
||||
: 'none')
|
||||
}
|
||||
key={index}
|
||||
onClick={() =>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as React from "react";
|
||||
import { ResultRow } from "../adapt";
|
||||
import { zebraStripe } from "./result-table-utils";
|
||||
import RawTableValue from "./RawTableValue";
|
||||
import * as React from 'react';
|
||||
import { ResultRow } from '../adapt';
|
||||
import { zebraStripe } from './result-table-utils';
|
||||
import RawTableValue from './RawTableValue';
|
||||
|
||||
interface Props {
|
||||
rowIndex: number;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as React from "react";
|
||||
import * as React from 'react';
|
||||
|
||||
import { ResultValue } from "../adapt";
|
||||
import { renderLocation } from "./result-table-utils";
|
||||
import { ResultValue } from '../adapt';
|
||||
import { renderLocation } from './result-table-utils';
|
||||
|
||||
interface Props {
|
||||
value: ResultValue;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as React from "react";
|
||||
import { ResultTableProps, className } from "./result-table-utils";
|
||||
import { RAW_RESULTS_LIMIT, RawResultsSortState } from "../interface-types";
|
||||
import { RawTableResultSet } from "../interface-types";
|
||||
import RawTableHeader from "./RawTableHeader";
|
||||
import RawTableRow from "./RawTableRow";
|
||||
import { ResultRow } from "../adapt";
|
||||
import * as React from 'react';
|
||||
import { ResultTableProps, className } from './result-table-utils';
|
||||
import { RAW_RESULTS_LIMIT, RawResultsSortState } from '../interface-types';
|
||||
import { RawTableResultSet } from '../interface-types';
|
||||
import RawTableHeader from './RawTableHeader';
|
||||
import RawTableRow from './RawTableRow';
|
||||
import { ResultRow } from '../adapt';
|
||||
|
||||
export type RawTableProps = ResultTableProps & {
|
||||
resultSet: RawTableResultSet;
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
ALERTS_TABLE_NAME,
|
||||
SELECT_TABLE_NAME,
|
||||
getDefaultResultSetName,
|
||||
} from "../interface-types";
|
||||
} from '../interface-types';
|
||||
import { PathTable } from './alert-table';
|
||||
import { RawTable } from './raw-results-table';
|
||||
import { ResultTableProps, tableSelectionHeaderClassName, toggleDiagnosticsClassName, alertExtrasClassName } from './result-table-utils';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import * as React from "react";
|
||||
import * as Rdom from "react-dom";
|
||||
import * as bqrs from "semmle-bqrs";
|
||||
import * as React from 'react';
|
||||
import * as Rdom from 'react-dom';
|
||||
import * as bqrs from 'semmle-bqrs';
|
||||
import {
|
||||
ElementBase,
|
||||
PrimitiveColumnValue,
|
||||
PrimitiveTypeKind,
|
||||
tryGetResolvableLocation,
|
||||
} from "semmle-bqrs";
|
||||
import { assertNever } from "../helpers-pure";
|
||||
} from 'semmle-bqrs';
|
||||
import { assertNever } from '../helpers-pure';
|
||||
import {
|
||||
DatabaseInfo,
|
||||
Interpretation,
|
||||
@@ -17,16 +17,16 @@ import {
|
||||
NavigatePathMsg,
|
||||
QueryMetadata,
|
||||
ResultsPaths,
|
||||
} from "../interface-types";
|
||||
import { EventHandlers as EventHandlerList } from "./event-handler-list";
|
||||
import { ResultTables } from "./result-tables";
|
||||
} from '../interface-types';
|
||||
import { EventHandlers as EventHandlerList } from './event-handler-list';
|
||||
import { ResultTables } from './result-tables';
|
||||
import {
|
||||
ResultValue,
|
||||
ResultRow,
|
||||
ParsedResultSets,
|
||||
} from "../adapt";
|
||||
import { ResultSet } from "../interface-types";
|
||||
import { vscode } from "./vscode-api";
|
||||
} from '../adapt';
|
||||
import { ResultSet } from '../interface-types';
|
||||
import { vscode } from './vscode-api';
|
||||
|
||||
/**
|
||||
* results.tsx
|
||||
@@ -58,14 +58,14 @@ function translatePrimitiveValue(
|
||||
type: PrimitiveTypeKind
|
||||
): ResultValue {
|
||||
switch (type) {
|
||||
case "i":
|
||||
case "f":
|
||||
case "s":
|
||||
case "d":
|
||||
case "b":
|
||||
case 'i':
|
||||
case 'f':
|
||||
case 's':
|
||||
case 'd':
|
||||
case 'b':
|
||||
return value.toString();
|
||||
|
||||
case "u":
|
||||
case 'u':
|
||||
return {
|
||||
uri: value as string,
|
||||
};
|
||||
@@ -83,7 +83,7 @@ async function parseResultSets(
|
||||
const columnTypes = resultSetSchema.columns.map((column) => column.type);
|
||||
const rows: ResultRow[] = [];
|
||||
resultSets.push({
|
||||
t: "RawResultSet",
|
||||
t: 'RawResultSet',
|
||||
schema: resultSetSchema,
|
||||
rows: rows,
|
||||
});
|
||||
@@ -92,7 +92,7 @@ async function parseResultSets(
|
||||
const row: ResultValue[] = [];
|
||||
tuple.forEach((value, index) => {
|
||||
const type = columnTypes[index];
|
||||
if (type.type === "e") {
|
||||
if (type.type === 'e') {
|
||||
const element: ElementBase = value as ElementBase;
|
||||
const label =
|
||||
element.label !== undefined ? element.label : element.id.toString(); //REVIEW: URLs?
|
||||
@@ -171,7 +171,7 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
displayedResults: {
|
||||
resultsInfo: null,
|
||||
results: null,
|
||||
errorMessage: "",
|
||||
errorMessage: '',
|
||||
},
|
||||
nextResultsInfo: null,
|
||||
isExpectingResultsUpdate: true,
|
||||
@@ -180,7 +180,7 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
|
||||
handleMessage(msg: IntoResultsViewMsg): void {
|
||||
switch (msg.t) {
|
||||
case "setState":
|
||||
case 'setState':
|
||||
this.updateStateWithNewResultsInfo({
|
||||
resultsPath: msg.resultsPath,
|
||||
parsedResultSets: msg.parsedResultSets,
|
||||
@@ -195,12 +195,12 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
|
||||
this.loadResults();
|
||||
break;
|
||||
case "resultsUpdating":
|
||||
case 'resultsUpdating':
|
||||
this.setState({
|
||||
isExpectingResultsUpdate: true,
|
||||
});
|
||||
break;
|
||||
case "navigatePath":
|
||||
case 'navigatePath':
|
||||
onNavigation.fire(msg);
|
||||
break;
|
||||
default:
|
||||
@@ -223,7 +223,7 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
return stateWithDisplayedResults({
|
||||
resultsInfo: null,
|
||||
results: null,
|
||||
errorMessage: "No results to display",
|
||||
errorMessage: 'No results to display',
|
||||
});
|
||||
}
|
||||
if (!resultsInfo || !resultsInfo.shouldKeepOldResultsWhileRendering) {
|
||||
@@ -231,7 +231,7 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
return stateWithDisplayedResults({
|
||||
resultsInfo: null,
|
||||
results: null,
|
||||
errorMessage: "Loading results…",
|
||||
errorMessage: 'Loading results…',
|
||||
});
|
||||
}
|
||||
return stateWithDisplayedResults(prevState.displayedResults);
|
||||
@@ -243,10 +243,10 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
): Promise<readonly ResultSet[]> {
|
||||
const parsedResultSets = resultsInfo.parsedResultSets;
|
||||
switch (parsedResultSets.t) {
|
||||
case "WebviewParsed":
|
||||
case 'WebviewParsed':
|
||||
return await this.fetchResultSets(resultsInfo);
|
||||
case "ExtensionParsed": {
|
||||
return [{ t: "RawResultSet", ...parsedResultSets.resultSet }];
|
||||
case 'ExtensionParsed': {
|
||||
return [{ t: 'RawResultSet', ...parsedResultSets.resultSet }];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -258,7 +258,7 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
}
|
||||
|
||||
let results: Results | null = null;
|
||||
let statusText = "";
|
||||
let statusText = '';
|
||||
try {
|
||||
const resultSets = await this.getResultSets(resultsInfo);
|
||||
results = {
|
||||
@@ -271,7 +271,7 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
if (e instanceof Error) {
|
||||
errorMessage = e.message;
|
||||
} else {
|
||||
errorMessage = "Unknown error";
|
||||
errorMessage = 'Unknown error';
|
||||
}
|
||||
|
||||
statusText = `Error loading results: ${errorMessage}`;
|
||||
@@ -377,12 +377,12 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
componentDidMount(): void {
|
||||
this.vscodeMessageHandler = (evt) =>
|
||||
this.handleMessage(evt.data as IntoResultsViewMsg);
|
||||
window.addEventListener("message", this.vscodeMessageHandler);
|
||||
window.addEventListener('message', this.vscodeMessageHandler);
|
||||
}
|
||||
|
||||
componentWillUnmount(): void {
|
||||
if (this.vscodeMessageHandler) {
|
||||
window.removeEventListener("message", this.vscodeMessageHandler);
|
||||
window.removeEventListener('message', this.vscodeMessageHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,6 +391,6 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
| undefined = undefined;
|
||||
}
|
||||
|
||||
Rdom.render(<App />, document.getElementById("root"));
|
||||
Rdom.render(<App />, document.getElementById('root'));
|
||||
|
||||
vscode.postMessage({ t: 'resultViewLoaded' });
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { FromCompareViewMessage, FromResultsViewMsg } from "../interface-types";
|
||||
import { FromCompareViewMessage, FromResultsViewMsg } from '../interface-types';
|
||||
|
||||
export interface VsCodeApi {
|
||||
/**
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import { expect } from "chai";
|
||||
import * as vscode from "vscode";
|
||||
import * as path from "path";
|
||||
import * as sinon from "sinon";
|
||||
import * as tmp from "tmp";
|
||||
import { window, ViewColumn, Uri } from "vscode";
|
||||
import { expect } from 'chai';
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
import * as sinon from 'sinon';
|
||||
import * as tmp from 'tmp';
|
||||
import { window, ViewColumn, Uri } from 'vscode';
|
||||
import {
|
||||
fileUriToWebviewUri,
|
||||
webviewUriToFileUri,
|
||||
tryResolveLocation,
|
||||
} from "../../interface-utils";
|
||||
import { getDefaultResultSetName } from "../../interface-types";
|
||||
import { LocationStyle } from "semmle-bqrs";
|
||||
import { DatabaseItem } from "../../databases";
|
||||
} from '../../interface-utils';
|
||||
import { getDefaultResultSetName } from '../../interface-types';
|
||||
import { LocationStyle } from 'semmle-bqrs';
|
||||
import { DatabaseItem } from '../../databases';
|
||||
|
||||
describe("interface-utils", () => {
|
||||
describe("webview uri conversion", function () {
|
||||
const fileSuffix = ".bqrs";
|
||||
describe('interface-utils', () => {
|
||||
describe('webview uri conversion', function() {
|
||||
const fileSuffix = '.bqrs';
|
||||
|
||||
function setupWebview(filePrefix: string) {
|
||||
const tmpFile = tmp.fileSync({
|
||||
@@ -25,21 +25,21 @@ describe("interface-utils", () => {
|
||||
});
|
||||
const fileUriOnDisk = Uri.file(tmpFile.name);
|
||||
const panel = window.createWebviewPanel(
|
||||
"test panel",
|
||||
"test panel",
|
||||
'test panel',
|
||||
'test panel',
|
||||
ViewColumn.Beside,
|
||||
{
|
||||
enableScripts: false,
|
||||
localResourceRoots: [fileUriOnDisk],
|
||||
}
|
||||
);
|
||||
after(function () {
|
||||
after(function() {
|
||||
panel.dispose();
|
||||
tmpFile.removeCallback();
|
||||
});
|
||||
|
||||
// CSP allowing nothing, to prevent warnings.
|
||||
const html = `<html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none';"></head></html>`;
|
||||
const html = '<html><head><meta http-equiv="Content-Security-Policy" content="default-src \'none\';"></head></html>';
|
||||
panel.webview.html = html;
|
||||
return {
|
||||
fileUriOnDisk,
|
||||
@@ -47,8 +47,8 @@ describe("interface-utils", () => {
|
||||
};
|
||||
}
|
||||
|
||||
it("should correctly round trip from filesystem to webview and back", function () {
|
||||
const { fileUriOnDisk, panel } = setupWebview("");
|
||||
it('should correctly round trip from filesystem to webview and back', function() {
|
||||
const { fileUriOnDisk, panel } = setupWebview('');
|
||||
const webviewUri = fileUriToWebviewUri(panel, fileUriOnDisk);
|
||||
const reconstructedFileUri = webviewUriToFileUri(webviewUri);
|
||||
expect(reconstructedFileUri.toString(true)).to.equal(
|
||||
@@ -56,8 +56,8 @@ describe("interface-utils", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("does not double-encode # in URIs", function () {
|
||||
const { fileUriOnDisk, panel } = setupWebview("#");
|
||||
it('does not double-encode # in URIs', function() {
|
||||
const { fileUriOnDisk, panel } = setupWebview('#');
|
||||
const webviewUri = fileUriToWebviewUri(panel, fileUriOnDisk);
|
||||
const parsedUri = Uri.parse(webviewUri);
|
||||
expect(path.basename(parsedUri.path, fileSuffix)).to.equal(
|
||||
@@ -66,43 +66,43 @@ describe("interface-utils", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getDefaultResultSetName", () => {
|
||||
it("should get the default name", () => {
|
||||
expect(getDefaultResultSetName(["a", "b", "#select", "alerts"])).to.equal(
|
||||
"alerts"
|
||||
describe('getDefaultResultSetName', () => {
|
||||
it('should get the default name', () => {
|
||||
expect(getDefaultResultSetName(['a', 'b', '#select', 'alerts'])).to.equal(
|
||||
'alerts'
|
||||
);
|
||||
expect(getDefaultResultSetName(["a", "b", "#select"])).to.equal(
|
||||
"#select"
|
||||
expect(getDefaultResultSetName(['a', 'b', '#select'])).to.equal(
|
||||
'#select'
|
||||
);
|
||||
expect(getDefaultResultSetName(["a", "b"])).to.equal("a");
|
||||
expect(getDefaultResultSetName(['a', 'b'])).to.equal('a');
|
||||
expect(getDefaultResultSetName([])).to.be.undefined;
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveWholeFileLocation", () => {
|
||||
it("should resolve a whole file location", () => {
|
||||
describe('resolveWholeFileLocation', () => {
|
||||
it('should resolve a whole file location', () => {
|
||||
const mockDatabaseItem: DatabaseItem = ({
|
||||
resolveSourceFile: sinon.stub().returns(vscode.Uri.parse("abc")),
|
||||
resolveSourceFile: sinon.stub().returns(vscode.Uri.parse('abc')),
|
||||
} as unknown) as DatabaseItem;
|
||||
expect(
|
||||
tryResolveLocation(
|
||||
{
|
||||
t: LocationStyle.WholeFile,
|
||||
file: "hucairz",
|
||||
file: 'hucairz',
|
||||
},
|
||||
mockDatabaseItem
|
||||
)
|
||||
).to.deep.equal(
|
||||
new vscode.Location(
|
||||
vscode.Uri.parse("abc"),
|
||||
vscode.Uri.parse('abc'),
|
||||
new vscode.Range(0, 0, 0, 0)
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
it("should resolve a five-part location", () => {
|
||||
it('should resolve a five-part location', () => {
|
||||
const mockDatabaseItem: DatabaseItem = ({
|
||||
resolveSourceFile: sinon.stub().returns(vscode.Uri.parse("abc")),
|
||||
resolveSourceFile: sinon.stub().returns(vscode.Uri.parse('abc')),
|
||||
} as unknown) as DatabaseItem;
|
||||
|
||||
expect(
|
||||
@@ -113,79 +113,79 @@ describe("interface-utils", () => {
|
||||
colEnd: 3,
|
||||
lineStart: 4,
|
||||
lineEnd: 5,
|
||||
file: "hucairz",
|
||||
file: 'hucairz',
|
||||
},
|
||||
mockDatabaseItem
|
||||
)
|
||||
).to.deep.equal(
|
||||
new vscode.Location(
|
||||
vscode.Uri.parse("abc"),
|
||||
vscode.Uri.parse('abc'),
|
||||
new vscode.Range(new vscode.Position(4, 3), new vscode.Position(3, 0))
|
||||
)
|
||||
);
|
||||
expect(mockDatabaseItem.resolveSourceFile).to.have.been.calledOnceWith(
|
||||
"hucairz"
|
||||
'hucairz'
|
||||
);
|
||||
});
|
||||
|
||||
it("should resolve a string location for whole file", () => {
|
||||
it('should resolve a string location for whole file', () => {
|
||||
const mockDatabaseItem: DatabaseItem = ({
|
||||
resolveSourceFile: sinon.stub().returns(vscode.Uri.parse("abc")),
|
||||
resolveSourceFile: sinon.stub().returns(vscode.Uri.parse('abc')),
|
||||
} as unknown) as DatabaseItem;
|
||||
|
||||
expect(
|
||||
tryResolveLocation(
|
||||
{
|
||||
t: LocationStyle.String,
|
||||
loc: "file://hucairz:0:0:0:0"
|
||||
loc: 'file://hucairz:0:0:0:0'
|
||||
},
|
||||
mockDatabaseItem
|
||||
)
|
||||
).to.deep.equal(
|
||||
new vscode.Location(
|
||||
vscode.Uri.parse("abc"),
|
||||
vscode.Uri.parse('abc'),
|
||||
new vscode.Range(0, 0, 0, 0)
|
||||
)
|
||||
);
|
||||
expect(mockDatabaseItem.resolveSourceFile).to.have.been.calledOnceWith(
|
||||
"hucairz"
|
||||
'hucairz'
|
||||
);
|
||||
});
|
||||
|
||||
it("should resolve a string location for five-part location", () => {
|
||||
it('should resolve a string location for five-part location', () => {
|
||||
const mockDatabaseItem: DatabaseItem = ({
|
||||
resolveSourceFile: sinon.stub().returns(vscode.Uri.parse("abc")),
|
||||
resolveSourceFile: sinon.stub().returns(vscode.Uri.parse('abc')),
|
||||
} as unknown) as DatabaseItem;
|
||||
|
||||
expect(
|
||||
tryResolveLocation(
|
||||
{
|
||||
t: LocationStyle.String,
|
||||
loc: "file://hucairz:5:4:3:2"
|
||||
loc: 'file://hucairz:5:4:3:2'
|
||||
},
|
||||
mockDatabaseItem
|
||||
)
|
||||
).to.deep.equal(
|
||||
new vscode.Location(
|
||||
vscode.Uri.parse("abc"),
|
||||
vscode.Uri.parse('abc'),
|
||||
new vscode.Range(new vscode.Position(4, 3), new vscode.Position(2, 2))
|
||||
)
|
||||
);
|
||||
expect(mockDatabaseItem.resolveSourceFile).to.have.been.calledOnceWith(
|
||||
"hucairz"
|
||||
'hucairz'
|
||||
);
|
||||
});
|
||||
|
||||
it("should resolve a string location for invalid string", () => {
|
||||
it('should resolve a string location for invalid string', () => {
|
||||
const mockDatabaseItem: DatabaseItem = ({
|
||||
resolveSourceFile: sinon.stub().returns(vscode.Uri.parse("abc")),
|
||||
resolveSourceFile: sinon.stub().returns(vscode.Uri.parse('abc')),
|
||||
} as unknown) as DatabaseItem;
|
||||
|
||||
expect(
|
||||
tryResolveLocation(
|
||||
{
|
||||
t: LocationStyle.String,
|
||||
loc: "file://hucairz:x:y:z:a"
|
||||
loc: 'file://hucairz:x:y:z:a'
|
||||
},
|
||||
mockDatabaseItem
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user