+ % Second statement
+ \draw[overlaybox] (2*\charwidth,\mintedtop+\lineheight) rectangle
+ +(16*\charwidth,\lineheight);
+
+ % Third statement
+ \draw[overlaybox] (2*\charwidth,\mintedtop+2*\lineheight) rectangle
+ +(16*\charwidth,\lineheight);
+
+ \draw[overlaybox] (\indent-3*\charwidth,\mintedtop) rectangle
+ +(18*\charwidth,2*\lineheight);
+
+ \draw[overlaybox] (3*\charwidth,\mintedtop+\lineheight) rectangle
+ +(14*\charwidth,2*\lineheight);
+
+ % All
+ \draw[overlaybox] (\indent,\mintedtop) rectangle
+ +(12*\charwidth,3*\lineheight);
+\end{tikzpicture}
+% indent should be 5 spaces
+\begin{minted}[linenos,firstnumber=16]{java}
+ b.a.foo();
+ b.a.bar();
+ break;
+\end{minted}
+\caption{Example of how the text selections generator would generate text
+ selections based on a lists of statements. Each highlighted rectangle
+represents a text selection.}
+\label{lst:textSelectionsExample}
+\end{listing}
+
+Each nesting level of a method body can have many such sequences of statements.
+The outermost nesting level has one such sequence, and each branch contains
+their own sequence of statements. \Myref{lst:grandExample} has a version of some
+code where all such sequences of statements are highlighted for a method body.
+
+To complete our example of possible text selections, I will now list all
+possible text selections for the method in \myref{lst:grandExample}, by nesting
+level. There are 23 of them in total.
+
+\begin{description}
+ \item[Level 1 (10 selections)] \hfill \\
+ $\{(5,9), (11), (12), (14,21), (5,11), (5,12), (5,21), (11,12),
+ (11,21), \\(12,21)\}$
+
+ \item[Level 2 (13 selections)] \hfill \\
+ $\{(6), (7), (8), (6,7), (6,8), (7,8), (16), (17), (18), (16,17), (16,18), \\
+ (17,18), (20)\}$
+\end{description}
+
+\subsubsection{The complexity}\label{sec:complexity}
+The complexity of how many text selections that needs to be analyzed for a body
+of in total $n$ statements, is bounded by $O(n^2)$. A body of statements is here
+all the statements in all nesting levels of a sequence of statements. A method
+body (or a block) is a body of statements. To prove that the complexity is
+bounded by $O(n^2)$, I present a couple of theorems and proves them.
+
+\begin{theorem}
+The number of text selections that need to be analyzed for each list of
+statements of length $n$, is exactly
+
+\begin{equation*}
+ \sum_{i=1}^{n} i = \frac{n(n+1)}{2}
+ \label{eq:complexityStatementList}
+\end{equation*}
+\label{thm:numberOfTextSelection}
+\end{theorem}
+
+\begin{proof}
+ For $n=1$ this is trivial: $\frac{1(1+1)}{2} = \frac{2}{2} = 1$. One statement
+ equals one selection.
+
+ For $n=2$, you get one text selection for the first statement, one selection
+ for the second statement, and one selection for the two of them combined.
+ This equals three selections. $\frac{2(2+1)}{2} = \frac{6}{2} = 3$.
+
+ For $n=3$, you get 3 selections for the two first statements, as in the case
+ where $n=2$. In addition you get one selection for the third statement itself,
+ and two more statements for the combinations of it with the two previous
+ statements. This equals six selections. $\frac{3(3+1)}{2} = \frac{12}{2} = 6$.
+
+ Assume that for $n=k$ there exists $\frac{k(k+1)}{2}$ text selections. Then we
+ want to add selections for another statement, following the previous $k$
+ statements. So, for $n=k+1$, we get one additional selection for the statement
+ itself. Then we get one selection for each pair of the new selection and the
+ previous $k$ statements. So the total number of selections will be the number
+ of already generated selections, plus $k$ for every pair, plus one for the
+ statement itself: $\frac{k(k+1)}{2} + k +
+ 1 = \frac{k(k+1)+2k+2}{2} = \frac{k(k+1)+2(k+1)}{2} = \frac{(k+1)(k+2)}{2} =
+ \frac{(k+1)((k+1)+1)}{2} = \sum_{i=1}^{k+1} i$
+\end{proof}
+
+%\definition{A \emph{body of statements} is a sequence of statements where every
+%statement may have sub-statements.}
+
+\begin{theorem}
+ The number of text selections for a body of statements is maximized if all the
+ statements are at the same level.
+ \label{thm:textSelectionsMaximized}
+\end{theorem}
+
+\begin{proof}
+ Assume we have a body of, in total, $k$ statements. Then, the sum of the
+ lengths of all the lists of statements in the body, is also $k$. Let
+ $\{l,\ldots,m,(k-l-\ldots-m)\}$ be the lengths of the lists of statements in
+ the body, with $l+\ldots+m<k \Rightarrow \forall i \in \{l,\ldots,m\} : i < k$.