(tp *typeparser.TypeParser, c *checker.Checker, sf *ast.SourceFile)
| 34 | } |
| 35 | |
| 36 | func AnalyzeExtendsNativeError(tp *typeparser.TypeParser, c *checker.Checker, sf *ast.SourceFile) []ExtendsNativeErrorMatch { |
| 37 | errorSymbol := c.ResolveName("Error", nil, ast.SymbolFlagsType, false) |
| 38 | if errorSymbol == nil { |
| 39 | return nil |
| 40 | } |
| 41 | |
| 42 | var matches []ExtendsNativeErrorMatch |
| 43 | |
| 44 | nodeToVisit := make([]*ast.Node, 0) |
| 45 | pushChild := func(child *ast.Node) bool { |
| 46 | nodeToVisit = append(nodeToVisit, child) |
| 47 | return false |
| 48 | } |
| 49 | sf.AsNode().ForEachChild(pushChild) |
| 50 | |
| 51 | for len(nodeToVisit) > 0 { |
| 52 | node := nodeToVisit[len(nodeToVisit)-1] |
| 53 | nodeToVisit = nodeToVisit[:len(nodeToVisit)-1] |
| 54 | |
| 55 | if node.Kind == ast.KindClassDeclaration { |
| 56 | if m := checkExtendsNativeError(tp, c, sf, node, errorSymbol); m != nil { |
| 57 | matches = append(matches, *m) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | node.ForEachChild(pushChild) |
| 62 | } |
| 63 | |
| 64 | return matches |
| 65 | } |
| 66 | |
| 67 | func checkExtendsNativeError(tp *typeparser.TypeParser, c *checker.Checker, sf *ast.SourceFile, node *ast.Node, errorSymbol *ast.Symbol) *ExtendsNativeErrorMatch { |
| 68 | extendsElements := ast.GetExtendsHeritageClauseElements(node) |
no test coverage detected