@@ -596,60 +596,6 @@ namespace ts {
596596 return node . kind === SyntaxKind . EnumDeclaration && isConst ( node ) ;
597597 }
598598
599- function walkUpBindingElementsAndPatterns ( node : Node ) : Node {
600- while ( node && ( node . kind === SyntaxKind . BindingElement || isBindingPattern ( node ) ) ) {
601- node = node . parent ;
602- }
603-
604- return node ;
605- }
606-
607- export function getCombinedModifierFlags ( node : Node ) : ModifierFlags {
608- node = walkUpBindingElementsAndPatterns ( node ) ;
609- let flags = getModifierFlags ( node ) ;
610- if ( node . kind === SyntaxKind . VariableDeclaration ) {
611- node = node . parent ;
612- }
613-
614- if ( node && node . kind === SyntaxKind . VariableDeclarationList ) {
615- flags |= getModifierFlags ( node ) ;
616- node = node . parent ;
617- }
618-
619- if ( node && node . kind === SyntaxKind . VariableStatement ) {
620- flags |= getModifierFlags ( node ) ;
621- }
622-
623- return flags ;
624- }
625-
626- // Returns the node flags for this node and all relevant parent nodes. This is done so that
627- // nodes like variable declarations and binding elements can returned a view of their flags
628- // that includes the modifiers from their container. i.e. flags like export/declare aren't
629- // stored on the variable declaration directly, but on the containing variable statement
630- // (if it has one). Similarly, flags for let/const are store on the variable declaration
631- // list. By calling this function, all those flags are combined so that the client can treat
632- // the node as if it actually had those flags.
633- export function getCombinedNodeFlags ( node : Node ) : NodeFlags {
634- node = walkUpBindingElementsAndPatterns ( node ) ;
635-
636- let flags = node . flags ;
637- if ( node . kind === SyntaxKind . VariableDeclaration ) {
638- node = node . parent ;
639- }
640-
641- if ( node && node . kind === SyntaxKind . VariableDeclarationList ) {
642- flags |= node . flags ;
643- node = node . parent ;
644- }
645-
646- if ( node && node . kind === SyntaxKind . VariableStatement ) {
647- flags |= node . flags ;
648- }
649-
650- return flags ;
651- }
652-
653599 export function isConst ( node : Node ) : boolean {
654600 return ! ! ( getCombinedNodeFlags ( node ) & NodeFlags . Const )
655601 || ! ! ( getCombinedModifierFlags ( node ) & ModifierFlags . Const ) ;
@@ -4370,4 +4316,58 @@ namespace ts {
43704316 export function isParameterPropertyDeclaration ( node : ParameterDeclaration ) : boolean {
43714317 return hasModifier ( node , ModifierFlags . ParameterPropertyModifier ) && node . parent . kind === SyntaxKind . Constructor && isClassLike ( node . parent . parent ) ;
43724318 }
4319+
4320+ function walkUpBindingElementsAndPatterns ( node : Node ) : Node {
4321+ while ( node && ( node . kind === SyntaxKind . BindingElement || isBindingPattern ( node ) ) ) {
4322+ node = node . parent ;
4323+ }
4324+
4325+ return node ;
4326+ }
4327+
4328+ export function getCombinedModifierFlags ( node : Node ) : ModifierFlags {
4329+ node = walkUpBindingElementsAndPatterns ( node ) ;
4330+ let flags = getModifierFlags ( node ) ;
4331+ if ( node . kind === SyntaxKind . VariableDeclaration ) {
4332+ node = node . parent ;
4333+ }
4334+
4335+ if ( node && node . kind === SyntaxKind . VariableDeclarationList ) {
4336+ flags |= getModifierFlags ( node ) ;
4337+ node = node . parent ;
4338+ }
4339+
4340+ if ( node && node . kind === SyntaxKind . VariableStatement ) {
4341+ flags |= getModifierFlags ( node ) ;
4342+ }
4343+
4344+ return flags ;
4345+ }
4346+
4347+ // Returns the node flags for this node and all relevant parent nodes. This is done so that
4348+ // nodes like variable declarations and binding elements can returned a view of their flags
4349+ // that includes the modifiers from their container. i.e. flags like export/declare aren't
4350+ // stored on the variable declaration directly, but on the containing variable statement
4351+ // (if it has one). Similarly, flags for let/const are store on the variable declaration
4352+ // list. By calling this function, all those flags are combined so that the client can treat
4353+ // the node as if it actually had those flags.
4354+ export function getCombinedNodeFlags ( node : Node ) : NodeFlags {
4355+ node = walkUpBindingElementsAndPatterns ( node ) ;
4356+
4357+ let flags = node . flags ;
4358+ if ( node . kind === SyntaxKind . VariableDeclaration ) {
4359+ node = node . parent ;
4360+ }
4361+
4362+ if ( node && node . kind === SyntaxKind . VariableDeclarationList ) {
4363+ flags |= node . flags ;
4364+ node = node . parent ;
4365+ }
4366+
4367+ if ( node && node . kind === SyntaxKind . VariableStatement ) {
4368+ flags |= node . flags ;
4369+ }
4370+
4371+ return flags ;
4372+ }
43734373}
0 commit comments