MCPcopy Index your code
hub / github.com/fkling/astexplorer

github.com/fkling/astexplorer @v2.1.0 sqlite

repository ↗ · DeepWiki ↗ · release v2.1.0 ↗
457 symbols 799 edges 123 files 4 documented · 1%
README

AST explorer

Join the chat at https://gitter.im/astexplorer/Lobby

Paste or drop code into the editor and inspect the generated AST.

The AST explorer provides following code parsers:

Depending on the parser settings, it not only supports ES5/CSS3 but also

Since future syntax is supported, the JavaScript AST explorer is a useful tool for developers who want to create AST transforms.

In fact, following transformers are included so you can prototype your own plugins:

Features

  • Save and fork code snippets. Copy the URL to share them.
  • Copying an AST or dropping a file containing an AST into the window will parse the AST and update the code using escodegen.
  • Otherwise, the content of texteditor will be replaced with the content of the file (i.e. you can drag and drop JS files).
  • Choose between multiple parsers and configure them.
  • Toggle Transform mode with jscodeshift and babel.
  • shift+click on a node expands the full subtree.
  • Hovering over a node highlights the corresponding text in the source code: source highlight
  • Editing the source or moving the cursor around will automatically highlight the corresponding AST node (or its ancestors of it isn't expanded): source highlight
  • You can use $node in the console to refer to the last opened/toggled AST node.

Contributions

I'm happy about any feedback, feature request or PR to make this tool as useful as possible!

How to add a new parser

  1. Install the new parser as dependency: yarn add theParser (or npm install -S theParser)
  2. Copy one of the existing examples in src/parsers/{language}.
  3. Adjust the code as necessary:
  4. Update metadata.
  5. Load the right parser (loadParser).
  6. Call the right parsing method with the right/necessary options in parse.
  7. Implement the nodeToRange method (this is for highlighting).
  8. Implement the getNodeName method (this is for quick look through the tree).
  9. Implement opensByDefault method for auto-expansion of specific properties.
  10. Define _ignoredProperties set or implement forEachProperty generator method for filtering.
  11. Provide a renderSettings method if applicable.

How to add a new transformer

  1. Install the new transformer as dependency.
  2. Copy one of the existing examples in src/parsers/{language}/transformers.
  3. Adjust the code as necessary:
  4. Update metadata and defaultParserID.
  5. Load the right transformer (loadTransformer).
  6. Call the transformation method in transform.
  7. Change sample transformation code in codeExample.txt.

Build your own version for development

  1. Clone the repository.
  2. Run git submodule update --init to initialize / update all submodules.
  3. Install all dependencies with yarn install (you can run npm install as well).

Run yarn run build for the final minimized version.
Run yarn run watch for incremental builds.

Run yarn start to start a simple static webserver.

Core symbols most depended-on inside this repo

require
called by 79
website/src/parsers/css/transformers/postcss/index.js
logEvent
called by 8
website/src/utils/logger.js
compileModule
called by 8
website/src/parsers/utils/compileModule.js
getParserByID
called by 6
website/src/parsers/index.js
_bindListener
called by 5
website/src/components/PasteDropTarget.js
getTransformerByID
called by 5
website/src/parsers/index.js
api
called by 5
website/src/storage/api.js
create
called by 4
website/src/storage/index.js

Shape

Function 345
Method 72
Class 40

Languages

TypeScript100%

Modules by API surface

website/src/store/actions.js25 symbols
website/src/storage/parse.js20 symbols
website/src/storage/gist.js19 symbols
website/src/store/selectors.js17 symbols
website/src/store/reducers.js17 symbols
website/src/components/visualization/tree/Element.js17 symbols
website/src/components/Editor.js16 symbols
website/src/storage/index.js12 symbols
website/src/parsers/html/htmlparser2.js12 symbols
website/src/components/ASTOutput.js12 symbols
website/src/parsers/js/traceur.js10 symbols
website/src/components/visualization/tree/RecursiveTreeElement.js10 symbols

Dependencies from manifests, versioned

@glimmer/compiler0.21.2 · 1×
@glimmer/syntax0.21.2 · 1×
acorn4.0.4 · 1×
acorn-jsx3.0.1 · 1×
acorn-to-esprima1.0.2 · 1×
autoprefixer-loader3.1.0 · 1×
babel-core6.16.0 · 1×
babel-eslint6.1.2 · 1×
babel-loader6.2.4 · 1×
babel-plugin-transform-flow-strip-types6.14.0 · 1×
babel-plugin-transform-runtime6.12.0 · 1×
babel-preset-es20156.16.0 · 1×

For agents

$ claude mcp add astexplorer \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact