Skip to content

Commit ac4a22c

Browse files
committed
Support querydb blocked notifications
1 parent 168fe24 commit ac4a22c

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"publisher": "cquery-project",
88
"preview": true,
99
"engines": {
10-
"vscode": "^1.18.0"
10+
"vscode": "^1.22.0"
1111
},
1212
"categories": [
1313
"Programming Languages"
@@ -166,6 +166,11 @@
166166
"default": "",
167167
"description": "Absolute path to the directory that the cached index will be stored in. Try to have this directory on an SSD. If not explicitly set, this will be automatically populated with the extension cache directory.\n\n${workspaceFolder} will be replaced by the folder where .vscode/settings.json resides.\n\nCache directories are project-wide, so this should be configured in the workspace settings so multiple indexes do not clash.\n\nExample value: \"/work/cquery-cache/chrome/\""
168168
},
169+
"cquery.developer.emitQueryDbBlocked": {
170+
"type": "boolean",
171+
"default": false,
172+
"description": "If true, a notification will be shown whenever the querydb thread is busy."
173+
},
169174
"cquery.highlighting.enabled.types": {
170175
"type": "boolean",
171176
"default": false,

src/extension.ts

+37
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function getClientConfig(context: ExtensionContext) {
8484
['launchCommand', 'launch.command'],
8585
['launchArgs', 'launch.args'],
8686
['cacheDirectory', kCacheDirPrefName],
87+
['emitQueryDbBlocked', 'cquery.developer.emitQueryDbBlocked'],
8788
['index.whitelist', 'index.whitelist'],
8889
['index.blacklist', 'index.blacklist'],
8990
['index.logSkippedPaths', 'log.skippedPathsForIndex'],
@@ -517,6 +518,42 @@ export function activate(context: ExtensionContext) {
517518
}
518519
})();
519520

521+
// QueryDb busy
522+
(() => {
523+
// Notifications have a minimum time to live. If the status changes multiple
524+
// times within that interface, we will show multiple notifications. Try to
525+
// avoid that.
526+
const kGracePeriodMs = 250;
527+
528+
var timeout: NodeJS.Timer
529+
var resolvePromise: any
530+
languageClient.onReady().then(() => {
531+
languageClient.onNotification('$cquery/queryDbStatus', (args) => {
532+
let isActive: boolean = args.isActive;
533+
if (isActive) {
534+
if (timeout) {
535+
clearTimeout(timeout);
536+
timeout = undefined;
537+
}
538+
else {
539+
window.withProgress({location: ProgressLocation.Notification, title: 'querydb is busy'}, (p) => {
540+
p.report({increment: 100})
541+
return new Promise((resolve, reject) => {
542+
resolvePromise = resolve;
543+
});
544+
});
545+
}
546+
} else if (resolvePromise) {
547+
timeout = setTimeout(() => {
548+
resolvePromise();
549+
resolvePromise = undefined;
550+
timeout = undefined;
551+
}, kGracePeriodMs);
552+
}
553+
});
554+
});
555+
})();
556+
520557
// Inheritance hierarchy.
521558
(() => {
522559
const inheritanceHierarchyProvider =

0 commit comments

Comments
 (0)