@@ -46,7 +46,6 @@ type Binder struct {
46
46
unreachableFlow * ast.FlowNode
47
47
reportedUnreachableFlow * ast.FlowNode
48
48
49
- parent * ast.Node
50
49
container * ast.Node
51
50
thisContainer * ast.Node
52
51
blockScopeContainer * ast.Node
@@ -211,9 +210,6 @@ func (b *Binder) declareSymbolEx(symbolTable ast.SymbolTable, parent *ast.Symbol
211
210
} else if ! (includes & ast .SymbolFlagsVariable != 0 && symbol .Flags & ast .SymbolFlagsAssignment != 0 ||
212
211
includes & ast .SymbolFlagsAssignment != 0 && symbol .Flags & ast .SymbolFlagsVariable != 0 ) {
213
212
// Assignment declarations are allowed to merge with variables, no matter what other flags they have.
214
- if node .Name () != nil {
215
- setParent (node .Name (), node )
216
- }
217
213
// Report errors every position with duplicate declaration
218
214
// Report errors on previous encountered declarations
219
215
var message * diagnostics.Message
@@ -584,9 +580,6 @@ func (b *Binder) bind(node *ast.Node) bool {
584
580
if node == nil {
585
581
return false
586
582
}
587
- if node .Parent == nil || node .Parent .Flags & ast .NodeFlagsReparsed != 0 {
588
- node .Parent = b .parent
589
- }
590
583
saveInStrictMode := b .inStrictMode
591
584
// Even though in the AST the jsdoc @typedef node belongs to the current node,
592
585
// its symbol might be in the same scope with the current node's symbol. Consider:
@@ -731,9 +724,7 @@ func (b *Binder) bind(node *ast.Node) bool {
731
724
// children, as an optimization we don't process those.
732
725
thisNodeOrAnySubnodesHasError := node .Flags & ast .NodeFlagsThisNodeHasError != 0
733
726
if node .Kind > ast .KindLastToken {
734
- saveParent := b .parent
735
727
saveSeenParseError := b .seenParseError
736
- b .parent = node
737
728
b .seenParseError = false
738
729
containerFlags := GetContainerFlags (node )
739
730
if containerFlags == ContainerFlagsNone {
@@ -744,15 +735,7 @@ func (b *Binder) bind(node *ast.Node) bool {
744
735
if b .seenParseError {
745
736
thisNodeOrAnySubnodesHasError = true
746
737
}
747
- b .parent = saveParent
748
738
b .seenParseError = saveSeenParseError
749
- } else {
750
- saveParent := b .parent
751
- if node .Kind == ast .KindEndOfFile {
752
- b .parent = node
753
- }
754
- b .setJSDocParents (node )
755
- b .parent = saveParent
756
739
}
757
740
if thisNodeOrAnySubnodesHasError {
758
741
node .Flags |= ast .NodeFlagsThisNodeOrAnySubNodesHasError
@@ -762,16 +745,6 @@ func (b *Binder) bind(node *ast.Node) bool {
762
745
return false
763
746
}
764
747
765
- func (b * Binder ) setJSDocParents (node * ast.Node ) {
766
- for _ , jsdoc := range node .JSDoc (b .file ) {
767
- setParent (jsdoc , node )
768
- if jsdoc .Kind != ast .KindJSDocImportTag {
769
- // JSDocImportTag children have parents set during parsing for module resolution purposes.
770
- ast .SetParentInChildren (jsdoc )
771
- }
772
- }
773
- }
774
-
775
748
func (b * Binder ) bindPropertyWorker (node * ast.Node ) {
776
749
isAutoAccessor := ast .IsAutoAccessorPropertyDeclaration (node )
777
750
includes := core .IfElse (isAutoAccessor , ast .SymbolFlagsAccessor , ast .SymbolFlagsProperty )
@@ -868,9 +841,6 @@ func (b *Binder) bindExportDeclaration(node *ast.Node) {
868
841
// All export * declarations are collected in an __export symbol
869
842
b .declareSymbol (ast .GetExports (b .container .Symbol ()), b .container .Symbol (), node , ast .SymbolFlagsExportStar , ast .SymbolFlagsNone )
870
843
} else if ast .IsNamespaceExport (decl .ExportClause ) {
871
- // declareSymbol walks up parents to find name text, parent _must_ be set
872
- // but won't be set by the normal binder walk until `bindChildren` later on.
873
- setParent (decl .ExportClause , node )
874
844
b .declareSymbol (ast .GetExports (b .container .Symbol ()), b .container .Symbol (), decl .ExportClause , ast .SymbolFlagsAlias , ast .SymbolFlagsAliasExcludes )
875
845
}
876
846
}
@@ -981,7 +951,6 @@ func (b *Binder) bindClassLikeDeclaration(node *ast.Node) {
981
951
prototypeSymbol := b .newSymbol (ast .SymbolFlagsProperty | ast .SymbolFlagsPrototype , "prototype" )
982
952
symbolExport := ast .GetExports (symbol )[prototypeSymbol .Name ]
983
953
if symbolExport != nil {
984
- setParent (name , node )
985
954
b .errorOnNode (symbolExport .Declarations [0 ], diagnostics .Duplicate_identifier_0 , ast .SymbolName (prototypeSymbol ))
986
955
}
987
956
ast .GetExports (symbol )[prototypeSymbol .Name ] = prototypeSymbol
@@ -1026,9 +995,6 @@ func (b *Binder) bindExpandoPropertyAssignment(node *ast.Node) {
1026
995
symbol = b .lookupEntity (parent , b .container )
1027
996
}
1028
997
if symbol = getInitializerSymbol (symbol ); symbol != nil {
1029
- // Fix up parent pointers since we're going to use these nodes before we bind into them
1030
- setParent (expr .Left , node )
1031
- setParent (expr .Right , node )
1032
998
if ast .HasDynamicName (node ) {
1033
999
b .bindAnonymousDeclaration (node , ast .SymbolFlagsProperty | ast .SymbolFlagsAssignment , ast .InternalSymbolNameComputed )
1034
1000
addLateBoundAssignmentDeclarationToSymbol (node , symbol )
@@ -1599,7 +1565,6 @@ func (b *Binder) bindChildren(node *ast.Node) {
1599
1565
// and set it before we descend into nodes that could actually be part of an assignment pattern.
1600
1566
b .inAssignmentPattern = false
1601
1567
if b .checkUnreachable (node ) {
1602
- b .setJSDocParents (node )
1603
1568
b .bindEachChild (node )
1604
1569
b .inAssignmentPattern = saveInAssignmentPattern
1605
1570
return
@@ -1611,7 +1576,6 @@ func (b *Binder) bindChildren(node *ast.Node) {
1611
1576
hasFlowNodeData .FlowNode = b .currentFlow
1612
1577
}
1613
1578
}
1614
- b .setJSDocParents (node )
1615
1579
switch node .Kind {
1616
1580
case ast .KindWhileStatement :
1617
1581
b .bindWhileStatement (node )
@@ -2800,12 +2764,6 @@ func (b *Binder) addDiagnostic(diagnostic *ast.Diagnostic) {
2800
2764
b .file .SetBindDiagnostics (append (b .file .BindDiagnostics (), diagnostic ))
2801
2765
}
2802
2766
2803
- func setParent (child * ast.Node , parent * ast.Node ) {
2804
- if child != nil {
2805
- child .Parent = parent
2806
- }
2807
- }
2808
-
2809
2767
func isSignedNumericLiteral (node * ast.Node ) bool {
2810
2768
if node .Kind == ast .KindPrefixUnaryExpression {
2811
2769
node := node .AsPrefixUnaryExpression ()
0 commit comments