Skip to content

Commit b5b0fbb

Browse files
StartAutomatingStartAutomating
authored andcommitted
enhancement: Extending Microsoft.CodeAnalysis.SyntaxTree (Fixes #549)
1 parent e5e13c3 commit b5b0fbb

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
System.Management.Automation.Language.VariableExpressionAst.GetAssignments()
2+
----------------------------------------------------------------------------
3+
4+
5+
6+
7+
### Synopsis
8+
Gets assignments of a variable
9+
10+
11+
12+
---
13+
14+
15+
### Description
16+
17+
Searches the abstract syntax tree for assignments of the variable.
18+
19+
20+
21+
---
22+
23+
24+
### Examples
25+
> EXAMPLE 1
26+
27+
```PowerShell
28+
{
29+
$x = 1
30+
$y = 2
31+
$x * $y
32+
}.Ast.EndBlock.Statements[-1].PipelineElements[0].Expression.Left.GetAssignments()
33+
```
34+
> EXAMPLE 2
35+
36+
```PowerShell
37+
{
38+
[int]$x, [int]$y = 1, 2
39+
$x * $y
40+
}.Ast.EndBlock.Statements[-1].PipelineElements[0].Expression.Left.GetAssignments()
41+
```
42+
> EXAMPLE 3
43+
44+
```PowerShell
45+
{
46+
param($x, $y)
47+
$x * $y
48+
}.Ast.EndBlock.Statements[-1].PipelineElements[0].Expression.Left.GetAssignments()
49+
```
50+
51+
52+
---

0 commit comments

Comments
 (0)