@@ -10,7 +10,7 @@ export class Document {
1010 private readonly log = LoggerFactory . getLogger ( Document ) ;
1111 public readonly extension : string ;
1212 public readonly documentType : DocumentType ;
13- public cfnFileType : CloudFormationFileType ;
13+ private _cfnFileType : CloudFormationFileType ;
1414 public readonly fileName : string ;
1515 private tabSize : number ;
1616 private cachedParsedContent : unknown ;
@@ -29,29 +29,33 @@ export class Document {
2929 this . extension = extension ;
3030 this . documentType = type ;
3131 this . fileName = uriToPath ( uri ) . base ;
32- this . cfnFileType = CloudFormationFileType . Unknown ;
32+ this . _cfnFileType = CloudFormationFileType . Unknown ;
3333
3434 this . updateCfnFileType ( ) ;
3535 this . tabSize = fallbackTabSize ;
3636 this . processIndentation ( detectIndentation , fallbackTabSize ) ;
3737 }
3838
39+ public get cfnFileType ( ) : CloudFormationFileType {
40+ return this . _cfnFileType ;
41+ }
42+
3943 public updateCfnFileType ( ) : void {
4044 const content = this . textDocument . getText ( ) ;
4145 if ( ! content . trim ( ) ) {
42- this . cfnFileType = CloudFormationFileType . Unknown ;
46+ this . _cfnFileType = CloudFormationFileType . Unknown ;
4347 this . cachedParsedContent = undefined ;
4448 return ;
4549 }
4650
4751 try {
4852 this . cachedParsedContent = this . parseContent ( ) ;
49- this . cfnFileType = this . detectCfnFileType ( ) ;
53+ this . _cfnFileType = this . detectCfnFileType ( ) ;
5054 } catch {
5155 // If parsing fails, leave cfnFileType unchanged and clear cache
5256 this . cachedParsedContent = undefined ;
5357 this . log . debug (
54- `Failed to parse document ${ this . textDocument . uri } , keeping cfnFileType as ${ this . cfnFileType } ` ,
58+ `Failed to parse document ${ this . textDocument . uri } , keeping cfnFileType as ${ this . _cfnFileType } ` ,
5559 ) ;
5660 }
5761 }
0 commit comments