@@ -21,6 +21,12 @@ public static BitmapImage BitmapImage(this Declaration declaration)
21
21
return Cache [ declaration ] ;
22
22
}
23
23
24
+ /// <summary>
25
+ /// Returns the Selection of a VariableStmtContext.
26
+ /// </summary>
27
+ /// <exception cref="ArgumentException">Throws when target's DeclarationType is not Variable.</exception>
28
+ /// <param name="target"></param>
29
+ /// <returns></returns>
24
30
public static Selection GetVariableStmtContextSelection ( this Declaration target )
25
31
{
26
32
if ( target . DeclarationType != DeclarationType . Variable )
@@ -34,6 +40,12 @@ public static Selection GetVariableStmtContextSelection(this Declaration target)
34
40
statement . Stop . Line , statement . Stop . Column ) ;
35
41
}
36
42
43
+ /// <summary>
44
+ /// Returns a VariableStmtContext.
45
+ /// </summary>
46
+ /// <exception cref="ArgumentException">Throws when target's DeclarationType is not Variable.</exception>
47
+ /// <param name="target"></param>
48
+ /// <returns></returns>
37
49
public static VBAParser . VariableStmtContext GetVariableStmtContext ( this Declaration target )
38
50
{
39
51
if ( target . DeclarationType != DeclarationType . Variable )
@@ -50,6 +62,12 @@ public static VBAParser.VariableStmtContext GetVariableStmtContext(this Declarat
50
62
return statement ;
51
63
}
52
64
65
+ /// <summary>
66
+ /// Returns whether a variable declaration statement contains multiple declarations in a single statement.
67
+ /// </summary>
68
+ /// <exception cref="ArgumentException">Throws when target's DeclarationType is not Variable.</exception>
69
+ /// <param name="target"></param>
70
+ /// <returns></returns>
53
71
public static bool HasMultipleDeclarationsInStatement ( this Declaration target )
54
72
{
55
73
if ( target . DeclarationType != DeclarationType . Variable )
@@ -312,7 +330,15 @@ public static Declaration FindInterfaceMember(this IEnumerable<Declaration> decl
312
330
: matches . First ( ) ;
313
331
}
314
332
315
- public static Declaration FindSelection ( this IEnumerable < Declaration > declarations , QualifiedSelection selection , DeclarationType [ ] validDeclarationTypes )
333
+ /// <summary>
334
+ /// Returns the declaration contained in a qualified selection.
335
+ /// To get the selection of a variable or field, use FindVariable(QualifiedSelection)
336
+ /// </summary>
337
+ /// <param name="declarations"></param>
338
+ /// <param name="selection"></param>
339
+ /// <param name="validDeclarationTypes"></param>
340
+ /// <returns></returns>
341
+ public static Declaration FindTarget ( this IEnumerable < Declaration > declarations , QualifiedSelection selection , DeclarationType [ ] validDeclarationTypes )
316
342
{
317
343
var items = declarations . ToList ( ) ;
318
344
@@ -375,6 +401,12 @@ public static Declaration FindSelection(this IEnumerable<Declaration> declaratio
375
401
return target ;
376
402
}
377
403
404
+ /// <summary>
405
+ /// Returns the variable which contains the passed-in QualifiedSelection. Returns null if the selection is not on a variable.
406
+ /// </summary>
407
+ /// <param name="declarations"></param>
408
+ /// <param name="selection"></param>
409
+ /// <returns></returns>
378
410
public static Declaration FindVariable ( this IEnumerable < Declaration > declarations , QualifiedSelection selection )
379
411
{
380
412
var items = declarations . Where ( d => ! d . IsBuiltIn && d . DeclarationType == DeclarationType . Variable ) . ToList ( ) ;
0 commit comments