findAncestorByKind | R Documentation |
These functions traverse up the AST to find the nearest ancestor cursor with a given cursor kind. This allows us to find the enclosing routine/function, C++ namespace, C++ class, if statement, etc.
findAncestorByKind(cur, kind)
cur |
the |
kind |
the cursor kind identifying which type of cursor for which we are looking. |
The first matching ancestor CXCursor
.
NULL
if no ancestor cursor corresponds to the target kind.
Duncan Temple Lang
createTU
f = system.file("exampleCode/namespace.cpp", package = "RCIndex")
tu = createTU(f)
k = getCppClasses(tu)
m = k$Foo@methods$doit
ns = findEnclosingNamespace(m)
findEnclosingClass(m)
findAncestorByKind(m, CXCursor_ClassDecl)
c = findAssignTo(tu, "ctr")[[2]]
findEnclosingClass(c)
findEnclosingFunction(c)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.