@@ -259,9 +259,12 @@ def query(self, cmd, *args):
259
259
260
260
# DT bindings compatible strings are handled differently
261
261
if family == 'B' :
262
- return self .get_idents_comps (version , ident )
262
+ defs , refs , docs = self .get_idents_comps (version , ident )
263
263
else :
264
- return self .get_idents_defs (version , ident , family )
264
+ defs , refs , docs = self .get_idents_defs (version , ident , family )
265
+
266
+ peeks = self .get_peeks_of_syms (version , defs , refs )
267
+ return defs , refs , docs , peeks
265
268
266
269
else :
267
270
return 'Unknown subcommand: ' + cmd + '\n '
@@ -402,10 +405,37 @@ def get_idents_defs(self, version, ident, family):
402
405
symbol_doccomments .append (SymbolInstance (path , docline ))
403
406
404
407
return symbol_definitions , symbol_references , symbol_doccomments
408
+
409
+ def get_peeks_of_syms (self , version , symbol_definitions , symbol_references ):
410
+
411
+ peeks = {}
412
+
413
+ def request_peeks (syms ):
414
+ if len (syms ) > 100 :
415
+ return
416
+ for sym in syms :
417
+ if sym .path not in peeks :
418
+ peeks [sym .path ] = {}
419
+
420
+ content = self .scriptLines ('get-file' , version , "/" + sym .path )
421
+
422
+ if type (sym .line ) is int :
423
+ lines = (sym .line ,)
424
+ else :
425
+ lines = map (int , sym .line .split (',' ))
426
+
427
+ for num in lines :
428
+ index = num - 1
429
+ if index >= 0 and index < len (content ):
430
+ peeks [sym .path ][num ] = decode (content [index ]).strip ()
431
+
432
+ request_peeks (symbol_definitions )
433
+ request_peeks (symbol_references )
434
+ return peeks
405
435
406
436
407
437
def cmd_ident (q , version , ident , family , ** kwargs ):
408
- symbol_definitions , symbol_references , symbol_doccomments = q .query ("ident" , version , ident , family )
438
+ symbol_definitions , symbol_references , symbol_doccomments , peeks = q .query ("ident" , version , ident , family )
409
439
print ("Symbol Definitions:" )
410
440
for symbol_definition in symbol_definitions :
411
441
print (symbol_definition )
@@ -418,6 +448,11 @@ def cmd_ident(q, version, ident, family, **kwargs):
418
448
for symbol_doccomment in symbol_doccomments :
419
449
print (symbol_doccomment )
420
450
451
+ print ("\n Symbol peeks:" )
452
+ for file , content in peeks .items ():
453
+ for num , line in content .items ():
454
+ print (f"{ file } :{ num } : { line } " )
455
+
421
456
def cmd_file (q , version , path , ** kwargs ):
422
457
code = q .query ("file" , version , path )
423
458
print (code )
0 commit comments