@@ -36,7 +36,6 @@ export function toVsCodeRange(range: Range): vscode.Range {
3636}
3737
3838export const SUPPORTED_LANGUAGES = [ "robotframework" ] ;
39- export const SUPPORTED_SUITE_FILE_EXTENSIONS = [ ".robot" ] ;
4039
4140export interface Keyword {
4241 name : string ;
@@ -102,6 +101,15 @@ interface DiscoverInfoResult {
102101 [ key : string ] : string | undefined ;
103102}
104103
104+ interface RobotCodeContributions {
105+ contributes ?: {
106+ robotCode ?: {
107+ fileExtensions ?: string [ ] ;
108+ languageIds ?: string [ ] ;
109+ } ;
110+ } ;
111+ }
112+
105113export class LanguageClientsManager {
106114 private clientsMutex = new Mutex ( ) ;
107115 private _pythonValidPythonAndRobotEnvMutex = new Mutex ( ) ;
@@ -120,9 +128,43 @@ export class LanguageClientsManager {
120128 return this . _onClientStateChangedEmitter . event ;
121129 }
122130
131+ private _supportedLanguages ?: string [ ] ;
132+
133+ public get supportedLanguages ( ) : string [ ] {
134+ if ( this . _supportedLanguages === undefined ) {
135+ this . _supportedLanguages = [ "robotframework" ] ;
136+
137+ vscode . extensions . all . forEach ( ( extension ) => {
138+ if ( this . _supportedLanguages !== undefined && extension . packageJSON !== undefined ) {
139+ const ext = ( extension . packageJSON as RobotCodeContributions ) ?. contributes ?. robotCode ?. languageIds ;
140+
141+ if ( ext !== undefined ) {
142+ this . _supportedLanguages . push ( ...ext ) ;
143+ }
144+ }
145+ } ) ;
146+ }
147+ return this . _supportedLanguages ;
148+ }
149+
150+ private _fileExtensions ?: string [ ] ;
151+
123152 // eslint-disable-next-line class-methods-use-this
124153 public get fileExtensions ( ) : string [ ] {
125- return [ "robot" , "resource" ] ;
154+ if ( this . _fileExtensions === undefined ) {
155+ this . _fileExtensions = [ "robot" , "resource" ] ;
156+
157+ vscode . extensions . all . forEach ( ( extension ) => {
158+ if ( this . _fileExtensions !== undefined && extension . packageJSON !== undefined ) {
159+ const ext = ( extension . packageJSON as RobotCodeContributions ) ?. contributes ?. robotCode ?. fileExtensions ;
160+
161+ if ( ext !== undefined ) {
162+ this . _fileExtensions . push ( ...ext ) ;
163+ }
164+ }
165+ } ) ;
166+ }
167+ return this . _fileExtensions ;
126168 }
127169
128170 constructor (
@@ -375,7 +417,7 @@ export class LanguageClientsManager {
375417 }
376418
377419 public async getLanguageClientForDocument ( document : vscode . TextDocument ) : Promise < LanguageClient | undefined > {
378- if ( ! SUPPORTED_LANGUAGES . includes ( document . languageId ) ) return ;
420+ if ( ! this . supportedLanguages . includes ( document . languageId ) ) return ;
379421
380422 return this . getLanguageClientForResource ( document . uri ) ;
381423 }
@@ -613,7 +655,7 @@ export class LanguageClientsManager {
613655 }
614656
615657 for ( const document of vscode . workspace . textDocuments ) {
616- if ( SUPPORTED_LANGUAGES . includes ( document . languageId ) ) {
658+ if ( this . supportedLanguages . includes ( document . languageId ) ) {
617659 const workspaceFolder = vscode . workspace . getWorkspaceFolder ( document . uri ) ;
618660 if ( workspaceFolder ) {
619661 folders . add ( workspaceFolder ) ;
@@ -728,7 +770,7 @@ export class LanguageClientsManager {
728770 }
729771
730772 private async updateStatusbarItem ( editor : vscode . TextEditor | undefined ) {
731- if ( editor && SUPPORTED_LANGUAGES . includes ( editor . document . languageId ) ) {
773+ if ( editor && this . supportedLanguages . includes ( editor . document . languageId ) ) {
732774 try {
733775 const folder = vscode . workspace . getWorkspaceFolder ( editor . document . uri ) ;
734776 if ( folder ) {
0 commit comments