@@ -8,16 +8,16 @@ import assert = require('node:assert');
8
8
export function convertServerOptionNameToClientConfigurationName ( section : string ) : string | null {
9
9
// Server name would be in format {languageName}|{grouping}.{name} or
10
10
// {grouping}.{name} if this option can be applied to multiple languages.
11
- let languageNameIndex = section . indexOf ( '|' ) ;
11
+ const languageNameIndex = section . indexOf ( '|' ) ;
12
12
if ( languageNameIndex == - 1 || section . substring ( 0 , languageNameIndex ) == 'csharp' ) {
13
13
// 1. locate the last dot to find the {name} part.
14
- let lastDotIndex = section . lastIndexOf ( '.' ) ;
14
+ const lastDotIndex = section . lastIndexOf ( '.' ) ;
15
15
assert ( lastDotIndex !== - 1 , `There is no . in ${ section } .` ) ;
16
- let optionName = section . substring ( lastDotIndex + 1 ) ;
16
+ const optionName = section . substring ( lastDotIndex + 1 ) ;
17
17
18
18
// 2. Get {grouping} part.
19
- let startIndex = languageNameIndex == - 1 ? 0 : languageNameIndex + 1 ;
20
- let optionGroupName = section . substring ( startIndex , lastDotIndex ) ;
19
+ const startIndex = languageNameIndex == - 1 ? 0 : languageNameIndex + 1 ;
20
+ const optionGroupName = section . substring ( startIndex , lastDotIndex ) ;
21
21
22
22
// 3. {name} part from roslyn would be in editorconfig-like form.
23
23
// A valid prefix here is dotnet, csharp or no prefix
@@ -27,7 +27,7 @@ export function convertServerOptionNameToClientConfigurationName(section: string
27
27
// Name: dotnet_insertion_behavior
28
28
// Expect result is: dotnet.implmentType.insertionBehavior
29
29
const prefixes = [ 'dotnet' , 'csharp' ] ;
30
- let optionNamePrefix = getPrefix ( optionName , prefixes ) ;
30
+ const optionNamePrefix = getPrefix ( optionName , prefixes ) ;
31
31
32
32
let featureName = optionNamePrefix == '' ? optionName : optionName . substring ( optionNamePrefix . length + 1 ) ;
33
33
@@ -38,8 +38,8 @@ export function convertServerOptionNameToClientConfigurationName(section: string
38
38
}
39
39
40
40
// Finally, convert everything to camel case and put them together.
41
- let camelCaseGroupName = convertToCamelCase ( optionGroupName , '_' ) ;
42
- let camelCaseFeatureName = convertToCamelCase ( featureName , '_' ) ;
41
+ const camelCaseGroupName = convertToCamelCase ( optionGroupName , '_' ) ;
42
+ const camelCaseFeatureName = convertToCamelCase ( featureName , '_' ) ;
43
43
return optionNamePrefix == ''
44
44
? camelCaseGroupName . concat ( '.' , camelCaseFeatureName )
45
45
: convertToCamelCase ( optionNamePrefix , '_' ) . concat ( '.' , camelCaseGroupName , '.' , camelCaseFeatureName ) ;
@@ -61,16 +61,16 @@ function getPrefix(section: string, prefixes: string[]) {
61
61
}
62
62
63
63
function convertToCamelCase ( inputString : string , delimiter : string ) : string {
64
- let words = inputString . split ( delimiter ) . map ( word => word . toLowerCase ( ) ) ;
64
+ const words = inputString . split ( delimiter ) . map ( word => word . toLowerCase ( ) ) ;
65
65
if ( words . length <= 1 ) {
66
66
return inputString . toLowerCase ( ) ;
67
67
}
68
68
69
- let firstWord = words [ 0 ] ;
70
- let capitalizedWords = words . slice ( 1 ) . map ( capitalize ) ;
69
+ const firstWord = words [ 0 ] ;
70
+ const capitalizedWords = words . slice ( 1 ) . map ( capitalize ) ;
71
71
return firstWord . concat ( ...capitalizedWords ) ;
72
72
}
73
73
74
74
function capitalize ( inputString : string ) : string {
75
- return inputString . charAt ( 0 ) . toUpperCase ( ) + inputString . substring ( 1 ) ;
75
+ return inputString . charAt ( 0 ) . toUpperCase ( ) + inputString . substring ( 1 ) ;
76
76
}
0 commit comments