src/vs/workbench/contrib/preferences/browser/settingsTreeModels.ts/inspectSetting
export function inspectSetting(key: string, target: SettingsTarget, languageFilter: string | undefined, configurationService: IWorkbenchConfigurationService): IInspectResult {
	const inspectOverrides = URI.isUri(target) ? { resource: target } : undefined;
	const inspected = configurationService.inspect(key, inspectOverrides);
	const targetSelector = target === ConfigurationTarget.USER_LOCAL ? 'userLocalValue' :
		target === ConfigurationTarget.USER_REMOTE ? 'userRemoteValue' :
			target === ConfigurationTarget.WORKSPACE ? 'workspaceValue' :
				'workspaceFolderValue';
	const targetOverrideSelector = target === ConfigurationTarget.USER_LOCAL ? 'userLocal' :
		target === ConfigurationTarget.USER_REMOTE ? 'userRemote' :
			target === ConfigurationTarget.WORKSPACE ? 'workspace' :
				'workspaceFolder';
	let isConfigured = typeof inspected[targetSelector] !== 'undefined';
	if (!isConfigured) {
		if (target === ConfigurationTarget.USER_LOCAL) {
			isConfigured = !!configurationService.restrictedSettings.userLocal?.includes(key);
		} else if (target === ConfigurationTarget.USER_REMOTE) {
			isConfigured = !!configurationService.restrictedSettings.userRemote?.includes(key);
		} else if (target === ConfigurationTarget.WORKSPACE) {
			isConfigured = !!configurationService.restrictedSettings.workspace?.includes(key);
		} else if (target instanceof URI) {
			isConfigured = !!configurationService.restrictedSettings.workspaceFolder?.get(target)?.includes(key);
		}
	}

	const overrideIdentifiers = inspected.overrideIdentifiers;
	const inspectedLanguageOverrides = new Map<string, IConfigurationValue<unknown>>();

	// We must reset isConfigured to be false if languageFilter is set, and manually
	// determine whether it can be set to true later.
	if (languageFilter) {
		isConfigured = false;
	}
	if (overrideIdentifiers) {
		// The setting we're looking at has language overrides.
		for (const overrideIdentifier of overrideIdentifiers) {
			inspectedLanguageOverrides.set(overrideIdentifier, configurationService.inspect(key, { overrideIdentifier }));
		}

		// For all language filters, see if there's an override for that filter.
		if (languageFilter) {
			if (inspectedLanguageOverrides.has(languageFilter)) {
				const overrideValue = inspectedLanguageOverrides.get(languageFilter)![targetOverrideSelector]?.override;
				if (typeof overrideValue !== 'undefined') {
					isConfigured = true;
				}
			}
		}
	}

	return { isConfigured, inspected, targetSelector, inspectedLanguageOverrides, languageSelector: languageFilter };
}