@@ -62,31 +62,34 @@ module ts {
6262 return node . end - node . pos ;
6363 }
6464
65- export function hasFlag ( val : number , flag : number ) : boolean {
65+ function hasFlag ( val : number , flag : number ) : boolean {
6666 return ( val & flag ) !== 0 ;
6767 }
6868
6969 // Returns true if this node contains a parse error anywhere underneath it.
7070 export function containsParseError ( node : Node ) : boolean {
71- if ( ! hasFlag ( node . parserContextFlags , ParserContextFlags . HasComputedThisNodeOrAnySubNodesHasError ) ) {
71+ aggregateChildData ( node ) ;
72+ return hasFlag ( node . parserContextFlags , ParserContextFlags . ThisNodeOrAnySubNodesHasError ) ;
73+ }
74+
75+ function aggregateChildData ( node : Node ) : void {
76+ if ( ! hasFlag ( node . parserContextFlags , ParserContextFlags . HasAggregatedChildData ) ) {
7277 // A node is considered to contain a parse error if:
7378 // a) the parser explicitly marked that it had an error
7479 // b) any of it's children reported that it had an error.
75- var val = hasFlag ( node . parserContextFlags , ParserContextFlags . ThisNodeHasError ) ||
80+ var thisNodeOrAnySubNodesHasError = hasFlag ( node . parserContextFlags , ParserContextFlags . ThisNodeHasError ) ||
7681 forEachChild ( node , containsParseError ) ;
7782
7883 // If so, mark ourselves accordingly.
79- if ( val ) {
84+ if ( thisNodeOrAnySubNodesHasError ) {
8085 node . parserContextFlags |= ParserContextFlags . ThisNodeOrAnySubNodesHasError ;
8186 }
8287
8388 // Also mark that we've propogated the child information to this node. This way we can
8489 // always consult the bit directly on this node without needing to check its children
8590 // again.
86- node . parserContextFlags |= ParserContextFlags . HasComputedThisNodeOrAnySubNodesHasError ;
91+ node . parserContextFlags |= ParserContextFlags . HasAggregatedChildData ;
8792 }
88-
89- return hasFlag ( node . parserContextFlags , ParserContextFlags . ThisNodeOrAnySubNodesHasError ) ;
9093 }
9194
9295 export function getSourceFileOfNode ( node : Node ) : SourceFile {
0 commit comments