@@ -259,9 +259,12 @@ def query(self, cmd, *args):
259259
260260 # DT bindings compatible strings are handled differently
261261 if family == 'B' :
262- return self .get_idents_comps (version , ident )
262+ defs , refs , docs = self .get_idents_comps (version , ident )
263263 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
265268
266269 else :
267270 return 'Unknown subcommand: ' + cmd + '\n '
@@ -402,10 +405,37 @@ def get_idents_defs(self, version, ident, family):
402405 symbol_doccomments .append (SymbolInstance (path , docline ))
403406
404407 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
405435
406436
407437def 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 )
409439 print ("Symbol Definitions:" )
410440 for symbol_definition in symbol_definitions :
411441 print (symbol_definition )
@@ -418,6 +448,11 @@ def cmd_ident(q, version, ident, family, **kwargs):
418448 for symbol_doccomment in symbol_doccomments :
419449 print (symbol_doccomment )
420450
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+
421456def cmd_file (q , version , path , ** kwargs ):
422457 code = q .query ("file" , version , path )
423458 print (code )
0 commit comments