Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Add codemod APIs from HackAST (FB project) #177

Open
3 tasks
fredemmott opened this issue May 30, 2019 · 0 comments
Open
3 tasks

Add codemod APIs from HackAST (FB project) #177

fredemmott opened this issue May 30, 2019 · 0 comments
Assignees

Comments

@fredemmott
Copy link
Contributor

fredemmott commented May 30, 2019

Key components:

  • HackAstQuery - this is basically just a refactoring; for example, $hhast_node->getDescendantsOfType(HHAST\Foo::class) is largely the same as $hackast_node->query()->selectByType(HackAstFoo::class)
  • HackCST* - this is a structured query language (but not actually SQL) for hh_server using hh_client --cst-search or hh_client --cst-search-files; this is depended on by HackASTQuery, and can also be used to reduce the number of files that a codemod needs to inspect
  • HackAstMatcher - this is another query approach, allowing sscanf()-style patterns. For example, $matcher = await HackAstMatcher::genFromStmt('list(%s) = await genva(%s);'); $nodes = $ast->query()->selectByMatcher($matcher)->nodes() This ultimately allows reimplementing something similar to spatch on top of the AST.

HackCST* and HackAstMatcher have standalone benefits for HHAST in usability in performance; HackAstQuery would make it easier to port FB-internal codemods.

@fredemmott fredemmott self-assigned this Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant