US 11,853,732 B1
Source code structural inference based on indentation
Johan Sebastian Heesemann Rosenkilde, Birkerød (DK); and Albert Ziegler, Uppsala (SE)
Assigned to Microsoft Technology Licensing, LLC, Redmond, WA (US)
Filed by Microsoft Technology Licensing, LLC, Redmond, WA (US)
Filed on Jun. 21, 2022, as Appl. No. 17/845,739.
Int. Cl. G06F 8/41 (2018.01); G06F 8/33 (2018.01)
CPC G06F 8/427 (2013.01) [G06F 8/33 (2013.01); G06F 8/433 (2013.01)] 20 Claims
OG exemplary drawing
 
1. A method, implemented at a computer system that includes a processor, for inferring source code structure based on indentation, the method comprising:
identifying a portion of source code comprising a plurality of lines;
determining a corresponding indentation level for each line in the plurality of lines;
generating a plurality of nodes that each represents a different line in the plurality of lines;
arranging the plurality of nodes into an ordered tree based at least on the corresponding indentation level for each line in the plurality of lines;
based on an identified line in the plurality of lines:
identifying, from the ordered tree, a subtree that comprises a node representing the identified line;
identifying a subset of the plurality of nodes that correspond to the subtree; and
identifying a subset of the plurality of lines that are represented by the subset of the plurality of nodes as being syntactically-related to the identified line; and
initiating a source code action based on the subset of the plurality of lines.