Revert "Generate line mappings for empty expressions."
This reverts commit 4c0afbad86.
This commit is contained in:
parent
4c0afbad86
commit
d4e21ae706
|
|
@ -21,6 +21,11 @@ namespace Microsoft.AspNetCore.Razor.Evolution.CodeGeneration
|
|||
throw new ArgumentNullException(nameof(node));
|
||||
}
|
||||
|
||||
if (node.Children.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.Source != null)
|
||||
{
|
||||
using (context.Writer.BuildLinePragma(node.Source.Value))
|
||||
|
|
@ -29,28 +34,18 @@ namespace Microsoft.AspNetCore.Razor.Evolution.CodeGeneration
|
|||
context.Writer.WritePadding(offset, node.Source, context);
|
||||
context.Writer.WriteStartAssignment(RazorDesignTimeIRPass.DesignTimeVariable);
|
||||
|
||||
if (node.Children.Count > 0)
|
||||
for (var i = 0; i < node.Children.Count; i++)
|
||||
{
|
||||
for (var i = 0; i < node.Children.Count; i++)
|
||||
if (node.Children[i] is RazorIRToken token && token.IsCSharp)
|
||||
{
|
||||
if (node.Children[i] is RazorIRToken token && token.IsCSharp)
|
||||
{
|
||||
context.AddLineMappingFor(token);
|
||||
context.Writer.Write(token.Content);
|
||||
}
|
||||
else
|
||||
{
|
||||
// There may be something else inside the expression like a Template or another extension node.
|
||||
context.RenderNode(node.Children[i]);
|
||||
}
|
||||
context.AddLineMappingFor(token);
|
||||
context.Writer.Write(token.Content);
|
||||
}
|
||||
else
|
||||
{
|
||||
// There may be something else inside the expression like a Template or another extension node.
|
||||
context.RenderNode(node.Children[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// When typing "@" / "@(" we still need to provide IntelliSense. This is taken care of by creating a 0 length
|
||||
// line mapping. It's also important that this 0 length line mapping exists in a line pragma so when a user
|
||||
// starts typing additional characters following their "@" they get appropriately located errors.
|
||||
context.AddLineMappingFor(node);
|
||||
}
|
||||
|
||||
context.Writer.WriteLine(";");
|
||||
|
|
|
|||
|
|
@ -19,6 +19,10 @@ namespace Microsoft.AspNetCore.Razor.Evolution.CodeGeneration
|
|||
public override void VisitCSharpExpression(CSharpExpressionIRNode node)
|
||||
{
|
||||
// We can't remove this yet, because it's still used recursively in a few places.
|
||||
if (node.Children.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.Source != null)
|
||||
{
|
||||
|
|
@ -31,29 +35,19 @@ namespace Microsoft.AspNetCore.Razor.Evolution.CodeGeneration
|
|||
.Write(padding)
|
||||
.WriteStartAssignment(RazorDesignTimeIRPass.DesignTimeVariable);
|
||||
|
||||
if (node.Children.Count > 0)
|
||||
for (var i = 0; i < node.Children.Count; i++)
|
||||
{
|
||||
for (var i = 0; i < node.Children.Count; i++)
|
||||
{
|
||||
var token = node.Children[i] as RazorIRToken;
|
||||
if (token != null && token.IsCSharp)
|
||||
{
|
||||
Context.AddLineMappingFor(token);
|
||||
Context.Writer.Write(token.Content);
|
||||
}
|
||||
else
|
||||
{
|
||||
// There may be something else inside the expression like a Template or another extension node.
|
||||
Visit(node.Children[i]);
|
||||
}
|
||||
{
|
||||
Context.AddLineMappingFor(token);
|
||||
Context.Writer.Write(token.Content);
|
||||
}
|
||||
else
|
||||
{
|
||||
// There may be something else inside the expression like a Template or another extension node.
|
||||
Visit(node.Children[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// When typing "@" / "@(" we still need to provide IntelliSense. This is taken care of by creating a 0 length
|
||||
// line mapping. It's also important that this 0 length line mapping exists in a line pragma so when a user
|
||||
// starts typing additional characters following their "@" they get appropriately located errors.
|
||||
Context.AddLineMappingFor(node);
|
||||
}
|
||||
|
||||
Context.Writer.WriteLine(";");
|
||||
|
|
|
|||
|
|
@ -344,7 +344,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution
|
|||
|
||||
_builder.Pop();
|
||||
|
||||
var emptyExpression = true;
|
||||
if (expressionNode.Children.Count > 0)
|
||||
{
|
||||
var sourceRangeStart = expressionNode
|
||||
|
|
@ -362,19 +361,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution
|
|||
sourceRangeStart.Value.LineIndex,
|
||||
sourceRangeStart.Value.CharacterIndex,
|
||||
contentLength);
|
||||
emptyExpression = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (emptyExpression)
|
||||
{
|
||||
expressionNode.Source = new SourceSpan(
|
||||
block.Start.FilePath ?? FileName,
|
||||
block.Start.AbsoluteIndex,
|
||||
block.Start.LineIndex,
|
||||
block.Start.CharacterIndex,
|
||||
length: 0);
|
||||
}
|
||||
}
|
||||
|
||||
public override void VisitExpressionSpan(ExpressionChunkGenerator chunkGenerator, Span span)
|
||||
|
|
|
|||
|
|
@ -13,11 +13,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
|
|||
#pragma warning disable 1998
|
||||
public async System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml"
|
||||
__o = ;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,4 +17,4 @@ Document -
|
|||
RazorIRToken - - CSharp - private static System.Object __o = null;
|
||||
RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [18] EmptyExplicitExpression.cshtml) - This is markup\n\n
|
||||
CSharpExpression - (18:2,0 [0] EmptyExplicitExpression.cshtml)
|
||||
CSharpExpression -
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
Source Location: (18:2,0 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml)
|
||||
||
|
||||
Generated Location: (678:16,6 [0] )
|
||||
||
|
||||
|
||||
|
|
@ -10,11 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
|
|||
public async System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
WriteLiteral("This is markup\r\n\r\n");
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml"
|
||||
Write();
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
Write();
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ Document -
|
|||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyExplicitExpression_Runtime - -
|
||||
RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [18] EmptyExplicitExpression.cshtml) - This is markup\n\n
|
||||
CSharpExpression - (18:2,0 [0] EmptyExplicitExpression.cshtml)
|
||||
CSharpExpression -
|
||||
|
|
|
|||
|
|
@ -15,11 +15,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
|
|||
{
|
||||
|
||||
|
||||
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml"
|
||||
__o = ;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@ Document -
|
|||
RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
CSharpStatement - (2:0,2 [6] EmptyImplicitExpressionInCode.cshtml)
|
||||
RazorIRToken - (2:0,2 [6] EmptyImplicitExpressionInCode.cshtml) - CSharp - \n
|
||||
CSharpExpression - (8:1,4 [0] EmptyImplicitExpressionInCode.cshtml)
|
||||
CSharpExpression -
|
||||
CSharpStatement - (9:1,5 [2] EmptyImplicitExpressionInCode.cshtml)
|
||||
RazorIRToken - (9:1,5 [2] EmptyImplicitExpressionInCode.cshtml) - CSharp - \n
|
||||
|
|
|
|||
|
|
@ -5,15 +5,10 @@ Generated Location: (593:15,14 [6] )
|
|||
|
|
||||
|
|
||||
|
||||
Source Location: (8:1,4 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml)
|
||||
||
|
||||
Generated Location: (712:18,6 [0] )
|
||||
||
|
||||
|
||||
Source Location: (9:1,5 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml)
|
||||
|
|
||||
|
|
||||
Generated Location: (763:22,17 [2] )
|
||||
Generated Location: (618:17,17 [2] )
|
||||
|
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
|
|||
#pragma warning disable 1998
|
||||
public async System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml"
|
||||
Write();
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
Write();
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ Document -
|
|||
RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
CSharpStatement - (2:0,2 [6] EmptyImplicitExpressionInCode.cshtml)
|
||||
RazorIRToken - (2:0,2 [6] EmptyImplicitExpressionInCode.cshtml) - CSharp - \n
|
||||
CSharpExpression - (8:1,4 [0] EmptyImplicitExpressionInCode.cshtml)
|
||||
CSharpExpression -
|
||||
CSharpStatement - (9:1,5 [2] EmptyImplicitExpressionInCode.cshtml)
|
||||
RazorIRToken - (9:1,5 [2] EmptyImplicitExpressionInCode.cshtml) - CSharp - \n
|
||||
|
|
|
|||
|
|
@ -13,11 +13,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
|
|||
#pragma warning disable 1998
|
||||
public async System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml"
|
||||
__o = ;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,5 +17,5 @@ Document -
|
|||
RazorIRToken - - CSharp - private static System.Object __o = null;
|
||||
RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [18] EmptyImplicitExpression.cshtml) - This is markup\n\n
|
||||
CSharpExpression - (18:2,0 [0] EmptyImplicitExpression.cshtml)
|
||||
CSharpExpression -
|
||||
HtmlContent - (19:2,1 [1] EmptyImplicitExpression.cshtml) - !
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
Source Location: (18:2,0 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml)
|
||||
||
|
||||
Generated Location: (678:16,6 [0] )
|
||||
||
|
||||
|
||||
|
|
@ -10,11 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
|
|||
public async System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
WriteLiteral("This is markup\r\n\r\n");
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml"
|
||||
Write();
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
Write();
|
||||
WriteLiteral("!");
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
|
|
|
|||
|
|
@ -6,5 +6,5 @@ Document -
|
|||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_EmptyImplicitExpression_Runtime - -
|
||||
RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [18] EmptyImplicitExpression.cshtml) - This is markup\n\n
|
||||
CSharpExpression - (18:2,0 [0] EmptyImplicitExpression.cshtml)
|
||||
CSharpExpression -
|
||||
HtmlContent - (19:2,1 [1] EmptyImplicitExpression.cshtml) - !
|
||||
|
|
|
|||
|
|
@ -13,11 +13,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
|
|||
#pragma warning disable 1998
|
||||
public async System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml"
|
||||
__o = ;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,4 +17,4 @@ Document -
|
|||
RazorIRToken - - CSharp - private static System.Object __o = null;
|
||||
RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [18] ExplicitExpressionAtEOF.cshtml) - This is markup\n\n
|
||||
CSharpExpression - (18:2,0 [0] ExplicitExpressionAtEOF.cshtml)
|
||||
CSharpExpression -
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
Source Location: (18:2,0 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml)
|
||||
||
|
||||
Generated Location: (678:16,6 [0] )
|
||||
||
|
||||
|
||||
|
|
@ -10,11 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
|
|||
public async System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
WriteLiteral("This is markup\r\n\r\n");
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml"
|
||||
Write();
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
Write();
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ Document -
|
|||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ExplicitExpressionAtEOF_Runtime - -
|
||||
RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [18] ExplicitExpressionAtEOF.cshtml) - This is markup\n\n
|
||||
CSharpExpression - (18:2,0 [0] ExplicitExpressionAtEOF.cshtml)
|
||||
CSharpExpression -
|
||||
|
|
|
|||
|
|
@ -13,11 +13,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
|
|||
#pragma warning disable 1998
|
||||
public async System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml"
|
||||
__o = ;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,4 +17,4 @@ Document -
|
|||
RazorIRToken - - CSharp - private static System.Object __o = null;
|
||||
RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [18] ImplicitExpressionAtEOF.cshtml) - This is markup\n\n
|
||||
CSharpExpression - (18:2,0 [0] ImplicitExpressionAtEOF.cshtml)
|
||||
CSharpExpression -
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
Source Location: (18:2,0 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml)
|
||||
||
|
||||
Generated Location: (678:16,6 [0] )
|
||||
||
|
||||
|
||||
|
|
@ -10,11 +10,7 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
|
|||
public async System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
WriteLiteral("This is markup\r\n\r\n");
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml"
|
||||
Write();
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
Write();
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ Document -
|
|||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ImplicitExpressionAtEOF_Runtime - -
|
||||
RazorMethodDeclaration - - public - async - System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [18] ImplicitExpressionAtEOF.cshtml) - This is markup\n\n
|
||||
CSharpExpression - (18:2,0 [0] ImplicitExpressionAtEOF.cshtml)
|
||||
CSharpExpression -
|
||||
|
|
|
|||
Loading…
Reference in New Issue