Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Removed @helper directive #323

Merged
merged 1 commit into from
Mar 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public override CodeBuilderResult Build()

var csharpCodeVisitor = CreateCSharpCodeVisitor(writer, Context);

new CSharpHelperVisitor(csharpCodeVisitor, writer, Context).Accept(Tree.Chunks);
new CSharpTypeMemberVisitor(csharpCodeVisitor, writer, Context).Accept(Tree.Chunks);
new CSharpDesignTimeHelpersVisitor(csharpCodeVisitor, writer, Context).AcceptTree(Tree);
new CSharpTagHelperFieldDeclarationVisitor(writer, Context).Accept(Tree.Chunks);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ public virtual void Accept(Chunk chunk)
{
Visit((UsingChunk)chunk);
}
else if (chunk is HelperChunk)
{
Visit((HelperChunk)chunk);
}
else if (chunk is SetBaseTypeChunk)
{
Visit((SetBaseTypeChunk)chunk);
Expand Down Expand Up @@ -131,7 +127,6 @@ public virtual void Accept(Chunk chunk)
protected abstract void Visit(DynamicCodeAttributeChunk chunk);
protected abstract void Visit(LiteralCodeAttributeChunk chunk);
protected abstract void Visit(CodeAttributeChunk chunk);
protected abstract void Visit(HelperChunk chunk);
protected abstract void Visit(SectionChunk chunk);
protected abstract void Visit(TypeMemberChunk chunk);
protected abstract void Visit(ResolveUrlChunk chunk);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ protected override void Visit(LiteralCodeAttributeChunk chunk)
protected override void Visit(CodeAttributeChunk chunk)
{
}
protected override void Visit(HelperChunk chunk)
{
}
protected override void Visit(SectionChunk chunk)
{
}
Expand Down

This file was deleted.

60 changes: 0 additions & 60 deletions src/Microsoft.AspNet.Razor/Generator/HelperCodeGenerator.cs

This file was deleted.

173 changes: 0 additions & 173 deletions src/Microsoft.AspNet.Razor/Parser/CSharpCodeParser.Directives.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ private void SetupDirectives()
MapDirectives(InheritsDirective, SyntaxConstants.CSharp.InheritsKeyword);
MapDirectives(FunctionsDirective, SyntaxConstants.CSharp.FunctionsKeyword);
MapDirectives(SectionDirective, SyntaxConstants.CSharp.SectionKeyword);
MapDirectives(HelperDirective, SyntaxConstants.CSharp.HelperKeyword);
MapDirectives(LayoutDirective, SyntaxConstants.CSharp.LayoutKeyword);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to remove the SyntaxConstants.CSharp.HelperKeyword

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed.

}

Expand Down Expand Up @@ -71,178 +70,6 @@ protected virtual void LayoutDirective()
Output(SpanKind.MetaCode, foundNewline ? AcceptedCharacters.None : AcceptedCharacters.Any);
}

[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Coupling will be reviewed at a later date")]
[SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "C# Keywords are always lower-case")]
protected virtual void HelperDirective()
{
var nested = Context.IsWithin(BlockType.Helper);

// Set the block and span type
Context.CurrentBlock.Type = BlockType.Helper;

// Verify we're on "helper" and accept
AssertDirective(SyntaxConstants.CSharp.HelperKeyword);
var block = new Block(CurrentSymbol.Content.ToString().ToLowerInvariant(), CurrentLocation);
AcceptAndMoveNext();

if (nested)
{
Context.OnError(CurrentLocation, RazorResources.ParseError_Helpers_Cannot_Be_Nested);
}

// Accept a single whitespace character if present, if not, we should stop now
if (!At(CSharpSymbolType.WhiteSpace))
{
string error;
if (At(CSharpSymbolType.NewLine))
{
error = RazorResources.ErrorComponent_Newline;
}
else if (EndOfFile)
{
error = RazorResources.ErrorComponent_EndOfFile;
}
else
{
error = RazorResources.FormatErrorComponent_Character(CurrentSymbol.Content);
}

Context.OnError(
CurrentLocation,
RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start(error));
PutCurrentBack();
Output(SpanKind.MetaCode);
return;
}

var remainingWs = AcceptSingleWhiteSpaceCharacter();

// Output metacode and continue
Output(SpanKind.MetaCode);
if (remainingWs != null)
{
Accept(remainingWs);
}
AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true)); // Don't accept newlines.

