Prevent error from being logged due to custom configuration processing prior to the provider being ready (#8841)

This commit is contained in:
Colen Garoutte-Carson 2022-02-10 18:06:43 -08:00 коммит произвёл GitHub
Родитель b4625c7c30
Коммит e5abfbca71
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 51 добавлений и 54 удалений

Просмотреть файл

@ -1803,6 +1803,9 @@ export class DefaultClient implements Client {
// If we are being called by a configuration provider other than the current one, ignore it.
return;
}
if (!currentProvider.isReady) {
return;
}
this.clearCustomConfigurations();
if (diagnosticsCollectionCodeAnalysis) {
@ -1821,7 +1824,7 @@ export class DefaultClient implements Client {
}
console.log("updateCustomBrowseConfiguration");
const currentProvider: CustomConfigurationProvider1 | undefined = getCustomConfigProviders().get(this.configurationProvider);
if (!currentProvider || (requestingProvider && requestingProvider.extensionId !== currentProvider.extensionId)) {
if (!currentProvider || !currentProvider.isReady || (requestingProvider && requestingProvider.extensionId !== currentProvider.extensionId)) {
return;
}
@ -1950,14 +1953,10 @@ export class DefaultClient implements Client {
return;
}
const provider: CustomConfigurationProvider1 | undefined = getCustomConfigProviders().get(providerId);
if (!provider) {
if (!provider || !provider.isReady) {
onFinished();
return;
}
if (!provider.isReady) {
onFinished();
throw new Error(`${this.configurationProvider} is not ready`);
}
return this.queueBlockingTask(async () => {
const tokenSource: vscode.CancellationTokenSource = new vscode.CancellationTokenSource();
console.log("provideCustomConfiguration");
@ -1978,58 +1977,56 @@ export class DefaultClient implements Client {
// Need to loop through candidates, to see if we can get a custom configuration from any of them.
// Wrap all lookups in a single task, so we can apply a timeout to the entire duration.
const provideConfigurationAsync: () => Thenable<SourceFileConfigurationItem[] | null | undefined> = async () => {
if (provider) {
for (let i: number = 0; i < response.candidates.length; ++i) {
try {
const candidate: string = response.candidates[i];
const tuUri: vscode.Uri = vscode.Uri.parse(candidate);
if (await provider.canProvideConfiguration(tuUri, tokenSource.token)) {
const configs: util.Mutable<SourceFileConfigurationItem>[] = await provider.provideConfigurations([tuUri], tokenSource.token);
if (configs && configs.length > 0 && configs[0]) {
const fileConfiguration: configs.Configuration | undefined = this.configuration.CurrentConfiguration;
if (fileConfiguration?.mergeConfigurations) {
configs.forEach(config => {
if (fileConfiguration.includePath) {
fileConfiguration.includePath.forEach(p => {
if (!config.configuration.includePath.includes(p)) {
config.configuration.includePath.push(p);
for (let i: number = 0; i < response.candidates.length; ++i) {
try {
const candidate: string = response.candidates[i];
const tuUri: vscode.Uri = vscode.Uri.parse(candidate);
if (await provider.canProvideConfiguration(tuUri, tokenSource.token)) {
const configs: util.Mutable<SourceFileConfigurationItem>[] = await provider.provideConfigurations([tuUri], tokenSource.token);
if (configs && configs.length > 0 && configs[0]) {
const fileConfiguration: configs.Configuration | undefined = this.configuration.CurrentConfiguration;
if (fileConfiguration?.mergeConfigurations) {
configs.forEach(config => {
if (fileConfiguration.includePath) {
fileConfiguration.includePath.forEach(p => {
if (!config.configuration.includePath.includes(p)) {
config.configuration.includePath.push(p);
}
});
}
if (fileConfiguration.defines) {
fileConfiguration.defines.forEach(d => {
if (!config.configuration.defines.includes(d)) {
config.configuration.defines.push(d);
}
});
}
if (!config.configuration.forcedInclude) {
config.configuration.forcedInclude = [];
}
if (fileConfiguration.forcedInclude) {
fileConfiguration.forcedInclude.forEach(i => {
if (config.configuration.forcedInclude) {
if (!config.configuration.forcedInclude.includes(i)) {
config.configuration.forcedInclude.push(i);
}
});
}
if (fileConfiguration.defines) {
fileConfiguration.defines.forEach(d => {
if (!config.configuration.defines.includes(d)) {
config.configuration.defines.push(d);
}
});
}
if (!config.configuration.forcedInclude) {
config.configuration.forcedInclude = [];
}
if (fileConfiguration.forcedInclude) {
fileConfiguration.forcedInclude.forEach(i => {
if (config.configuration.forcedInclude) {
if (!config.configuration.forcedInclude.includes(i)) {
config.configuration.forcedInclude.push(i);
}
}
});
}
});
}
return configs as SourceFileConfigurationItem[];
}
});
}
});
}
return configs as SourceFileConfigurationItem[];
}
if (tokenSource.token.isCancellationRequested) {
return null;
}
} catch (err) {
console.warn("Caught exception request configuration");
}
if (tokenSource.token.isCancellationRequested) {
return null;
}
} catch (err) {
console.warn("Caught exception request configuration");
}
}
};