-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathprintAst.ql
More file actions
30 lines (25 loc) · 783 Bytes
/
printAst.ql
File metadata and controls
30 lines (25 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* @name Print AST
* @description Outputs a representation of a file's Abstract Syntax Tree. This
* query is used by the VS Code extension.
* @id go/print-ast
* @kind graph
* @tags ide-contextual-queries/print-ast
*/
import go
import semmle.go.PrintAst
import ideContextual
/**
* Gets the source file to generate an AST from.
*/
external string selectedSourceFile();
/**
* A hook to customize the functions printed by this query.
*/
class Cfg extends PrintAstConfiguration {
override predicate shouldPrintFunction(FuncDecl func) { this.shouldPrintFile(func.getFile()) }
override predicate shouldPrintFile(File file) {
file = getFileBySourceArchiveName(selectedSourceFile())
}
override predicate shouldPrintComments(File file) { none() }
}