@@ -11,6 +11,12 @@ namespace Rubberduck.Parsing
11
11
/// </summary>
12
12
public static class SelectionExtensions
13
13
{
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>
14
20
public static bool Contains ( this Selection selection , IToken token )
15
21
{
16
22
return
@@ -20,6 +26,12 @@ public static bool Contains(this Selection selection, IToken token)
20
26
|| ( selection . EndLine > token . EndLine ( ) ) ) ;
21
27
}
22
28
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>
23
35
public static bool Contains ( this ParserRuleContext context , Selection selection )
24
36
{
25
37
return
@@ -30,12 +42,13 @@ public static bool Contains(this ParserRuleContext context, Selection selection)
30
42
}
31
43
32
44
/// <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.
35
48
/// Whitespace and newline should be preserved within the token.
36
49
/// </summary>
37
50
/// <param name="token">The last token within a given context to test</param>
38
- /// <returns></returns>
51
+ /// <returns>Zero-based column position </returns>
39
52
public static int EndColumn ( this IToken token )
40
53
{
41
54
if ( token . Text . Contains ( Environment . NewLine ) )
@@ -51,6 +64,13 @@ public static int EndColumn(this IToken token)
51
64
}
52
65
}
53
66
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>
54
74
public static int EndLine ( this IToken token )
55
75
{
56
76
if ( token . Text . Contains ( Environment . NewLine ) )
0 commit comments