■ ■ ■ ■ ■ ■
new/language/implementation/javascript/javascript.go
| skipped 218 lines |
219 | 219 | | } |
220 | 220 | | |
221 | 221 | | func (implementation *javascriptImplementation) PatternIsAnchored(node *tree.Node) (bool, bool) { |
222 | | - | if node.Type() == "pair" { |
223 | | - | return false, false |
224 | | - | } |
225 | | - | |
226 | 222 | | parent := node.Parent() |
227 | 223 | | if parent == nil { |
228 | 224 | | return true, true |
| skipped 2 lines |
231 | 227 | | // Class body class_body |
232 | 228 | | // arrow functions statement_block |
233 | 229 | | // function statement_block |
234 | | - | // method statement_block |
235 | | - | unAnchored := []string{"statement_block", "class_body"} |
| 230 | + | // method statement_blocks |
| 231 | + | unAnchored := []string{"statement_blocks", "class_body", "pair"} |
236 | 232 | | |
237 | | - | isUnanchored := !slices.Contains(unAnchored, parent.Type()) |
| 233 | + | isUnanchored := !slices.Contains(unAnchored, node.Type()) |
238 | 234 | | return isUnanchored, isUnanchored |
239 | 235 | | } |
240 | 236 | | |
| skipped 2 lines |
243 | 239 | | } |
244 | 240 | | |
245 | 241 | | func (implementation *javascriptImplementation) PatternNodeTypes(node *tree.Node) []string { |
246 | | - | if node.Type() == "statement_block" && node.Parent().Type() == "program" { |
247 | | - | if node.NamedChildCount() == 0 { |
248 | | - | return []string{"object"} |
249 | | - | } else { |
250 | | - | return []string{node.Type(), "program"} |
251 | | - | } |
| 242 | + | if node.Type() == "statement_block" && node.Parent().Type() == "program" && node.NamedChildCount() == 0 { |
| 243 | + | return []string{"object"} |
252 | 244 | | } |
253 | 245 | | |
254 | 246 | | return []string{node.Type()} |
| skipped 6 lines |