@@ -25,10 +25,10 @@ namespace AutoItSyntaxHighlight.Lexer
2525{
2626 internal sealed class AutoItLexerComments : IAutoItLexer
2727 {
28- private Regex m_Regex ;
28+ private readonly Regex m_Regex ;
2929 private readonly IClassificationType m_Type ;
30- private List < MultiLineComment > m_MultiLineComments ;
31- private IClassificationTypeRegistryService m_Registry ;
30+ private readonly List < MultiLineComment > m_MultiLineComments ;
31+ private readonly IClassificationTypeRegistryService m_Registry ;
3232 public event EventHandler < ClassificationChangedEventArgs > ClassificationChanged ;
3333
3434 public AutoItLexerComments ( IClassificationTypeRegistryService registry )
@@ -56,13 +56,13 @@ private List<PrioritiesClassificationSpan> ParseMultiLine(SnapshotSpan span)
5656
5757 try
5858 {
59- string codeSegement = span . Snapshot . GetLineFromLineNumber ( lineNumber ) . GetText ( ) ;
60- int endPosition = IndexOfCommentEnd ( codeSegement ) ;
59+ string codeSegment = span . Snapshot . GetLineFromLineNumber ( lineNumber ) . GetText ( ) ;
60+ int endPosition = IndexOfCommentEnd ( codeSegment ) ;
6161 while ( endPosition < 0 )
6262 {
6363 ++ lineNumber ;
64- codeSegement = span . Snapshot . GetLineFromLineNumber ( lineNumber ) . GetText ( ) ;
65- endPosition = IndexOfCommentEnd ( codeSegement ) ;
64+ codeSegment = span . Snapshot . GetLineFromLineNumber ( lineNumber ) . GetText ( ) ;
65+ endPosition = IndexOfCommentEnd ( codeSegment ) ;
6666 }
6767 }
6868 catch ( ArgumentOutOfRangeException )
@@ -80,10 +80,11 @@ private List<PrioritiesClassificationSpan> ParseMultiLine(SnapshotSpan span)
8080 new ClassificationChangedEventArgs ( new SnapshotSpan ( span . End + 1 , multiSpan . End ) ) ) ;
8181 }
8282
83- var prioSpan = new PrioritiesClassificationSpan ( ) ;
84- prioSpan . Span = new ClassificationSpan ( multiSpan , m_Type ) ;
85- prioSpan . Priority = 400 ;
86- classifications . Add ( prioSpan ) ;
83+ var priorClassification = new PrioritiesClassificationSpan
84+ {
85+ Span = new ClassificationSpan ( multiSpan , m_Type ) , Priority = 400
86+ } ;
87+ classifications . Add ( priorClassification ) ;
8788
8889 if ( m_MultiLineComments . Any ( a => a . Tracking . GetSpan ( span . Snapshot ) . Span == multiSpan . Span ) == false )
8990 {
@@ -120,16 +121,16 @@ public List<PrioritiesClassificationSpan> Parse(SnapshotSpan span)
120121 isInsideOfComment = true ;
121122 if ( span . Snapshot . Version == comment . Version )
122123 {
123- var prioSpan = new PrioritiesClassificationSpan ( ) ;
124- prioSpan . Span = new ClassificationSpan ( multiSpan , m_Type ) ;
125- prioSpan . Priority = 400 ;
126- classifications . Add ( prioSpan ) ;
124+ var priorClassification = new PrioritiesClassificationSpan
125+ {
126+ Span = new ClassificationSpan ( multiSpan , m_Type ) , Priority = 400
127+ } ;
128+ classifications . Add ( priorClassification ) ;
127129 }
128130 else
129131 {
130132 m_MultiLineComments . RemoveAt ( i ) ;
131133 ClassificationChanged ? . Invoke ( this , new ClassificationChangedEventArgs ( multiSpan ) ) ;
132- continue ;
133134 }
134135 }
135136
@@ -157,10 +158,11 @@ public List<PrioritiesClassificationSpan> Parse(SnapshotSpan span)
157158 span . GetText ( ) . Length - match . Index ) ;
158159 SnapshotSpan snapshot = new SnapshotSpan ( span . Snapshot , spanWord ) ;
159160
160- var prioSpan = new PrioritiesClassificationSpan ( ) ;
161- prioSpan . Span = new ClassificationSpan ( snapshot , m_Type ) ;
162- prioSpan . Priority = 400 ;
163- classifications . Add ( prioSpan ) ;
161+ var priorClassification = new PrioritiesClassificationSpan
162+ {
163+ Span = new ClassificationSpan ( snapshot , m_Type ) , Priority = 400
164+ } ;
165+ classifications . Add ( priorClassification ) ;
164166 }
165167 return classifications ;
166168 }
@@ -184,12 +186,12 @@ private int IndexOfCommentStart(string code)
184186 {
185187 if ( code . Contains ( "#cs" ) )
186188 {
187- return code . IndexOf ( "#cs" ) ;
189+ return code . IndexOf ( "#cs" , StringComparison . Ordinal ) ;
188190 }
189191
190192 if ( code . Contains ( "#comment-start" ) )
191193 {
192- return code . IndexOf ( "#comment-start" ) ;
194+ return code . IndexOf ( "#comment-start" , StringComparison . Ordinal ) ;
193195 }
194196 return - 1 ;
195197 }
@@ -198,12 +200,12 @@ private int IndexOfCommentEnd(string code)
198200 {
199201 if ( code . Contains ( "#ce" ) )
200202 {
201- return code . IndexOf ( "#ce" ) ;
203+ return code . IndexOf ( "#ce" , StringComparison . Ordinal ) ;
202204 }
203205
204206 if ( code . Contains ( "#comment-end" ) )
205207 {
206- return code . IndexOf ( "#comment-end" ) ;
208+ return code . IndexOf ( "#comment-end" , StringComparison . Ordinal ) ;
207209 }
208210 return - 1 ;
209211 }
0 commit comments