This repository was archived by the owner on Jan 5, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /**
2+ * Provides classes and predicates related to contextual queries
3+ * in the code viewer.
4+ */
5+
6+ import go
7+
8+ cached
9+ File getEncodedFile ( string name ) { result .getAbsolutePath ( ) .replaceAll ( ":" , "_" ) = name }
Original file line number Diff line number Diff line change 88 */
99
1010import go
11+ import ideContextual
1112
1213external string selectedSourceFile ( ) ;
1314
14- cached
15- File getEncodedFile ( string name ) { result .getAbsolutePath ( ) .replaceAll ( ":" , "_" ) = name }
16-
1715from Ident def , Ident use , Entity e
1816where use .uses ( e ) and def .declares ( e ) and use .getFile ( ) = getEncodedFile ( selectedSourceFile ( ) )
1917select use , def , "V"
Original file line number Diff line number Diff line change 88 */
99
1010import go
11+ import ideContextual
1112
1213external string selectedSourceFile ( ) ;
1314
14- cached
15- File getEncodedFile ( string name ) { result .getAbsolutePath ( ) .replaceAll ( ":" , "_" ) = name }
16-
1715from Ident def , Ident use , Entity e
1816where use .uses ( e ) and def .declares ( e ) and def .getFile ( ) = getEncodedFile ( selectedSourceFile ( ) )
1917select use , def , "V"
Original file line number Diff line number Diff line change 1+ /**
2+ * @name Print AST
3+ * @description Outputs a representation of a file's Abstract Syntax Tree. This
4+ * query is used by the VS Code extension.
5+ * @id go/print-ast
6+ * @kind graph
7+ * @tags ide-contextual-queries/print-ast
8+ */
9+
10+ import go
11+ import semmle.go.PrintAst
12+ import ideContextual
13+
14+ /**
15+ * The source file to generate an AST from.
16+ */
17+ external string selectedSourceFile ( ) ;
18+
19+ /**
20+ * Hook to customize the functions printed by this query.
21+ */
22+ class Cfg extends PrintAstConfiguration {
23+ override predicate shouldPrintFunction ( FuncDef func ) {
24+ func .getFile ( ) = getEncodedFile ( selectedSourceFile ( ) )
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments