Re-add marker IR tokens to represent CSharp in an expression.

- At design time we weren't generating line mappings when a user would type `@` or `@(`. This results in no C# IntelliSense being provided to the user because the editor hasn't mapped any of Razor to the C# buffer.
- Modified the `DefaultIRLoweringPhase` to allow for marker symbols, these symbols .
- Re-generated test files to account for 0 length line mappings on empty expression nodes.

#1155
This commit is contained in:
N. Taylor Mullen 2017-04-03 12:58:06 -07:00
parent d4e21ae706
commit 0e15ff3e95
29 changed files with 103 additions and 27 deletions

View File

@ -367,17 +367,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution
public override void VisitExpressionSpan(ExpressionChunkGenerator chunkGenerator, Span span)
{
if (span.Symbols.Count == 1)
{
if (span.Symbols[0] is CSharpSymbol symbol &&
symbol.Type == CSharpSymbolType.Unknown &&
symbol.Content.Length == 0)
{
// We don't want to create IR nodes for marker symbols.
return;
}
}
_builder.Add(new RazorIRToken()
{
Content = span.Content,

View File

@ -13,6 +13,11 @@ 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
}

View File

@ -17,4 +17,5 @@ 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 -
CSharpExpression - (20:2,2 [0] EmptyExplicitExpression.cshtml)
RazorIRToken - (20:2,2 [0] EmptyExplicitExpression.cshtml) - CSharp -

View File

@ -0,0 +1,5 @@
Source Location: (20:2,2 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml)
||
Generated Location: (678:16,6 [0] )
||

View File

@ -10,7 +10,11 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
public async System.Threading.Tasks.Task ExecuteAsync()
{
WriteLiteral("This is markup\r\n\r\n");
Write();
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyExplicitExpression.cshtml"
Write();
#line default
#line hidden
}
#pragma warning restore 1998
}

View File

@ -6,4 +6,5 @@ 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 -
CSharpExpression - (20:2,2 [0] EmptyExplicitExpression.cshtml)
RazorIRToken - (20:2,2 [0] EmptyExplicitExpression.cshtml) - CSharp -

View File

@ -15,6 +15,11 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
{
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml"
__o = ;
#line default
#line hidden
}

View File

@ -18,6 +18,7 @@ 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 -
CSharpExpression - (9:1,5 [0] EmptyImplicitExpressionInCode.cshtml)
RazorIRToken - (9:1,5 [0] EmptyImplicitExpressionInCode.cshtml) - CSharp -
CSharpStatement - (9:1,5 [2] EmptyImplicitExpressionInCode.cshtml)
RazorIRToken - (9:1,5 [2] EmptyImplicitExpressionInCode.cshtml) - CSharp - \n

View File

@ -5,10 +5,15 @@ Generated Location: (593:15,14 [6] )
|
|
Source Location: (9:1,5 [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: (618:17,17 [2] )
Generated Location: (763:22,17 [2] )
|
|

View File

@ -9,7 +9,11 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
#pragma warning disable 1998
public async System.Threading.Tasks.Task ExecuteAsync()
{
Write();
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpressionInCode.cshtml"
Write();
#line default
#line hidden
}
#pragma warning restore 1998
}

View File

@ -7,6 +7,7 @@ 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 -
CSharpExpression - (9:1,5 [0] EmptyImplicitExpressionInCode.cshtml)
RazorIRToken - (9:1,5 [0] EmptyImplicitExpressionInCode.cshtml) - CSharp -
CSharpStatement - (9:1,5 [2] EmptyImplicitExpressionInCode.cshtml)
RazorIRToken - (9:1,5 [2] EmptyImplicitExpressionInCode.cshtml) - CSharp - \n

View File

@ -13,6 +13,11 @@ 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
}

View File

@ -17,5 +17,6 @@ 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 -
CSharpExpression - (19:2,1 [0] EmptyImplicitExpression.cshtml)
RazorIRToken - (19:2,1 [0] EmptyImplicitExpression.cshtml) - CSharp -
HtmlContent - (19:2,1 [1] EmptyImplicitExpression.cshtml) - !

View File

@ -0,0 +1,5 @@
Source Location: (19:2,1 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml)
||
Generated Location: (678:16,6 [0] )
||

View File

@ -10,7 +10,11 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
public async System.Threading.Tasks.Task ExecuteAsync()
{
WriteLiteral("This is markup\r\n\r\n");
Write();
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/EmptyImplicitExpression.cshtml"
Write();
#line default
#line hidden
WriteLiteral("!");
}
#pragma warning restore 1998

View File

@ -6,5 +6,6 @@ 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 -
CSharpExpression - (19:2,1 [0] EmptyImplicitExpression.cshtml)
RazorIRToken - (19:2,1 [0] EmptyImplicitExpression.cshtml) - CSharp -
HtmlContent - (19:2,1 [1] EmptyImplicitExpression.cshtml) - !

View File

@ -13,6 +13,11 @@ 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
}

