33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import assert from 'node:assert' ;
7-
86export function convertServerOptionNameToClientConfigurationName ( section : string ) : string | null {
97 // Server name would be in format {languageName}|{grouping}.{name} or
10- // {grouping}.{name} if this option can be applied to multiple languages.
8+ // {grouping}.{name} if this option can be applied to multiple languages or
9+ // just {name} if this option is not in a group.
1110 const languageNameIndex = section . indexOf ( '|' ) ;
1211 if ( languageNameIndex == - 1 || section . substring ( 0 , languageNameIndex ) == 'csharp' ) {
1312 // 1. locate the last dot to find the {name} part.
1413 const lastDotIndex = section . lastIndexOf ( '.' ) ;
15- assert ( lastDotIndex !== - 1 , `There is no . in ${ section } .` ) ;
1614 const optionName = section . substring ( lastDotIndex + 1 ) ;
1715
1816 // 2. Get {grouping} part.
@@ -25,7 +23,7 @@ export function convertServerOptionNameToClientConfigurationName(section: string
2523 // Example:
2624 // Grouping: implement_type
2725 // Name: dotnet_insertion_behavior
28- // Expect result is: dotnet.implmentType .insertionBehavior
26+ // Expect result is: dotnet.implementType .insertionBehavior
2927 const prefixes = [ 'dotnet' , 'csharp' ] ;
3028 const optionNamePrefix = getPrefix ( optionName , prefixes ) ;
3129
@@ -34,9 +32,11 @@ export function convertServerOptionNameToClientConfigurationName(section: string
3432 // Finally, convert everything to camel case and put them together.
3533 const camelCaseGroupName = convertToCamelCase ( optionGroupName , '_' ) ;
3634 const camelCaseFeatureName = convertToCamelCase ( featureName , '_' ) ;
37- return optionNamePrefix == ''
38- ? camelCaseGroupName . concat ( '.' , camelCaseFeatureName )
39- : convertToCamelCase ( optionNamePrefix , '_' ) . concat ( '.' , camelCaseGroupName , '.' , camelCaseFeatureName ) ;
35+ const camelCasePrefixName = convertToCamelCase ( optionNamePrefix , '_' ) ;
36+
37+ // Concatenate the three parts together, with dots as separators, but only if they are not empty.
38+ const parts = [ camelCasePrefixName , camelCaseGroupName , camelCaseFeatureName ] . filter ( ( part ) => part !== '' ) ;
39+ return parts . join ( '.' ) ;
4040 }
4141
4242 return null ;
0 commit comments