Skip to content

Commit ec92d8a

Browse files
committed
Add xmldocs to clearly document the expectations of the extension methods and what they will return, especially on the zero/one-based issue to avoid one-off errors.
1 parent 68ac493 commit ec92d8a

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

Rubberduck.Parsing/SelectionExtensions.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ namespace Rubberduck.Parsing
1111
/// </summary>
1212
public static class SelectionExtensions
1313
{
14+
/// <summary>
15+
/// Validates whether a token is contained within a given Selection
16+
/// </summary>
17+
/// <param name="selection">One-based selection, usually from CodePane.Selection</param>
18+
/// <param name="token">An individual token within a module's parse tree</param>
19+
/// <returns>Boolean with true indicating that token is within the selection</returns>
1420
public static bool Contains(this Selection selection, IToken token)
1521
{
1622
return
@@ -20,6 +26,12 @@ public static bool Contains(this Selection selection, IToken token)
2026
|| (selection.EndLine > token.EndLine()));
2127
}
2228

29+
/// <summary>
30+
/// Validates whether a context is contained within a given Selection
31+
/// </summary>
32+
/// <param name="context">A context which contains several tokens within a module's parse tree</param>
33+
/// <param name="selection">One-based selection, usually from CodePane.Selection</param>
34+
/// <returns>Boolean with true indicating that context is within the selection</returns>
2335
public static bool Contains(this ParserRuleContext context, Selection selection)
2436
{
2537
return
@@ -30,12 +42,13 @@ public static bool Contains(this ParserRuleContext context, Selection selection)
3042
}
3143

3244
/// <summary>
33-
/// Because a token can be spread across multiple lines with line continuations
34-
/// it is necessary to do some work to determine the token's actual ending column.
45+
/// Obtain the actual last column the token occupies. Because a token can be spread
46+
/// across multiple lines with line continuations it is necessary to do some work
47+
/// to determine the token's actual ending column.
3548
/// Whitespace and newline should be preserved within the token.
3649
/// </summary>
3750
/// <param name="token">The last token within a given context to test</param>
38-
/// <returns></returns>
51+
/// <returns>Zero-based column position</returns>
3952
public static int EndColumn(this IToken token)
4053
{
4154
if (token.Text.Contains(Environment.NewLine))
@@ -51,6 +64,13 @@ public static int EndColumn(this IToken token)
5164
}
5265
}
5366

67+
/// <summary>
68+
/// Obtain the actual last line token occupies. Typically it is same as token.Line but
69+
/// when it contains line continuation and is spread across lines, extra newlines are
70+
/// counted and added.
71+
/// </summary>
72+
/// <param name="token"></param>
73+
/// <returns>One-based line position</returns>
5474
public static int EndLine(this IToken token)
5575
{
5676
if(token.Text.Contains(Environment.NewLine))

0 commit comments

Comments
 (0)