@@ -121,7 +121,7 @@ public static Diagnostic LoadWarning(WarningCode code, IEnumerable<string> args,
121121 Code = Code ( code ) ,
122122 Source = source ,
123123 Message = DiagnosticItem . Message ( code , args ?? Enumerable . Empty < string > ( ) ) ,
124- Range = null
124+ Range = new Lsp . Range { Start = new Lsp . Position ( 0 , 0 ) , End = new Lsp . Position ( 0 , 0 ) }
125125 } ;
126126
127127 // warnings 20**
@@ -134,7 +134,7 @@ internal static Diagnostic EmptyStatementWarning(string filename, Position pos)
134134 Code = WarningCode . ExcessSemicolon . Code ( ) ,
135135 Source = filename ,
136136 Message = DiagnosticItem . Message ( WarningCode . ExcessSemicolon , Enumerable . Empty < string > ( ) ) ,
137- Range = pos == null ? null : new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
137+ Range = new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
138138 } ;
139139 }
140140 }
@@ -156,82 +156,112 @@ public static Diagnostic LoadError(ErrorCode code, IEnumerable<string> args, str
156156 Code = Code ( code ) ,
157157 Source = source ,
158158 Message = DiagnosticItem . Message ( code , args ?? Enumerable . Empty < string > ( ) ) ,
159- Range = null
159+ Range = new Lsp . Range { Start = new Lsp . Position ( 0 , 0 ) , End = new Lsp . Position ( 0 , 0 ) }
160160 } ;
161161
162162 // errors 20**
163163
164164 internal static Diagnostic InvalidFragmentEnding ( string filename , ErrorCode code , Position pos )
165165 {
166+ if ( pos == null )
167+ {
168+ throw new ArgumentNullException ( nameof ( pos ) ) ;
169+ }
170+
166171 return new Diagnostic
167172 {
168173 Severity = DiagnosticSeverity . Error ,
169174 Code = Code ( code ) ,
170175 Source = filename ,
171176 Message = DiagnosticItem . Message ( code , Enumerable . Empty < string > ( ) ) ,
172- Range = pos == null ? null : new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
177+ Range = new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
173178 } ;
174179 }
175180
176181 internal static Diagnostic MisplacedOpeningBracketError ( string filename , Position pos )
177182 {
183+ if ( pos == null )
184+ {
185+ throw new ArgumentNullException ( nameof ( pos ) ) ;
186+ }
187+
178188 return new Diagnostic
179189 {
180190 Severity = DiagnosticSeverity . Error ,
181191 Code = ErrorCode . MisplacedOpeningBracket . Code ( ) ,
182192 Source = filename ,
183193 Message = DiagnosticItem . Message ( ErrorCode . MisplacedOpeningBracket , Enumerable . Empty < string > ( ) ) ,
184- Range = pos == null ? null : new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
194+ Range = new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
185195 } ;
186196 }
187197
188198 // errors 10**
189199
190200 internal static Diagnostic ExcessBracketError ( string filename , Position pos )
191201 {
202+ if ( pos == null )
203+ {
204+ throw new ArgumentNullException ( nameof ( pos ) ) ;
205+ }
206+
192207 return new Diagnostic
193208 {
194209 Severity = DiagnosticSeverity . Error ,
195210 Code = ErrorCode . ExcessBracketError . Code ( ) ,
196211 Source = filename ,
197212 Message = DiagnosticItem . Message ( ErrorCode . ExcessBracketError , Enumerable . Empty < string > ( ) ) ,
198- Range = pos == null ? null : new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
213+ Range = new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
199214 } ;
200215 }
201216
202217 internal static Diagnostic MissingClosingBracketError ( string filename , Position pos )
203218 {
219+ if ( pos == null )
220+ {
221+ throw new ArgumentNullException ( nameof ( pos ) ) ;
222+ }
223+
204224 return new Diagnostic
205225 {
206226 Severity = DiagnosticSeverity . Error ,
207227 Code = ErrorCode . MissingBracketError . Code ( ) ,
208228 Source = filename ,
209229 Message = DiagnosticItem . Message ( ErrorCode . MissingBracketError , Enumerable . Empty < string > ( ) ) ,
210- Range = pos == null ? null : new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
230+ Range = new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
211231 } ;
212232 }
213233
214234 internal static Diagnostic MissingStringDelimiterError ( string filename , Position pos )
215235 {
236+ if ( pos == null )
237+ {
238+ throw new ArgumentNullException ( nameof ( pos ) ) ;
239+ }
240+
216241 return new Diagnostic
217242 {
218243 Severity = DiagnosticSeverity . Error ,
219244 Code = ErrorCode . MissingStringDelimiterError . Code ( ) ,
220245 Source = filename ,
221246 Message = DiagnosticItem . Message ( ErrorCode . MissingStringDelimiterError , Enumerable . Empty < string > ( ) ) ,
222- Range = pos == null ? null : new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
247+ Range = new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
223248 } ;
224249 }
225250
226251 internal static Diagnostic InvalidCharacterInInterpolatedArgument ( string filename , Position pos , char invalidCharacter )
227252 {
253+ if ( pos == null )
254+ {
255+ throw new ArgumentNullException ( nameof ( pos ) ) ;
256+ }
257+
228258 return new Diagnostic
229259 {
230260 Severity = DiagnosticSeverity . Error ,
231261 Code = ErrorCode . InvalidCharacterInInterpolatedArgument . Code ( ) ,
232262 Source = filename ,
233263 Message = DiagnosticItem . Message ( ErrorCode . InvalidCharacterInInterpolatedArgument , new [ ] { invalidCharacter . ToString ( ) } ) ,
234- Range = pos == null ? null : new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
264+ Range = new Lsp . Range { Start = pos . ToLsp ( ) , End = pos . ToLsp ( ) }
235265 } ;
236266 }
237267 }
0 commit comments