File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -207,21 +207,18 @@ Public Class Scanner
207
207
Return
208
208
End If
209
209
210
- 'All errors are reported against the line that the #Const directive appears on
211
- Dim constDirectiveLoc As New Span(m_CodeFileIndex, m_CurrentLine)
212
-
213
210
Me .NextUnconditionally()
214
211
215
212
If m_Current.IsIdentifier = False Then
216
- Compiler.Report.ShowMessage(Messages.VBNC30203, constDirectiveLoc )
213
+ Compiler.Report.ShowMessage(Messages.VBNC30203, m_Current.Location )
217
214
Me .EatLine( False )
218
215
Return
219
216
End If
220
217
name = m_Current.Identifier
221
218
Me .NextUnconditionally()
222
219
223
220
If m_Current <> KS.Equals Then
224
- Compiler.Report.ShowMessage(Messages.VBNC30249, constDirectiveLoc )
221
+ Compiler.Report.ShowMessage(Messages.VBNC30249, m_Current.Location )
225
222
Return
226
223
End If
227
224
Me .NextUnconditionally()
@@ -1348,8 +1345,12 @@ Public Class Scanner
1348
1345
Case COMMENTCHAR1, COMMENTCHAR2, COMMENTCHAR3 'VB Comment
1349
1346
EatComment()
1350
1347
Case nlD, nlA, nl2028, nl2029 'New line
1351
- EatNewLine()
1348
+
1349
+ 'Keep the current line of the end of line token to the current line so we get better
1350
+ 'location info for errors and warnings
1352
1351
Result = Token.CreateEndOfLineToken(GetCurrentLocation)
1352
+ EatNewLine()
1353
+
1353
1354
Case nl0 'End of file
1354
1355
Result = Token.CreateEndOfFileToken(GetCurrentLocation)
1355
1356
Case ":"c ':
Original file line number Diff line number Diff line change 20
20
Public Structure Token
21
21
Public m_TokenType As TokenType
22
22
Public m_TokenObject As Object
23
+ Public m_Location As Span
23
24
24
25
Shared Function IsSomething( ByVal Token As Token) As Boolean
25
26
'Return Token IsNot Nothing AndAlso Token.IsSomething
@@ -164,6 +165,7 @@ Public Structure Token
164
165
End Function
165
166
166
167
Sub New ( ByVal Span As Span)
168
+ m_Location = Span
167
169
End Sub
168
170
169
171
Function IdentiferOrKeywordIdentifier() As String
@@ -474,6 +476,13 @@ Public Structure Token
474
476
Return "not a symbol"
475
477
End Get
476
478
End Property
479
+
480
+ ReadOnly Property Location As Span
481
+ Get
482
+ Return m_Location
483
+ End Get
484
+ End Property
485
+
477
486
End Structure
478
487
479
488
You can’t perform that action at this time.
0 commit comments