mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
handle null ref exceptions in managed parser (#1606)
* handle null ref exceptions * add comment
This commit is contained in:
@@ -83,7 +83,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate the rest batch definitions
|
// Generate the rest batch definitions
|
||||||
for (int index = 1; index < count - 1 ; index++)
|
for (int index = 1; index < count - 1; index++)
|
||||||
{
|
{
|
||||||
lineDifference = batchInfos[index + 1].startLine - batchInfos[index].startLine;
|
lineDifference = batchInfos[index + 1].startLine - batchInfos[index].startLine;
|
||||||
position = ReadLines(reader, lineDifference, endLine);
|
position = ReadLines(reader, lineDifference, endLine);
|
||||||
@@ -151,7 +151,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser
|
|||||||
while (!foundAllOffsets)
|
while (!foundAllOffsets)
|
||||||
{
|
{
|
||||||
// go until the last start line of the batches
|
// go until the last start line of the batches
|
||||||
for (int i = 0; i <= maxStartLine ; i++)
|
for (int i = 0; i <= maxStartLine; i++)
|
||||||
{
|
{
|
||||||
// get offset for the current batch
|
// get offset for the current batch
|
||||||
ReadLines(reader, ref count, ref offset, ref foundAllOffsets, batchInfos, offsets, i);
|
ReadLines(reader, ref count, ref offset, ref foundAllOffsets, batchInfos, offsets, i);
|
||||||
@@ -229,7 +229,8 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get number of characters in the last line
|
// get number of characters in the last line
|
||||||
int endColumn = prevLine.ToCharArray().Length;
|
// for some SQLCMD scenarios, the reader is already at the end of file and causing the prevLine to be null.
|
||||||
|
int endColumn = prevLine == null ? 0 : prevLine.ToCharArray().Length;
|
||||||
|
|
||||||
return new BatchDefinition(
|
return new BatchDefinition(
|
||||||
batchText,
|
batchText,
|
||||||
@@ -263,7 +264,8 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get number of characters in the last line
|
// get number of characters in the last line
|
||||||
int endColumn = prevLine.ToCharArray().Length;
|
// for some SQLCMD scenarios, the reader is already at the end of file and causing the prevLine to be null.
|
||||||
|
int endColumn = prevLine == null ? 0 : prevLine.ToCharArray().Length;
|
||||||
|
|
||||||
//lineOffset doesn't matter because its the last batch
|
//lineOffset doesn't matter because its the last batch
|
||||||
return Tuple.Create(endLine, endColumn);
|
return Tuple.Create(endLine, endColumn);
|
||||||
|
|||||||
Reference in New Issue
Block a user