Skip to content
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

"Cannot view the AST" #944

Closed
kumom opened this issue Sep 6, 2021 · 8 comments · Fixed by #949
Closed

"Cannot view the AST" #944

kumom opened this issue Sep 6, 2021 · 8 comments · Fixed by #949
Labels
bug Something isn't working VSCode

Comments

@kumom
Copy link

kumom commented Sep 6, 2021

Describe the bug
I tried to see the AST generated by CodeQL in VS Code. I chose the torvalds/linux database downloaded from LGTM.com, but when the src.zip in the database or some *.c file unzipped from the src.zip is selected in the editor, the AST cannot be generated. The error message shows

Cannot view the AST. Please select a valid source file inside a CodeQL database. (codeQL.viewAst)

Version
CodeQL extension version: 1.5.4 CodeQL CLI version: 2.6.0 Platform: darwin x64

VS Code:
Version: 1.60.0
Commit: e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff
Date: 2021-09-01T10:54:53.442Z (4 days ago)
Electron: 13.1.8
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 20.6.0

To reproduce

  1. Select torvalds/linux database in the DATABASES panel
  2. Drag the src.zip in the database to the editor. Click View AST in the AST VIEWER panel.
  3. Unzip src.zip in the database. Open a random *.c file in the editor. Click View AST in the AST VIEWER panel.

Expected behavior
I actually don't know what to expect (i.e., whether it will produce a description of the graph or an image file) because the documentation does not give any examples. That's why I'd like to try it myself.

@kumom kumom added the bug Something isn't working label Sep 6, 2021
@github-actions github-actions bot added the VSCode label Sep 6, 2021
@edoardopirovano
Copy link
Contributor

Hello, thanks for reaching out with this! We are already aware of this issue and have a fix ready which will be in the 2.6.1 release of the CodeQL CLI.

@aeisenberg
Copy link
Contributor

Hi @kumom, on a deeper look into your issue, I think there is something else going on. @edoardopirovano is correct that we will be releasing a separate fix for the AST viewer in 2.6.1 of the CLI, but I suspect you are having a different problem.

The AST viewer will only work on source files inside of a database. There is no need to explicitly unzip the src.zip file and import the sources. That will not work since unzipped sources are not part of the database. Here is what you should be doing:

  1. Import the database into your workspace (it seems like you have already done this).
  2. Look for the source folder for that database that is automatically added to your workspace. It should look something like [torvolds_linux source archive].
  3. Open the folder and run the ast viewer command on that file.

See here for more information: https://codeql.github.com/docs/codeql-for-visual-studio-code/exploring-the-structure-of-your-source-code/

@kumom
Copy link
Author

kumom commented Sep 8, 2021

Hi @kumom, on a deeper look into your issue, I think there is something else going on. @edoardopirovano is correct that we will be releasing a separate fix for the AST viewer in 2.6.1 of the CLI, but I suspect you are having a different problem.

The AST viewer will only work on source files inside of a database. There is no need to explicitly unzip the src.zip file and import the sources. That will not work since unzipped sources are not part of the database. Here is what you should be doing:

  1. Import the database into your workspace (it seems like you have already done this).
  2. Look for the source folder for that database that is automatically added to your workspace. It should look something like [torvolds_linux source archive].
  3. Open the folder and run the ast viewer command on that file.

See here for more information: https://codeql.github.com/docs/codeql-for-visual-studio-code/exploring-the-structure-of-your-source-code/

You are right. After selecting the files from [torvalds_linux source archive], the error message shows

Resolving queries failed: [2021-09-08 17:24:55] [DETAILS] resolve queries> Expanding query suite /var/folders/6p/hdgtycg135317w0zp35lsl5w0000gn/T/tmp-45603-LBNdx0jCWxMP-.qls. [2021-09-08 17:24:55] [SPAMMY] resolve queries> Evaluating default query suite of

I guess this is expected then.

@aeisenberg
Copy link
Contributor

Yes, this is still a problem. We are releasing a fix shortly.

@aeisenberg aeisenberg reopened this Sep 8, 2021
@aeisenberg aeisenberg linked a pull request Sep 8, 2021 that will close this issue
3 tasks
@aeisenberg
Copy link
Contributor

v1.5.5 has been released and this bug is fixed. Please let me know if this works for you.

@kumom
Copy link
Author

kumom commented Sep 10, 2021

v1.5.5 has been released and this bug is fixed. Please let me know if this works for you.

Unfortunately, I could not find the folder [torvalds_linux source archive] in my workspace anymore. My workspace is simply VSCODE-CODEQL-STARTER downloaded here. After adding the database from the "DATABASES" panel and adding the folder to the workspace, I did not see [torvalds_linux source archive] folder appearing in the Explorer. Did I miss some step?

@aeisenberg
Copy link
Contributor

Could you try removing and re-adding the database? You should not need to add any folder to the workspace. The source archive is added automatically when you add the database.

@kumom
Copy link
Author

kumom commented Sep 11, 2021

Could you try removing and re-adding the database? You should not need to add any folder to the workspace. The source archive is added automatically when you add the database.

After removing and re-adding the database, I can see the source archive. The AST Viewer also works as expected now. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working VSCode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants