Implementing an IndentationManager Class
Learn how to implement an indentation manager class.
We'll cover the following
We will continue to build on the numerous indentation helper methods in this section to create a new IndentationManager
class. This class will be capable of grouping lines together based on their relative indentation. To help clarify what we are going to build, let’s reuse the following text:
L01
L02
L03
L04
L05
With the class we are about to build together, we would be able to retrieve the following direct ancestors of line one because they are indented a level further than line one:
L02
L05
Additionally, we would be able to retrieve all lines two through five under line one since their indentation levels are all nested below it.
Before we start on our implementation, we will need to add a few new properties to our existing TextIndentation
class. These new properties will be used to store what lines are direct ancestors of any given line as well as all of the lines below any given line:
Get hands-on with 1400+ tech skills courses.