// Expecting an identifier (helper name)
var errorReported = !Required(CSharpSymbolType.Identifier, errorIfNotFound: true, errorBase: RazorResources.FormatParseError_Unexpected_Character_At_Helper_Name_Start);
if (!errorReported)
{
Assert(CSharpSymbolType.Identifier);
AcceptAndMoveNext();
}

AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true));

// Expecting parameter list start: "("
var bracketErrorPos = CurrentLocation;
if (!Optional(CSharpSymbolType.LeftParenthesis))
{
if (!errorReported)
{
errorReported = true;
Context.OnError(
CurrentLocation,
RazorResources.FormatParseError_MissingCharAfterHelperName("("));
}
}
else
{
var bracketStart = CurrentLocation;
if (!Balance(BalancingModes.NoErrorOnFailure,
CSharpSymbolType.LeftParenthesis,
CSharpSymbolType.RightParenthesis,
bracketStart))
{
errorReported = true;
Context.OnError(
bracketErrorPos,
RazorResources.ParseError_UnterminatedHelperParameterList);
}
Optional(CSharpSymbolType.RightParenthesis);
}

var bookmark = CurrentLocation.AbsoluteIndex;
IEnumerable<CSharpSymbol> ws = ReadWhile(IsSpacingToken(includeNewLines: true, includeComments: true));

// Expecting a "{"
var errorLocation = CurrentLocation;
var headerComplete = At(CSharpSymbolType.LeftBrace);
if (headerComplete)
{
Accept(ws);
AcceptAndMoveNext();
}
else
{
Context.Source.Position = bookmark;
NextToken();
AcceptWhile(IsSpacingToken(includeNewLines: false, includeComments: true));
if (!errorReported)
{
Context.OnError(
errorLocation,
RazorResources.FormatParseError_MissingCharAfterHelperParameters(
Language.GetSample(CSharpSymbolType.LeftBrace)));
}
}

// Grab the signature and build the code generator
AddMarkerSymbolIfNecessary();
LocationTagged<string> signature = Span.GetContent();
var blockGen = new HelperCodeGenerator(signature, headerComplete);
Context.CurrentBlock.CodeGenerator = blockGen;

// The block will generate appropriate code,
Span.CodeGenerator = SpanCodeGenerator.Null;

if (!headerComplete)
{
CompleteBlock();
Output(SpanKind.Code);
return;
}
else
{
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
Output(SpanKind.Code);
}

// We're valid, so parse the nested block
var bodyEditHandler = new AutoCompleteEditHandler(Language.TokenizeString);
using (PushSpanConfig(DefaultSpanConfig))
{
using (Context.StartBlock(BlockType.Statement))
{
Span.EditHandler = bodyEditHandler;
CodeBlock(false, block);
CompleteBlock(insertMarkerIfNecessary: true);
Output(SpanKind.Code);
}
}
Initialize(Span);

EnsureCurrent();

Span.CodeGenerator = SpanCodeGenerator.Null; // The block will generate the footer code.
if (!Optional(CSharpSymbolType.RightBrace))
{
// The } is missing, so set the initial signature span to use it as an autocomplete string
bodyEditHandler.AutoCompleteString = "}";

// Need to be able to accept anything to properly handle the autocomplete
bodyEditHandler.AcceptedCharacters = AcceptedCharacters.Any;
}
else
{
blockGen.Footer = Span.GetContent();
Span.EditHandler.AcceptedCharacters = AcceptedCharacters.None;
}
CompleteBlock();
Output(SpanKind.Code);
}

protected virtual void SectionDirective()
{
var nested = Context.IsWithin(BlockType.Section);
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.AspNet.Razor/Parser/CSharpCodeParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public partial class CSharpCodeParser : TokenizerBackedParser<CSharpTokenizer, C
"using",
"section",
"inherits",
"helper",
"functions",
"namespace",
"class",
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.AspNet.Razor/Parser/SyntaxConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public static class CSharp
public static readonly string InheritsKeyword = "inherits";
public static readonly string FunctionsKeyword = "functions";
public static readonly string SectionKeyword = "section";
public static readonly string HelperKeyword = "helper";
public static readonly string ElseIfKeyword = "else if";
public static readonly string NamespaceKeyword = "namespace";
public static readonly string ClassKeyword = "class";
Expand Down
Loading