extensions/configuration-editing/src/configurationEditingMain.ts/registerContextKeyCompletions
function registerContextKeyCompletions(): vscode.Disposable {
	type ContextKeyInfo = { key: string, type?: string, description?: string };

	const paths = new Map<vscode.DocumentFilter, JSONPath[]>([
		[{ language: 'jsonc', pattern: '**/keybindings.json' }, [
			['*', 'when']
		]],
		[{ language: 'json', pattern: '**/package.json' }, [
			['contributes', 'menus', '*', '*', 'when'],
			['contributes', 'views', '*', '*', 'when'],
			['contributes', 'viewsWelcome', '*', 'when'],
			['contributes', 'keybindings', '*', 'when'],
			['contributes', 'keybindings', 'when'],
		]]
	]);

	return vscode.languages.registerCompletionItemProvider(
		[...paths.keys()],
		{
			async provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken) {

				const location = getLocation(document.getText(), document.offsetAt(position));

				if (location.isAtPropertyKey) {
					return;
				}

				let isValidLocation = false;
				for (const [key, value] of paths) {
					if (vscode.languages.match(key, document)) {
						if (value.some(location.matches.bind(location))) {
							isValidLocation = true;
							break;
						}
					}
				}

				if (!isValidLocation) {
					return;
				}

				// for JSON everything with quotes is a word
				const jsonWord = document.getWordRangeAtPosition(position);
				if (!jsonWord || jsonWord.start.isEqual(position) || jsonWord.end.isEqual(position)) {
					// we aren't inside a "JSON word" or on its quotes
					return;
				}

				let replacing: vscode.Range | undefined;
				if (jsonWord.end.character - jsonWord.start.character === 2 || document.getWordRangeAtPosition(position, /\s+/)) {
					// empty json word or on whitespace
					replacing = new vscode.Range(position, position);
				} else {
					replacing = document.getWordRangeAtPosition(position, /[a-zA-Z.]+/);
				}

				if (!replacing) {
					return;
				}
				const inserting = replacing.with(undefined, position);

				const data = await vscode.commands.executeCommand<ContextKeyInfo[]>('getContextKeyInfo');
				if (token.isCancellationRequested || !data) {
					return;
				}

				const result = new vscode.CompletionList();
				for (const item of data) {
					const completion = new vscode.CompletionItem(item.key, vscode.CompletionItemKind.Constant);
					completion.detail = item.type;
					completion.range = { replacing, inserting };
					completion.documentation = item.description;
					result.items.push(completion);
				}
				return result;
			}
		}
	);
}