@@ -62,31 +62,34 @@ module ts {
62
62
return node . end - node . pos ;
63
63
}
64
64
65
- export function hasFlag ( val : number , flag : number ) : boolean {
65
+ function hasFlag ( val : number , flag : number ) : boolean {
66
66
return ( val & flag ) !== 0 ;
67
67
}
68
68
69
69
// Returns true if this node contains a parse error anywhere underneath it.
70
70
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 ) ) {
72
77
// A node is considered to contain a parse error if:
73
78
// a) the parser explicitly marked that it had an error
74
79
// 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 ) ||
76
81
forEachChild ( node , containsParseError ) ;
77
82
78
83
// If so, mark ourselves accordingly.
79
- if ( val ) {
84
+ if ( thisNodeOrAnySubNodesHasError ) {
80
85
node . parserContextFlags |= ParserContextFlags . ThisNodeOrAnySubNodesHasError ;
81
86
}
82
87
83
88
// Also mark that we've propogated the child information to this node. This way we can
84
89
// always consult the bit directly on this node without needing to check its children
85
90
// again.
86
- node . parserContextFlags |= ParserContextFlags . HasComputedThisNodeOrAnySubNodesHasError ;
91
+ node . parserContextFlags |= ParserContextFlags . HasAggregatedChildData ;
87
92
}
88
-
89
- return hasFlag ( node . parserContextFlags , ParserContextFlags . ThisNodeOrAnySubNodesHasError ) ;
90
93
}
91
94
92
95
export function getSourceFileOfNode ( node : Node ) : SourceFile {
0 commit comments