@@ -15,7 +15,7 @@ import { FILES_ASSOCIATIONS_CONFIG, IFilesConfiguration } from 'vs/platform/file
15
15
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions' ;
16
16
import { ExtensionMessageCollector , ExtensionsRegistry , IExtensionPoint , IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry' ;
17
17
import { InstantiationType , registerSingleton } from 'vs/platform/instantiation/common/extensions' ;
18
- import { IExtensionDescription , IExtensionManifest } from 'vs/platform/extensions/common/extensions' ;
18
+ import { IExtensionManifest } from 'vs/platform/extensions/common/extensions' ;
19
19
import { ILogService } from 'vs/platform/log/common/log' ;
20
20
import { Disposable } from 'vs/base/common/lifecycle' ;
21
21
import { Extensions , IExtensionFeatureTableRenderer , IExtensionFeaturesRegistry , IRenderedData , IRowData , ITableData } from 'vs/workbench/services/extensionManagement/common/extensionFeatures' ;
@@ -131,14 +131,18 @@ class LanguageTableRenderer extends Disposable implements IExtensionFeatureTable
131
131
render ( manifest : IExtensionManifest ) : IRenderedData < ITableData > {
132
132
const contributes = manifest . contributes ;
133
133
const rawLanguages = contributes ?. languages || [ ] ;
134
- const languages = rawLanguages . map ( l => ( {
135
- id : l . id ,
136
- name : ( l . aliases || [ ] ) [ 0 ] || l . id ,
137
- extensions : l . extensions || [ ] ,
138
- hasGrammar : false ,
139
- hasSnippets : false
140
- } ) ) ;
141
-
134
+ const languages : { id : string ; name : string ; extensions : string [ ] ; hasGrammar : boolean ; hasSnippets : boolean } [ ] = [ ] ;
135
+ for ( const l of rawLanguages ) {
136
+ if ( isValidLanguageExtensionPoint ( l ) ) {
137
+ languages . push ( {
138
+ id : l . id ,
139
+ name : ( l . aliases || [ ] ) [ 0 ] || l . id ,
140
+ extensions : l . extensions || [ ] ,
141
+ hasGrammar : false ,
142
+ hasSnippets : false
143
+ } ) ;
144
+ }
145
+ }
142
146
const byId = index ( languages , l => l . id ) ;
143
147
144
148
const grammars = contributes ?. grammars || [ ] ;
@@ -235,7 +239,7 @@ export class WorkbenchLanguageService extends LanguageService {
235
239
236
240
for ( let j = 0 , lenJ = extension . value . length ; j < lenJ ; j ++ ) {
237
241
const ext = extension . value [ j ] ;
238
- if ( isValidLanguageExtensionPoint ( ext , extension . description , extension . collector ) ) {
242
+ if ( isValidLanguageExtensionPoint ( ext , extension . collector ) ) {
239
243
let configuration : URI | undefined = undefined ;
240
244
if ( ext . configuration ) {
241
245
configuration = joinPath ( extension . description . extensionLocation , ext . configuration ) ;
@@ -315,42 +319,42 @@ function isUndefinedOrStringArray(value: string[]): boolean {
315
319
return value . every ( item => typeof item === 'string' ) ;
316
320
}
317
321
318
- function isValidLanguageExtensionPoint ( value : IRawLanguageExtensionPoint , extension : IExtensionDescription , collector : ExtensionMessageCollector ) : boolean {
322
+ function isValidLanguageExtensionPoint ( value : any , collector ? : ExtensionMessageCollector ) : value is IRawLanguageExtensionPoint {
319
323
if ( ! value ) {
320
- collector . error ( localize ( 'invalid.empty' , "Empty value for `contributes.{0}`" , languagesExtPoint . name ) ) ;
324
+ collector ? .error ( localize ( 'invalid.empty' , "Empty value for `contributes.{0}`" , languagesExtPoint . name ) ) ;
321
325
return false ;
322
326
}
323
327
if ( typeof value . id !== 'string' ) {
324
- collector . error ( localize ( 'require.id' , "property `{0}` is mandatory and must be of type `string`" , 'id' ) ) ;
328
+ collector ? .error ( localize ( 'require.id' , "property `{0}` is mandatory and must be of type `string`" , 'id' ) ) ;
325
329
return false ;
326
330
}
327
331
if ( ! isUndefinedOrStringArray ( value . extensions ) ) {
328
- collector . error ( localize ( 'opt.extensions' , "property `{0}` can be omitted and must be of type `string[]`" , 'extensions' ) ) ;
332
+ collector ? .error ( localize ( 'opt.extensions' , "property `{0}` can be omitted and must be of type `string[]`" , 'extensions' ) ) ;
329
333
return false ;
330
334
}
331
335
if ( ! isUndefinedOrStringArray ( value . filenames ) ) {
332
- collector . error ( localize ( 'opt.filenames' , "property `{0}` can be omitted and must be of type `string[]`" , 'filenames' ) ) ;
336
+ collector ? .error ( localize ( 'opt.filenames' , "property `{0}` can be omitted and must be of type `string[]`" , 'filenames' ) ) ;
333
337
return false ;
334
338
}
335
339
if ( typeof value . firstLine !== 'undefined' && typeof value . firstLine !== 'string' ) {
336
- collector . error ( localize ( 'opt.firstLine' , "property `{0}` can be omitted and must be of type `string`" , 'firstLine' ) ) ;
340
+ collector ? .error ( localize ( 'opt.firstLine' , "property `{0}` can be omitted and must be of type `string`" , 'firstLine' ) ) ;
337
341
return false ;
338
342
}
339
343
if ( typeof value . configuration !== 'undefined' && typeof value . configuration !== 'string' ) {
340
- collector . error ( localize ( 'opt.configuration' , "property `{0}` can be omitted and must be of type `string`" , 'configuration' ) ) ;
344
+ collector ? .error ( localize ( 'opt.configuration' , "property `{0}` can be omitted and must be of type `string`" , 'configuration' ) ) ;
341
345
return false ;
342
346
}
343
347
if ( ! isUndefinedOrStringArray ( value . aliases ) ) {
344
- collector . error ( localize ( 'opt.aliases' , "property `{0}` can be omitted and must be of type `string[]`" , 'aliases' ) ) ;
348
+ collector ? .error ( localize ( 'opt.aliases' , "property `{0}` can be omitted and must be of type `string[]`" , 'aliases' ) ) ;
345
349
return false ;
346
350
}
347
351
if ( ! isUndefinedOrStringArray ( value . mimetypes ) ) {
348
- collector . error ( localize ( 'opt.mimetypes' , "property `{0}` can be omitted and must be of type `string[]`" , 'mimetypes' ) ) ;
352
+ collector ? .error ( localize ( 'opt.mimetypes' , "property `{0}` can be omitted and must be of type `string[]`" , 'mimetypes' ) ) ;
349
353
return false ;
350
354
}
351
355
if ( typeof value . icon !== 'undefined' ) {
352
356
if ( typeof value . icon !== 'object' || typeof value . icon . light !== 'string' || typeof value . icon . dark !== 'string' ) {
353
- collector . error ( localize ( 'opt.icon' , "property `{0}` can be omitted and must be of type `object` with properties `{1}` and `{2}` of type `string`" , 'icon' , 'light' , 'dark' ) ) ;
357
+ collector ? .error ( localize ( 'opt.icon' , "property `{0}` can be omitted and must be of type `object` with properties `{1}` and `{2}` of type `string`" , 'icon' , 'light' , 'dark' ) ) ;
354
358
return false ;
355
359
}
356
360
}
0 commit comments