33
44namespace Microsoft . Windows . PowerShell . ScriptAnalyzer
55{
6+ /// <summary>
7+ /// Class to represent position in text.
8+ /// </summary>
69 public class Position
710 {
8- public int Line { get ; }
9- public int Column { get ; }
11+ /// <summary>
12+ /// Constructs a Position object.
13+ /// </summary>
14+ /// <param name="line">1-based line number.</param>
15+ /// <param name="column">1-based column number.</param>
1016 public Position ( int line , int column )
1117 {
1218 if ( line < 1 )
@@ -27,6 +33,10 @@ public Position(int line, int column)
2733 Column = column ;
2834 }
2935
36+ /// <summary>
37+ /// Copy constructor.
38+ /// </summary>
39+ /// <param name="position">Object to be copied.</param>
3040 public Position ( Position position )
3141 {
3242 if ( position == null )
@@ -38,6 +48,22 @@ public Position(Position position)
3848 Column = position . Column ;
3949 }
4050
51+ /// <summary>
52+ /// Line number of the position.
53+ /// </summary>
54+ public int Line { get ; }
55+
56+ /// <summary>
57+ /// Column number of the position.
58+ /// </summary>
59+ public int Column { get ; }
60+
61+ /// <summary>
62+ /// Shift the position by given line and column deltas.
63+ /// </summary>
64+ /// <param name="lineDelta">Number of lines to shift the position.</param>
65+ /// <param name="columnDelta">Number of columns to shift the position.</param>
66+ /// <returns>A new Position object with the shifted position.</returns>
4167 public Position Shift ( int lineDelta , int columnDelta )
4268 {
4369 int newLine = Line ;
@@ -62,6 +88,12 @@ public Position Shift(int lineDelta, int columnDelta)
6288 return new Position ( newLine , newColumn ) ;
6389 }
6490
91+ /// <summary>
92+ /// Normalize position with respect to a reference position.
93+ /// </summary>
94+ /// <param name="refPos">Reference position.</param>
95+ /// <param name="pos">Position to be normalized.</param>
96+ /// <returns>A Position object with normalized position.</returns>
6597 public static Position Normalize ( Position refPos , Position pos )
6698 {
6799 if ( refPos == null )
@@ -91,6 +123,9 @@ public static Position Normalize(Position refPos, Position pos)
91123 }
92124 }
93125
126+ /// <summary>
127+ /// Checks if two position objects are equal.
128+ /// </summary>
94129 public static bool operator == ( Position lhs , Position rhs )
95130 {
96131 if ( ( object ) lhs == null )
@@ -111,11 +146,17 @@ public static Position Normalize(Position refPos, Position pos)
111146 return lhs . Equals ( rhs ) ;
112147 }
113148
149+ /// <summary>
150+ /// Checks if the position objects are not equal.
151+ /// </summary>
114152 public static bool operator != ( Position lhs , Position rhs )
115153 {
116154 return ! ( lhs == rhs ) ;
117155 }
118156
157+ /// <summary>
158+ /// Checks if the left hand position comes before the right hand position.
159+ /// </summary>
119160 public static bool operator < ( Position lhs , Position rhs )
120161 {
121162 if ( lhs == null )
@@ -131,21 +172,33 @@ public static Position Normalize(Position refPos, Position pos)
131172 return lhs . Line < rhs . Line || ( lhs . Line == rhs . Line && lhs . Column < rhs . Column ) ;
132173 }
133174
175+ /// <summary>
176+ /// Checks if the left hand position comes before or is at the same position as that of the right hand position.
177+ /// </summary>
134178 public static bool operator <= ( Position lhs , Position rhs )
135179 {
136180 return lhs == rhs || lhs < rhs ;
137181 }
138182
183+ /// <summary>
184+ /// Checks if the left hand position comes after the right hand position.
185+ /// </summary>
139186 public static bool operator > ( Position lhs , Position rhs )
140187 {
141188 return ! ( lhs <= rhs ) ;
142189 }
143190
191+ /// <summary>
192+ /// Checks if the left hand position comes after or is at the same position as that of the right hand position.
193+ /// </summary>
144194 public static bool operator >= ( Position lhs , Position rhs )
145195 {
146196 return ! ( lhs < rhs ) ;
147197 }
148198
199+ /// <summary>
200+ /// Checks of this object is equal the input object.
201+ /// </summary>
149202 public override bool Equals ( object obj )
150203 {
151204 if ( obj == null )
@@ -162,6 +215,9 @@ public override bool Equals(object obj)
162215 return Line == p . Line && Column == p . Column ;
163216 }
164217
218+ /// <summary>
219+ /// Returns the hash code of this object
220+ /// </summary>
165221 public override int GetHashCode ( )
166222 {
167223 return Line * Column ;
0 commit comments