feat: use configNamespace for registering language providers of other extensions (#95621)
fixes #75890
This commit is contained in:
parent
03beeec722
commit
47c54f0e32
|
@ -97,23 +97,31 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
|||
this.client.onReady(() => {
|
||||
const languages = new Set<string>();
|
||||
for (const plugin of pluginManager.plugins) {
|
||||
for (const language of plugin.languages) {
|
||||
languages.add(language);
|
||||
if (plugin.configNamespace && plugin.languages.length) {
|
||||
this.registerExtensionLanguageProvider({
|
||||
id: plugin.configNamespace,
|
||||
modeIds: Array.from(plugin.languages),
|
||||
diagnosticSource: 'ts-plugin',
|
||||
diagnosticLanguage: DiagnosticLanguage.TypeScript,
|
||||
diagnosticOwner: 'typescript',
|
||||
isExternal: true
|
||||
}, onCompletionAccepted);
|
||||
} else {
|
||||
for (const language of plugin.languages) {
|
||||
languages.add(language);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (languages.size) {
|
||||
const description: LanguageDescription = {
|
||||
this.registerExtensionLanguageProvider({
|
||||
id: 'typescript-plugins',
|
||||
modeIds: Array.from(languages.values()),
|
||||
diagnosticSource: 'ts-plugin',
|
||||
diagnosticLanguage: DiagnosticLanguage.TypeScript,
|
||||
diagnosticOwner: 'typescript',
|
||||
isExternal: true
|
||||
};
|
||||
const manager = new LanguageProvider(this.client, description, this.commandManager, this.client.telemetryReporter, this.typingsStatus, this.fileConfigurationManager, onCompletionAccepted);
|
||||
this.languages.push(manager);
|
||||
this._register(manager);
|
||||
this.languagePerId.set(description.id, manager);
|
||||
}, onCompletionAccepted);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -125,6 +133,13 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
|||
this.configurationChanged();
|
||||
}
|
||||
|
||||
private registerExtensionLanguageProvider(description: LanguageDescription, onCompletionAccepted: (item: vscode.CompletionItem) => void) {
|
||||
const manager = new LanguageProvider(this.client, description, this.commandManager, this.client.telemetryReporter, this.typingsStatus, this.fileConfigurationManager, onCompletionAccepted);
|
||||
this.languages.push(manager);
|
||||
this._register(manager);
|
||||
this.languagePerId.set(description.id, manager);
|
||||
}
|
||||
|
||||
private getAllModeIds(descriptions: LanguageDescription[], pluginManager: PluginManager) {
|
||||
const allModeIds = flatten([
|
||||
...descriptions.map(x => x.modeIds),
|
||||
|
|
|
@ -12,6 +12,7 @@ export interface TypeScriptServerPlugin {
|
|||
readonly name: string;
|
||||
readonly enableForWorkspaceTypeScriptVersions: boolean;
|
||||
readonly languages: ReadonlyArray<string>;
|
||||
readonly configNamespace?: string
|
||||
}
|
||||
|
||||
namespace TypeScriptServerPlugin {
|
||||
|
@ -77,6 +78,7 @@ export class PluginManager extends Disposable {
|
|||
enableForWorkspaceTypeScriptVersions: !!plugin.enableForWorkspaceTypeScriptVersions,
|
||||
path: extension.extensionPath,
|
||||
languages: Array.isArray(plugin.languages) ? plugin.languages : [],
|
||||
configNamespace: plugin.configNamespace,
|
||||
});
|
||||
}
|
||||
if (plugins.length) {
|
||||
|
@ -86,4 +88,4 @@ export class PluginManager extends Disposable {
|
|||
}
|
||||
return pluginMap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue