Skip to content

Usage of print ast ql file #478

Answered by hvitved
Naman-ntc asked this question in Q&A
Nov 15, 2021 · 2 comments · 6 replies
Discussion options

You must be logged in to vote

This query is specifically written to be executed in the context of VS Code (because of the external string selectedSourceFile predicate). If you want to run it externally, you can make your own query:

import javascript
import semmle.javascript.PrintAst
import definitions

will print out the AST for all files, but you could also restrict it

import javascript
import semmle.javascript.PrintAst
import definitions

private File relevantSourceFile() { ... }

class PrintAstConfigurationOverride extends PrintAstConfiguration {
  override predicate shouldPrint(Locatable e, Location l) {
    super.shouldPrint(e, l) and
    l.getFile() = relevantSourceFile()
  }
}

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@hvitved
Comment options

@Naman-ntc
Comment options

@hvitved
Comment options

@Naman-ntc
Comment options

@hvitved
Comment options

Answer selected by Naman-ntc
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants