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(() => {
|
this.client.onReady(() => {
|
||||||
const languages = new Set<string>();
|
const languages = new Set<string>();
|
||||||
for (const plugin of pluginManager.plugins) {
|
for (const plugin of pluginManager.plugins) {
|
||||||
for (const language of plugin.languages) {
|
if (plugin.configNamespace && plugin.languages.length) {
|
||||||
languages.add(language);
|
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) {
|
if (languages.size) {
|
||||||
const description: LanguageDescription = {
|
this.registerExtensionLanguageProvider({
|
||||||
id: 'typescript-plugins',
|
id: 'typescript-plugins',
|
||||||
modeIds: Array.from(languages.values()),
|
modeIds: Array.from(languages.values()),
|
||||||
diagnosticSource: 'ts-plugin',
|
diagnosticSource: 'ts-plugin',
|
||||||
diagnosticLanguage: DiagnosticLanguage.TypeScript,
|
diagnosticLanguage: DiagnosticLanguage.TypeScript,
|
||||||
diagnosticOwner: 'typescript',
|
diagnosticOwner: 'typescript',
|
||||||
isExternal: true
|
isExternal: true
|
||||||
};
|
}, onCompletionAccepted);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -125,6 +133,13 @@ export default class TypeScriptServiceClientHost extends Disposable {
|
||||||
this.configurationChanged();
|
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) {
|
private getAllModeIds(descriptions: LanguageDescription[], pluginManager: PluginManager) {
|
||||||
const allModeIds = flatten([
|
const allModeIds = flatten([
|
||||||
...descriptions.map(x => x.modeIds),
|
...descriptions.map(x => x.modeIds),
|
||||||
|
|
|
@ -12,6 +12,7 @@ export interface TypeScriptServerPlugin {
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
readonly enableForWorkspaceTypeScriptVersions: boolean;
|
readonly enableForWorkspaceTypeScriptVersions: boolean;
|
||||||
readonly languages: ReadonlyArray<string>;
|
readonly languages: ReadonlyArray<string>;
|
||||||
|
readonly configNamespace?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace TypeScriptServerPlugin {
|
namespace TypeScriptServerPlugin {
|
||||||
|
@ -77,6 +78,7 @@ export class PluginManager extends Disposable {
|
||||||
enableForWorkspaceTypeScriptVersions: !!plugin.enableForWorkspaceTypeScriptVersions,
|
enableForWorkspaceTypeScriptVersions: !!plugin.enableForWorkspaceTypeScriptVersions,
|
||||||
path: extension.extensionPath,
|
path: extension.extensionPath,
|
||||||
languages: Array.isArray(plugin.languages) ? plugin.languages : [],
|
languages: Array.isArray(plugin.languages) ? plugin.languages : [],
|
||||||
|
configNamespace: plugin.configNamespace,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (plugins.length) {
|
if (plugins.length) {
|
||||||
|
@ -86,4 +88,4 @@ export class PluginManager extends Disposable {
|
||||||
}
|
}
|
||||||
return pluginMap;
|
return pluginMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue