Use Span in diagnostics reporting
This commit is contained in:
parent
e60cc1bb73
commit
165cd35485
@ -30,7 +30,7 @@ namespace Parser.Binding
|
|||||||
if (f.Name == "Main")
|
if (f.Name == "Main")
|
||||||
{
|
{
|
||||||
_diagnostics.ReportMainIsNotAllowed(
|
_diagnostics.ReportMainIsNotAllowed(
|
||||||
new TextSpan(f.Syntax.Position, f.Syntax.FullWidth));
|
f.Syntax.Span);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,8 +277,7 @@ namespace Parser.Binding
|
|||||||
{
|
{
|
||||||
if (node.Kind != TokenKind.IdentifierNameExpression)
|
if (node.Kind != TokenKind.IdentifierNameExpression)
|
||||||
{
|
{
|
||||||
_diagnostics.ReportForLoopWithoutVariable(
|
_diagnostics.ReportForLoopWithoutVariable(node.Span);
|
||||||
new TextSpan(node.Position, node.FullWidth));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace Parser
|
|||||||
if (mainFunction.InputDescription.Length > 0)
|
if (mainFunction.InputDescription.Length > 0)
|
||||||
{
|
{
|
||||||
_diagnostics.ReportNotEnoughInputs(
|
_diagnostics.ReportNotEnoughInputs(
|
||||||
new TextSpan(mainFunction.Body.Syntax.Position, mainFunction.Body.Syntax.Position + mainFunction.Body.Syntax.FullWidth),
|
mainFunction.Body.Syntax.Span,
|
||||||
mainFunction.Name);
|
mainFunction.Name);
|
||||||
return new EvaluationResult(null, _diagnostics.ToImmutableArray());
|
return new EvaluationResult(null, _diagnostics.ToImmutableArray());
|
||||||
}
|
}
|
||||||
@ -291,10 +291,9 @@ namespace Parser
|
|||||||
foreach (var argument in node.Arguments)
|
foreach (var argument in node.Arguments)
|
||||||
{
|
{
|
||||||
var evaluatedArgument = EvaluateExpression(argument);
|
var evaluatedArgument = EvaluateExpression(argument);
|
||||||
if (argument is null)
|
if (evaluatedArgument is null)
|
||||||
{
|
{
|
||||||
_diagnostics.ReportCannotEvaluateExpression(
|
_diagnostics.ReportCannotEvaluateExpression(argument.Syntax.Span);
|
||||||
new TextSpan(argument.Syntax.Position, argument.Syntax.FullWidth));
|
|
||||||
allGood = false;
|
allGood = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -319,9 +318,7 @@ namespace Parser
|
|||||||
if (resolvedFunction is null)
|
if (resolvedFunction is null)
|
||||||
{
|
{
|
||||||
_diagnostics.ReportFunctionNotFound(
|
_diagnostics.ReportFunctionNotFound(
|
||||||
new TextSpan(
|
node.Name.Syntax.Span,
|
||||||
node.Name.Syntax.Position,
|
|
||||||
node.Name.Syntax.Position + node.Name.Syntax.FullWidth),
|
|
||||||
function.Name);
|
function.Name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -343,9 +340,7 @@ namespace Parser
|
|||||||
if (counter < arguments.Count)
|
if (counter < arguments.Count)
|
||||||
{
|
{
|
||||||
_diagnostics.ReportTooManyInputs(
|
_diagnostics.ReportTooManyInputs(
|
||||||
new TextSpan(
|
node.Arguments[counter].Syntax.Span,
|
||||||
node.Arguments[counter].Syntax.Position,
|
|
||||||
node.Arguments[counter].Syntax.Position + node.Arguments[counter].Syntax.FullWidth),
|
|
||||||
function.Name);
|
function.Name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -439,7 +434,7 @@ namespace Parser
|
|||||||
if (maybeValue is null)
|
if (maybeValue is null)
|
||||||
{
|
{
|
||||||
_diagnostics.ReportVariableNotFound(
|
_diagnostics.ReportVariableNotFound(
|
||||||
new TextSpan(node.Syntax.Position, node.Syntax.FullWidth),
|
node.Syntax.Span,
|
||||||
variableName);
|
variableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,7 +500,7 @@ namespace Parser
|
|||||||
if (rightValue is null)
|
if (rightValue is null)
|
||||||
{
|
{
|
||||||
_diagnostics.ReportCannotEvaluateExpression(
|
_diagnostics.ReportCannotEvaluateExpression(
|
||||||
new TextSpan(node.Right.Syntax.Position, node.Right.Syntax.Position + node.Right.Syntax.FullWidth));
|
node.Right.Syntax.Span);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user