import * as vs from "vscode" ; import { TsunamiCodeConfig } from "./TsunamiCodeConfig" ; export class ConfigDeserializer { getDefaultConfig ( vscodeOptions ) { return { importConfig : { namespaceAliases : new Map < string , any > ( ) , } , formatOptions : { indentSize : vscodeOptions . tabSize as number , trailingCommaInObjectLiterals : false , useDoubleQuotes : true , } , formatImportsOnSave : false , enableCompletionProvider : true , enableImportCodeAction : true , } ; } ; deserializeConfig ( rawConfig , vscodeOptions ) { const defaultConfig = this . getDefaultConfig ( vscodeOptions ) ; if ( ! rawConfig ) { return defaultConfig ; } const namespaceImports = rawConfig . get ( "namespaceImports" , { } ) ; const importConfig = { namespaceAliases : new Map < any , string > ( ) , } ; Object . keys ( namespaceImports ) . forEach ( k => importConfig . namespaceAliases . set ( k , namespaceImports [ k ] ) ) ; return { importConfig , formatOptions : { indentSize : defaultConfig . formatOptions . indentSize , trailingCommaInObjectLiterals : rawConfig . get ( "trailingCommaInObjectLiterals" , defaultConfig . formatOptions . trailingCommaInObjectLiterals ) , useDoubleQuotes : rawConfig . get ( "formatUseDoubleQuotes" , defaultConfig . formatOptions . useDoubleQuotes ) , } , formatImportsOnSave : rawConfig . get ( "formatImportsOnSave" , defaultConfig . formatImportsOnSave ) , enableCompletionProvider : rawConfig . get ( "enableCompletionProvider" , defaultConfig . enableCompletionProvider ) , enableImportCodeAction : rawConfig . get ( "enableImportCodeAction" , defaultConfig . enableImportCodeAction ) , } ; } }