Skip to content

Commit 8cadd3d

Browse files
committed
Add error message when no definitions queries.
1 parent 038e0a3 commit 8cadd3d

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

extensions/ql-vscode/src/definitions.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,24 @@ function tagOfKeyType(keyType: KeyType): string {
3434
}
3535
}
3636

37+
function nameOfKeyType(keyType: KeyType): string {
38+
switch (keyType) {
39+
case KeyType.DefinitionQuery: return "definitions";
40+
case KeyType.ReferenceQuery: return "references";
41+
}
42+
}
43+
3744
async function resolveQueries(cli: CodeQLCliServer, qlpack: string, keyType: KeyType): Promise<string[]> {
3845
const suiteFile = tmp.fileSync({ postfix: '.qls' }).name;
3946
const suiteYaml = { qlpack, include: { kind: 'definitions', 'tags contain': tagOfKeyType(keyType) } };
4047
await fs.writeFile(suiteFile, yaml.safeDump(suiteYaml), 'utf8');
4148

4249
const queries = await cli.resolveQueriesInSuite(suiteFile, helpers.getOnDiskWorkspaceFolders());
4350
if (queries.length === 0) {
44-
throw new Error("Couldn't find any queries for qlpack");
51+
vscode.window.showErrorMessage(
52+
`No ${nameOfKeyType(keyType)} queries (tagged "${tagOfKeyType(keyType)}") could be found in the current library path. It might be necessary to upgrade the CodeQL libraries.`
53+
);
54+
throw new Error(`Couldn't find any queries tagged ${tagOfKeyType(keyType)} for qlpack ${qlpack}`);
4555
}
4656
return queries;
4757
}

0 commit comments

Comments
 (0)