@@ -52,9 +52,9 @@ export class ConfigResolver {
5252 }
5353
5454 getHmsSdkPath ( ) : string | undefined {
55- return this . params . initializationOptions ?. ets ?. hmsSdkPath
56- ? path . resolve ( this . params . initializationOptions ?. ets ?. hmsSdkPath )
57- : this . params . initializationOptions ?. ets ?. hmsSdkPath
55+ return this . params . initializationOptions ?. ets ?. hmsPath
56+ ? path . resolve ( this . params . initializationOptions ?. ets ?. hmsPath )
57+ : this . params . initializationOptions ?. ets ?. hmsPath
5858 }
5959
6060 getEtsLoaderPath ( ) : string {
@@ -137,28 +137,36 @@ export class ConfigResolver {
137137 }
138138
139139 private async hmsToTypeScriptCompilerOptionsPaths ( ) : Promise < import ( 'typescript' ) . MapLike < string [ ] > > {
140- const hmsSdkPath = this . getHmsSdkPath ( )
141- if ( ! hmsSdkPath ) return { }
142- const hmsApiFolder = Utils . joinPath ( URI . file ( hmsSdkPath ) , 'api' )
143- const hmsKitsFolder = Utils . joinPath ( URI . file ( hmsSdkPath ) , 'kits' )
144- if ( ! hmsApiFolder || ! hmsKitsFolder ) return { }
145-
146- const paths : import ( 'typescript' ) . MapLike < string [ ] > = { }
147- const apiFiles = await this . fs . readDirectory ( hmsApiFolder )
148- const kitsFiles = await this . fs . readDirectory ( hmsKitsFolder )
149- for ( const [ fileNameWithExtension , fileType ] of apiFiles ) {
150- if ( fileType !== FileType . File ) continue
151- const fileName = this . getFileNameWithoutExtension ( fileNameWithExtension )
152- paths [ fileName ] = [ Utils . joinPath ( hmsApiFolder , fileNameWithExtension ) . fsPath ]
153- paths [ `${ fileName } /*` ] = [ Utils . joinPath ( hmsApiFolder , fileNameWithExtension , '*' ) . fsPath ]
140+ try {
141+ const hmsSdkPath = this . getHmsSdkPath ( )
142+ if ( ! hmsSdkPath ) return { }
143+ const hmsApiFolder = Utils . joinPath ( URI . file ( hmsSdkPath ) , 'ets' , 'api' )
144+ const hmsKitsFolder = Utils . joinPath ( URI . file ( hmsSdkPath ) , 'ets' , 'kits' )
145+ if ( ! hmsApiFolder || ! hmsKitsFolder ) return { }
146+
147+ const paths : import ( 'typescript' ) . MapLike < string [ ] > = { }
148+ const apiFiles = await this . fs . readDirectory ( hmsApiFolder )
149+ const kitsFiles = await this . fs . readDirectory ( hmsKitsFolder )
150+ for ( const [ fileNameWithExtension , fileType ] of apiFiles ) {
151+ if ( fileType !== FileType . File ) continue
152+ const fileName = this . getFileNameWithoutExtension ( fileNameWithExtension )
153+ paths [ fileName ] = [ Utils . joinPath ( hmsApiFolder , fileNameWithExtension ) . fsPath ]
154+ paths [ `${ fileName } /*` ] = [ Utils . joinPath ( hmsApiFolder , fileNameWithExtension , '*' ) . fsPath ]
155+ }
156+ for ( const [ fileNameWithExtension , fileType ] of kitsFiles ) {
157+ if ( fileType !== FileType . File ) continue
158+ const fileName = this . getFileNameWithoutExtension ( fileNameWithExtension )
159+ paths [ fileName ] = [ Utils . joinPath ( hmsKitsFolder , fileNameWithExtension ) . fsPath ]
160+ paths [ `${ fileName } /*` ] = [ Utils . joinPath ( hmsKitsFolder , fileNameWithExtension , '*' ) . fsPath ]
161+ }
162+ return paths
154163 }
155- for ( const [ fileNameWithExtension , fileType ] of kitsFiles ) {
156- if ( fileType !== FileType . File ) continue
157- const fileName = this . getFileNameWithoutExtension ( fileNameWithExtension )
158- paths [ fileName ] = [ Utils . joinPath ( hmsKitsFolder , fileNameWithExtension ) . fsPath ]
159- paths [ ` ${ fileName } /*` ] = [ Utils . joinPath ( hmsKitsFolder , fileNameWithExtension , '*' ) . fsPath ]
164+ catch ( error ) {
165+ this . logger . getConsola ( ) . error ( `Failed to detect ets.hmsPath, please check the ets.hmsPath in the initialization options: ${ error } ` )
166+ if ( error instanceof Error ) this . logger . getConsola ( ) . error ( error . stack )
167+ this . connection . window . showErrorMessage ( `Failed to detect ets.hmsPath, please check the ets.hmsPath in the initialization options.` )
168+ return { }
160169 }
161- return paths
162170 }
163171
164172 async getPaths ( ) : Promise < ets . MapLike < string [ ] > > {
0 commit comments