View File

@ -17,4 +17,5 @@ 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 -
CSharpExpression - (20:2,2 [0] ExplicitExpressionAtEOF.cshtml)
RazorIRToken - (20:2,2 [0] ExplicitExpressionAtEOF.cshtml) - CSharp -

View File

@ -0,0 +1,5 @@
Source Location: (20:2,2 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml)
||
Generated Location: (678:16,6 [0] )
||

View File

@ -10,7 +10,11 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
public async System.Threading.Tasks.Task ExecuteAsync()
{
WriteLiteral("This is markup\r\n\r\n");
Write();
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionAtEOF.cshtml"
Write();
#line default
#line hidden
}
#pragma warning restore 1998
}

View File

@ -6,4 +6,5 @@ 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 -
CSharpExpression - (20:2,2 [0] ExplicitExpressionAtEOF.cshtml)
RazorIRToken - (20:2,2 [0] ExplicitExpressionAtEOF.cshtml) - CSharp -

View File

@ -20,3 +20,4 @@ Document -
CSharpExpression - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml)
Template - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml)
HtmlContent - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml) - </div>
RazorIRToken - (14:0,14 [0] ExplicitExpressionWithMarkup.cshtml) - CSharp -

View File

@ -0,0 +1,5 @@
Source Location: (14:0,14 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ExplicitExpressionWithMarkup.cshtml)
||
Generated Location: (787:18,1 [0] )
||

View File

@ -9,3 +9,4 @@ Document -
CSharpExpression - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml)
Template - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml)
HtmlContent - (8:0,8 [6] ExplicitExpressionWithMarkup.cshtml) - </div>
RazorIRToken - (14:0,14 [0] ExplicitExpressionWithMarkup.cshtml) - CSharp -

View File

@ -13,6 +13,11 @@ 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
}

View File

@ -17,4 +17,5 @@ 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 -
CSharpExpression - (19:2,1 [0] ImplicitExpressionAtEOF.cshtml)
RazorIRToken - (19:2,1 [0] ImplicitExpressionAtEOF.cshtml) - CSharp -

View File

@ -0,0 +1,5 @@
Source Location: (19:2,1 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml)
||
Generated Location: (678:16,6 [0] )
||

View File

@ -10,7 +10,11 @@ namespace Microsoft.AspNetCore.Razor.Evolution.IntegrationTests.TestFiles
public async System.Threading.Tasks.Task ExecuteAsync()
{
WriteLiteral("This is markup\r\n\r\n");
Write();
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ImplicitExpressionAtEOF.cshtml"
Write();
#line default
#line hidden
}
#pragma warning restore 1998
}

View File

@ -6,4 +6,5 @@ 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 -
CSharpExpression - (19:2,1 [0] ImplicitExpressionAtEOF.cshtml)
RazorIRToken - (19:2,1 [0] ImplicitExpressionAtEOF.cshtml) - CSharp -