Skip to content

Commit 6a41028

Browse files
alexetjcreedcmu
authored andcommitted
CPP:Add preliminary local jump to def queries
1 parent 29a5ea1 commit 6a41028

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

cpp/ql/src/definitions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ private predicate constructorCallTypeMention(ConstructorCall cc, TypeMention tm)
132132
* - `"X"` for macro accesses
133133
* - `"I"` for import / include directives
134134
*/
135-
Top definitionOf(Top e, string kind) {
135+
cached Top definitionOf(Top e, string kind) {
136136
(
137137
// call -> function called
138138
kind = "M" and

cpp/ql/src/localDefinitions.ql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @name Jump-to-definition links
3+
* @description Generates use-definition pairs that provide the data
4+
* for jump-to-definition in the code viewer.
5+
* @kind definitions
6+
* @id cpp/jump-to-definition
7+
*/
8+
9+
import definitions
10+
11+
external string selectedSourceFile();
12+
13+
cached File getEncodedFile(string name) {
14+
result.getAbsolutePath().replaceAll(":", "_") = name
15+
}
16+
17+
18+
19+
from Top e, Top def, string kind
20+
where def = definitionOf(e, kind) and e.getFile() = getEncodedFile(selectedSourceFile())
21+
select e, def, kind

cpp/ql/src/localReferences.ql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @name Jump-to-definition links
3+
* @description Generates use-definition pairs that provide the data
4+
* for jump-to-definition in the code viewer.
5+
* @kind definitions
6+
* @id cpp/jump-to-definition
7+
*/
8+
9+
import definitions
10+
11+
external string selectedSourceFile();
12+
13+
cached File getEncodedFile(string name) {
14+
result.getAbsolutePath().replaceAll(":", "_") = name
15+
}
16+
17+
18+
19+
from Top e, Top def, string kind
20+
where def = definitionOf(e, kind) and def.getFile() = getEncodedFile(selectedSourceFile())
21+
select e, def, kind

0 commit comments

Comments
 (0)