Skip to content

Commit e15f153

Browse files
authored
Merge pull request #3125 from github/aeisenberg/no-multi-token
Avoid creating a multitoken when finding definitions
2 parents 9594a5e + 8516940 commit e15f153

3 files changed

Lines changed: 34 additions & 34 deletions

File tree

extensions/ql-vscode/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [UNRELEASED]
44

5+
- Avoid showing a popup when hovering over source elements in database source files. [#3125](https://github.com/github/vscode-codeql/pull/3125)
6+
57
## 1.11.0 - 13 December 2023
68

79
- Add a new method modeling panel to classify methods as sources/sinks/summaries while in the context of the source code. [#3128](https://github.com/github/vscode-codeql/pull/3128)
@@ -19,7 +21,7 @@
1921
- Add new CodeQL views for managing databases and queries:
2022
1. A queries panel that shows all queries in your workspace. It allows you to view, create, and run queries in one place.
2123
2. A language selector, which allows you to quickly filter databases and queries by language.
22-
24+
2325
For more information, see the [documentation](https://codeql.github.com/docs/codeql-for-visual-studio-code/analyzing-your-projects/#filtering-databases-and-queries-by-language).
2426
- When adding a CodeQL database, we no longer add the database source folder to the workspace by default (since this caused bugs in single-folder workspaces). [#3047](https://github.com/github/vscode-codeql/pull/3047)
2527
- You can manually add individual database source folders to the workspace with the "Add Database Source to Workspace" right-click command in the databases view.

extensions/ql-vscode/src/extension.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,23 +1086,27 @@ async function activateWithInstalledDistribution(
10861086
// Jump-to-definition and find-references
10871087
void extLogger.log("Registering jump-to-definition handlers.");
10881088

1089-
languages.registerDefinitionProvider(
1090-
{ scheme: zipArchiveScheme },
1091-
new TemplateQueryDefinitionProvider(
1092-
cliServer,
1093-
qs,
1094-
dbm,
1095-
contextualQueryStorageDir,
1089+
ctx.subscriptions.push(
1090+
languages.registerDefinitionProvider(
1091+
{ scheme: zipArchiveScheme },
1092+
new TemplateQueryDefinitionProvider(
1093+
cliServer,
1094+
qs,
1095+
dbm,
1096+
contextualQueryStorageDir,
1097+
),
10961098
),
10971099
);
10981100

1099-
languages.registerReferenceProvider(
1100-
{ scheme: zipArchiveScheme },
1101-
new TemplateQueryReferenceProvider(
1102-
cliServer,
1103-
qs,
1104-
dbm,
1105-
contextualQueryStorageDir,
1101+
ctx.subscriptions.push(
1102+
languages.registerReferenceProvider(
1103+
{ scheme: zipArchiveScheme },
1104+
new TemplateQueryReferenceProvider(
1105+
cliServer,
1106+
qs,
1107+
dbm,
1108+
contextualQueryStorageDir,
1109+
),
11061110
),
11071111
);
11081112

extensions/ql-vscode/src/language-support/contextual/template-provider.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,18 @@ export class TemplateQueryDefinitionProvider implements DefinitionProvider {
8888
uriString: string,
8989
token: CancellationToken,
9090
): Promise<LocationLink[]> {
91-
return withProgress(
92-
async (progress, tokenInner) => {
93-
const multiToken = new MultiCancellationToken(token, tokenInner);
94-
return getLocationsForUriString(
95-
this.cli,
96-
this.qs,
97-
this.dbm,
98-
uriString,
99-
KeyType.DefinitionQuery,
100-
this.queryStorageDir,
101-
progress,
102-
multiToken,
103-
(src, _dest) => src === uriString,
104-
);
105-
},
106-
{
107-
cancellable: true,
108-
title: "Finding definitions",
109-
},
91+
// Do not create a multitoken here. There will be no popup and users cannot click on anything to cancel this operation.
92+
// This is because finding definitions can be triggered by a hover, which should not have a popup.
93+
return getLocationsForUriString(
94+
this.cli,
95+
this.qs,
96+
this.dbm,
97+
uriString,
98+
KeyType.DefinitionQuery,
99+
this.queryStorageDir,
100+
() => {}, // noop
101+
token,
102+
(src, _dest) => src === uriString,
110103
);
111104
}
112105
}
@@ -161,6 +154,7 @@ export class TemplateQueryReferenceProvider implements ReferenceProvider {
161154
uriString: string,
162155
token: CancellationToken,
163156
): Promise<FullLocationLink[]> {
157+
// Create a multitoken here. There will be a popup and users can click on it to cancel this operation.
164158
return withProgress(
165159
async (progress, tokenInner) => {
166160
const multiToken = new MultiCancellationToken(token, tokenInner);

0 commit comments

Comments
 (0)