@@ -5,21 +5,22 @@ import {
55 IntrinsicsSet ,
66 PseudoParametersSet ,
77 ResourceAttributesSet ,
8+ SectionType ,
89 TopLevelSection ,
910 TopLevelSectionsSet ,
1011 TopLevelSectionsWithLogicalIdsSet ,
1112} from './ContextType' ;
1213import { IntrinsicContext } from './IntrinsicContext' ;
1314import { Entity } from './semantic/Entity' ;
14- import { nodeToEntity } from './semantic/EntityBuilder' ;
15+ import { entityTypeFromSection , nodeToEntity } from './semantic/EntityBuilder' ;
1516import { normalizeIntrinsicFunction } from './semantic/Intrinsics' ;
17+ import { EntityType } from './semantic/SemanticTypes' ;
1618import { PropertyPath } from './syntaxtree/SyntaxTree' ;
1719import { NodeType } from './syntaxtree/utils/NodeType' ;
1820import { YamlNodeTypes , CommonNodeTypes } from './syntaxtree/utils/TreeSitterTypes' ;
1921import { TransformContext } from './TransformContext' ;
2022
21- export type SectionType = TopLevelSection | 'Unknown' ;
22- export type QuoteCharacter = '"' | "'" ;
23+ type QuoteCharacter = '"' | "'" ;
2324
2425export class Context {
2526 public readonly section : SectionType ;
@@ -64,6 +65,10 @@ export class Context {
6465 return this . _entity ;
6566 }
6667
68+ public getEntityType ( ) : EntityType {
69+ return entityTypeFromSection ( this . section , this . logicalId ) ;
70+ }
71+
6772 public get intrinsicContext ( ) : IntrinsicContext {
6873 this . _intrinsicContext ??= new IntrinsicContext ( this . pathToRoot , this . documentType ) ;
6974 return this . _intrinsicContext ;
@@ -310,7 +315,7 @@ export class Context {
310315 return undefined ;
311316 }
312317
313- public record ( ) {
318+ public logRecord ( ) {
314319 return {
315320 section : this . section ,
316321 logicalId : this . logicalId ,
@@ -322,7 +327,7 @@ export class Context {
322327 node : { start : this . node . startPosition , end : this . node . endPosition } ,
323328 root : { start : this . entityRootNode ?. startPosition , end : this . entityRootNode ?. endPosition } ,
324329 entity : this . entity ,
325- intrinsicContext : this . intrinsicContext . record ( ) ,
330+ intrinsicContext : this . intrinsicContext . logRecord ( ) , // eslint-disable-line no-restricted-syntax
326331 isKey : this . isKey ( ) ,
327332 isValue : this . isValue ( ) ,
328333 } ;
0 commit comments