-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to the CLI to extract AST as JSON #554
Comments
The output format is a custom textual format, e.g.:
|
@iabuhilal an alternative to get the AST in JSON format is to use the web service (run rust-code-analysis-web, send a request to the "ast" endpoint) |
Thank you |
hi @marco-c I tried to use rust-code-analysis-web. then ran
I also ran
I used postman but I get nothing. am I missing something? also is there documentation on how to use the REST API other than |
This is a mistake in the docs. We moved the server to rust-code-analysis-web, as you noticed. I've filed #571 to update the docs. |
There is an example usage from Python in https://github.com/mozilla/bugbug/blob/master/bugbug/rust_code_analysis_server.py. |
@iabuhilal example usage: import requests
r = requests.post(URL_TO_RUST_CODE_ANALYSIS_SERVER, json={
"id": "whatever",
"file_name": YOUR_FILE_NAME,
"code": YOUR_FILE_CONTENT,
"comment": False,
"span": True,
})
print(r.json()) |
@marco-c thank you, I can get the AST as JSON now. one last note, comment = false returns comments, i think it should return if comment = true
|
Can we close this one? |
@Luni-4 we still don't have a CLI command to get it, or do we? |
in the documentation, there is the following
"Print AST
If you want to print the AST of a source code, run the following command:
rust-code-analysis-cli -p /path/to/your/file/or/directory -d
The -d option prints the entire AST on the shell."
not sure what is the output format to parse it.
is there is a way to export the AST as a JSON file using rust-code-analysis-cli ?
The text was updated successfully, but these errors were encountered: