3 ms·
Hi, thanks for giving ast-grep a try. Pattern code must be valid code that tree-sitter can parse.[0] You can use this syntax `try { $$$CODE } catch ($$$E) { $
by herrington_d 3y ago
Hi, thanks for giving ast-grep a try.
Pattern code must be valid code that tree-sitter can parse.[0]
You can use this syntax `try { $$$CODE } catch ($$$E) { $$$HANDLE }`[1]
[0] https://ast-grep.github.io/guide/pattern-syntax.html#pattern-matching https://ast-grep.github.io/guide/pattern-syntax.html#pattern...
[1] https://ast-grep.github.io/playground.html#eyJtb2RlIjoiUGF0Y2giLCJsYW5nIjoiY3BwIiwicXVlcnkiOiJ0cnkgeyAkJCRDT0RFIH0gY2F0Y2ggKCQkJEUpIHsgJCQkSEFORExFIH0iLCJyZXdyaXRlIjoidGVzdCIsImNvbmZpZyI6IiMgWUFNTCBSdWxlIGlzIG1vcmUgcG93ZXJmdWwhXG4jIGh0dHBzOi8vYXN0LWdyZXAuZ2l0aHViLmlvL2d1aWRlL3J1bGUtY29uZmlnLmh0bWwjcnVsZVxucnVsZTpcbiAgYW55OlxuICAgIC0gcGF0dGVybjogY29uc29sZS5sb2coJEEpXG4gICAgLSBwYXR0ZXJuOiBjb25zb2xlLmRlYnVnKCRBKVxuZml4OlxuICBsb2dnZXIubG9nKCRBKSIsInNvdXJjZSI6IiAgICB0cnlcbiAgICB7XG4gICAgICAgIGlmICh0aHJlYWRfZ3JvdXApXG4gICAgICAgICAgICBDdXJyZW50VGhyZWFkOjphdHRhY2hUb0dyb3VwKHRocmVhZF9ncm91cCk7XG5cbiAgICAgICAgZGF0YS5leGVjdXRvci0+ZXhlY3V0ZShudW1fdGhyZWFkcywgY29uY3VycmVuY3lfY29udHJvbCk7XG4gICAgfVxuICAgIGNhdGNoICguLi4pXG4gICAge1xuICAgICAgICBkYXRhLmV4Y2VwdGlvbiA9IHN0ZDo6Y3VycmVudF9leGNlcHRpb24oKTtcbiAgICAgICAgZGF0YS5oYXNfZXhjZXB0aW9uID0gdHJ1ZTtcbiAgICB9XG4ifQ== https://ast-grep.github.io/playground.html#eyJtb2RlIjoiUGF0Y...
- zX41ZdbW 3y agoThank you! You saved me :) Although it is non-obvious, which AST fragments are considered valid and which are not.