(n *ast.Node, sourceFile *ast.SourceFile)
| 17 | } |
| 18 | |
| 19 | func IsCompletedNode(n *ast.Node, sourceFile *ast.SourceFile) bool { |
| 20 | if n == nil || ast.NodeIsMissing(n) { |
| 21 | return false |
| 22 | } |
| 23 | |
| 24 | switch n.Kind { |
| 25 | case ast.KindClassDeclaration, |
| 26 | ast.KindInterfaceDeclaration, |
| 27 | ast.KindEnumDeclaration, |
| 28 | ast.KindObjectLiteralExpression, |
| 29 | ast.KindObjectBindingPattern, |
| 30 | ast.KindTypeLiteral, |
| 31 | ast.KindBlock, |
| 32 | ast.KindModuleBlock, |
| 33 | ast.KindCaseBlock, |
| 34 | ast.KindNamedImports, |
| 35 | ast.KindNamedExports: |
| 36 | return nodeEndsWith(n, ast.KindCloseBraceToken, sourceFile) |
| 37 | |
| 38 | case ast.KindCatchClause: |
| 39 | return IsCompletedNode(n.AsCatchClause().Block, sourceFile) |
| 40 | |
| 41 | case ast.KindNewExpression: |
| 42 | if n.ArgumentList() == nil { |
| 43 | return true |
| 44 | } |
| 45 | fallthrough |
| 46 | |
| 47 | case ast.KindCallExpression, |
| 48 | ast.KindParenthesizedExpression, |
| 49 | ast.KindParenthesizedType: |
| 50 | return nodeEndsWith(n, ast.KindCloseParenToken, sourceFile) |
| 51 | |
| 52 | case ast.KindFunctionType, |
| 53 | ast.KindConstructorType: |
| 54 | return IsCompletedNode(n.Type(), sourceFile) |
| 55 | |
| 56 | case ast.KindConstructor, |
| 57 | ast.KindGetAccessor, |
| 58 | ast.KindSetAccessor, |
| 59 | ast.KindFunctionDeclaration, |
| 60 | ast.KindFunctionExpression, |
| 61 | ast.KindMethodDeclaration, |
| 62 | ast.KindMethodSignature, |
| 63 | ast.KindConstructSignature, |
| 64 | ast.KindCallSignature, |
| 65 | ast.KindArrowFunction: |
| 66 | if n.Body() != nil { |
| 67 | return IsCompletedNode(n.Body(), sourceFile) |
| 68 | } |
| 69 | if n.Type() != nil { |
| 70 | return IsCompletedNode(n.Type(), sourceFile) |
| 71 | } |
| 72 | // Even though type parameters can be unclosed, we can get away with |
| 73 | // having at least a closing paren. |
| 74 | return hasChildOfKind(n, ast.KindCloseParenToken, sourceFile) |
| 75 | |
| 76 | case ast.KindModuleDeclaration: |
no test coverage detected