public override void VisitDirectiveToken(DirectiveTokenChunkGenerator chunkGenerator, Span span) { _builder.Add(new DirectiveTokenIntermediateNode() { Content = span.Content, DirectiveToken = chunkGenerator.Descriptor, Source = BuildSourceSpanFromNode(span), }); }
public override void VisitDefault(IntermediateNode node) { if (node is MemberDeclarationIntermediateNode) { _class.Add(node); return; } _method.Add(node); }
public override void Add(IntermediateNode node) { node.Annotations[CommonAnnotations.Imported] = CommonAnnotations.Imported; _innerBuilder.Add(node); }
public override void VisitCSharpStatementLiteral(CSharpStatementLiteralSyntax node) { var context = node.GetSpanContext(); if (context == null) { base.VisitCSharpStatementLiteral(node); return; } else if (context.ChunkGenerator is DirectiveTokenChunkGenerator tokenChunkGenerator) { _builder.Add(new DirectiveTokenIntermediateNode() { Content = node.GetContent(), DirectiveToken = tokenChunkGenerator.Descriptor, Source = BuildSourceSpanFromNode(node), }); } else if (context.ChunkGenerator is AddImportChunkGenerator importChunkGenerator) { var namespaceImport = importChunkGenerator.Namespace.Trim(); var namespaceSpan = BuildSourceSpanFromNode(node); _usings.Add(new UsingReference(namespaceImport, namespaceSpan)); } else if (context.ChunkGenerator is AddTagHelperChunkGenerator addTagHelperChunkGenerator) { IntermediateNode directiveNode; if (IsMalformed(addTagHelperChunkGenerator.Diagnostics)) { directiveNode = new MalformedDirectiveIntermediateNode() { DirectiveName = CSharpCodeParser.AddTagHelperDirectiveDescriptor.Directive, Directive = CSharpCodeParser.AddTagHelperDirectiveDescriptor, Source = BuildSourceSpanFromNode(node), }; } else { directiveNode = new DirectiveIntermediateNode() { DirectiveName = CSharpCodeParser.AddTagHelperDirectiveDescriptor.Directive, Directive = CSharpCodeParser.AddTagHelperDirectiveDescriptor, Source = BuildSourceSpanFromNode(node), }; } for (var i = 0; i < addTagHelperChunkGenerator.Diagnostics.Count; i++) { directiveNode.Diagnostics.Add(addTagHelperChunkGenerator.Diagnostics[i]); } _builder.Push(directiveNode); _builder.Add(new DirectiveTokenIntermediateNode() { Content = addTagHelperChunkGenerator.LookupText, DirectiveToken = CSharpCodeParser.AddTagHelperDirectiveDescriptor.Tokens.First(), Source = BuildSourceSpanFromNode(node), }); _builder.Pop(); } else if (context.ChunkGenerator is RemoveTagHelperChunkGenerator removeTagHelperChunkGenerator) { IntermediateNode directiveNode; if (IsMalformed(removeTagHelperChunkGenerator.Diagnostics)) { directiveNode = new MalformedDirectiveIntermediateNode() { DirectiveName = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor.Directive, Directive = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor, Source = BuildSourceSpanFromNode(node), }; } else { directiveNode = new DirectiveIntermediateNode() { DirectiveName = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor.Directive, Directive = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor, Source = BuildSourceSpanFromNode(node), }; } for (var i = 0; i < removeTagHelperChunkGenerator.Diagnostics.Count; i++) { directiveNode.Diagnostics.Add(removeTagHelperChunkGenerator.Diagnostics[i]); } _builder.Push(directiveNode); _builder.Add(new DirectiveTokenIntermediateNode() { Content = removeTagHelperChunkGenerator.LookupText, DirectiveToken = CSharpCodeParser.RemoveTagHelperDirectiveDescriptor.Tokens.First(), Source = BuildSourceSpanFromNode(node), }); _builder.Pop(); } else if (context.ChunkGenerator is TagHelperPrefixDirectiveChunkGenerator tagHelperPrefixChunkGenerator) { IntermediateNode directiveNode; if (IsMalformed(tagHelperPrefixChunkGenerator.Diagnostics)) { directiveNode = new MalformedDirectiveIntermediateNode() { DirectiveName = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor.Directive, Directive = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor, Source = BuildSourceSpanFromNode(node), }; } else { directiveNode = new DirectiveIntermediateNode() { DirectiveName = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor.Directive, Directive = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor, Source = BuildSourceSpanFromNode(node), }; } for (var i = 0; i < tagHelperPrefixChunkGenerator.Diagnostics.Count; i++) { directiveNode.Diagnostics.Add(tagHelperPrefixChunkGenerator.Diagnostics[i]); } _builder.Push(directiveNode); _builder.Add(new DirectiveTokenIntermediateNode() { Content = tagHelperPrefixChunkGenerator.Prefix, DirectiveToken = CSharpCodeParser.TagHelperPrefixDirectiveDescriptor.Tokens.First(), Source = BuildSourceSpanFromNode(node), }); _builder.Pop(); } base.VisitCSharpStatementLiteral(node); }