CPP:Add preliminary local jump to def queries

This commit is contained in:
alexet
2020-01-13 18:36:55 +00:00
committed by Jason Reed
parent 29a5ea121a
commit 6a41028d3a
3 changed files with 43 additions and 1 deletions

View File

@@ -132,7 +132,7 @@ private predicate constructorCallTypeMention(ConstructorCall cc, TypeMention tm)
* - `"X"` for macro accesses
* - `"I"` for import / include directives
*/
Top definitionOf(Top e, string kind) {
cached Top definitionOf(Top e, string kind) {
(
// call -> function called
kind = "M" and

View File

@@ -0,0 +1,21 @@
/**
* @name Jump-to-definition links
* @description Generates use-definition pairs that provide the data
* for jump-to-definition in the code viewer.
* @kind definitions
* @id cpp/jump-to-definition
*/
import definitions
external string selectedSourceFile();
cached File getEncodedFile(string name) {
result.getAbsolutePath().replaceAll(":", "_") = name
}
from Top e, Top def, string kind
where def = definitionOf(e, kind) and e.getFile() = getEncodedFile(selectedSourceFile())
select e, def, kind

View File

@@ -0,0 +1,21 @@
/**
* @name Jump-to-definition links
* @description Generates use-definition pairs that provide the data
* for jump-to-definition in the code viewer.
* @kind definitions
* @id cpp/jump-to-definition
*/
import definitions
external string selectedSourceFile();
cached File getEncodedFile(string name) {
result.getAbsolutePath().replaceAll(":", "_") = name
}
from Top e, Top def, string kind
where def = definitionOf(e, kind) and def.getFile() = getEncodedFile(selectedSourceFile())
select e, def, kind