File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1271,6 +1271,17 @@ def translation_unit(self):
1271
1271
# created.
1272
1272
return self ._tu
1273
1273
1274
+ @property
1275
+ def referenced (self ):
1276
+ """
1277
+ For a cursor that is a reference, returns a cursor
1278
+ representing the entity that it references.
1279
+ """
1280
+ if not hasattr (self , '_referenced' ):
1281
+ self ._referenced = conf .lib .clang_getCursorReferenced (self )
1282
+
1283
+ return self ._referenced
1284
+
1274
1285
def get_arguments (self ):
1275
1286
"""Return an iterator for accessing the arguments of this cursor."""
1276
1287
num_args = conf .lib .clang_Cursor_getNumArguments (self )
Original file line number Diff line number Diff line change @@ -250,3 +250,12 @@ def test_get_arguments():
250
250
assert len (arguments ) == 2
251
251
assert arguments [0 ].spelling == "i"
252
252
assert arguments [1 ].spelling == "j"
253
+
254
+ def test_referenced ():
255
+ tu = get_tu ('void foo(); void bar() { foo(); }' )
256
+ foo = get_cursor (tu , 'foo' )
257
+ bar = get_cursor (tu , 'bar' )
258
+ for c in bar .get_children ():
259
+ if c .kind == CursorKind .CALL_EXPR :
260
+ assert c .referenced .spelling == foo .spelling
261
+ break
You can’t perform that action at this time.
0 commit comments