Modify await keyword to accept dots.
When doing Html.Foo we used to not accept the "." and then group the rest of the line together at the end. #45
This commit is contained in:
parent
c03e12aa31
commit
d0541ad5b2
|
|
@ -9,7 +9,7 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
{
|
{
|
||||||
private void SetUpExpressions()
|
private void SetUpExpressions()
|
||||||
{
|
{
|
||||||
MapKeywords(AwaitExpression, CSharpKeyword.Await);
|
MapExpressionKeyword(AwaitExpression, CSharpKeyword.Await);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AwaitExpression(bool topLevel)
|
private void AwaitExpression(bool topLevel)
|
||||||
|
|
@ -23,11 +23,6 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
// Accept 1 or more spaces between the await and the following code.
|
// Accept 1 or more spaces between the await and the following code.
|
||||||
AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true));
|
AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true));
|
||||||
|
|
||||||
// Accept a single code piece to await. This will accept up until a method "call" signature.
|
|
||||||
// Ex: "@await |Foo|()" Inbetween the pipes is what is accepted. The Statement/ImplicitExpression
|
|
||||||
// handling capture method calls and the parameters passed in.
|
|
||||||
AcceptWhile(CSharpSymbolType.Identifier);
|
|
||||||
|
|
||||||
// Top level basically indicates if we're within an expression or statement.
|
// Top level basically indicates if we're within an expression or statement.
|
||||||
// Ex: topLevel true = @await Foo() | topLevel false = @{ await Foo(); }
|
// Ex: topLevel true = @await Foo() | topLevel false = @{ await Foo(); }
|
||||||
// Note that in this case @{ <b>@await Foo()</b> } top level is true for await.
|
// Note that in this case @{ <b>@await Foo()</b> } top level is true for await.
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
|
|
||||||
internal static ISet<string> DefaultKeywords = new HashSet<string>()
|
internal static ISet<string> DefaultKeywords = new HashSet<string>()
|
||||||
{
|
{
|
||||||
"await",
|
|
||||||
"if",
|
"if",
|
||||||
"do",
|
"do",
|
||||||
"try",
|
"try",
|
||||||
|
|
@ -78,6 +77,13 @@ namespace Microsoft.AspNet.Razor.Parser
|
||||||
return _directiveParsers.TryGetValue(directive, out handler);
|
return _directiveParsers.TryGetValue(directive, out handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MapExpressionKeyword(Action<bool> handler, CSharpKeyword keyword)
|
||||||
|
{
|
||||||
|
_keywordParsers.Add(keyword, handler);
|
||||||
|
|
||||||
|
// Expression keywords don't belong in the regular keyword list
|
||||||
|
}
|
||||||
|
|
||||||
private void MapKeywords(Action<bool> handler, params CSharpKeyword[] keywords)
|
private void MapKeywords(Action<bool> handler, params CSharpKeyword[] keywords)
|
||||||
{
|
{
|
||||||
MapKeywords(handler, topLevel: true, keywords: keywords);
|
MapKeywords(handler, topLevel: true, keywords: keywords);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue