public RenderChildrenVisitor(CodeRenderingContext context)
 {
     _context = context;
 }
Пример #2
0
 public abstract void EndWriterScope(CodeRenderingContext context);
Пример #3
0
 public abstract void WriteUsingDirective(CodeRenderingContext context, UsingDirectiveIntermediateNode node);
Пример #4
0
 public abstract void WriteCSharpCodeAttributeValue(CodeRenderingContext context, CSharpCodeAttributeValueIntermediateNode node);
Пример #5
0
 public abstract void BeginWriterScope(CodeRenderingContext context, string writer);
Пример #6
0
 public abstract void WriteHtmlContent(CodeRenderingContext context, HtmlContentIntermediateNode node);
Пример #7
0
 public abstract void WriteHtmlAttributeValue(CodeRenderingContext context, HtmlAttributeValueIntermediateNode node);
Пример #8
0
 public override void WriteNode(CodeTarget target, CodeRenderingContext context)
 {
     throw new NotImplementedException();
 }
Пример #9
0
 public abstract void WriteCSharpExpression(CodeRenderingContext context, CSharpExpressionIntermediateNode node);
        public static CodeWriter WritePadding(this CodeWriter writer, int offset, SourceSpan?span, CodeRenderingContext context)
        {
            if (span == null)
            {
                return(writer);
            }

            var basePadding     = CalculatePadding();
            var resolvedPadding = Math.Max(basePadding - offset, 0);

            if (context.Options.IndentWithTabs)
            {
                // Avoid writing directly to the StringBuilder here, that will throw off the manual indexing
                // done by the base class.
                var tabs = resolvedPadding / context.Options.IndentSize;
                for (var i = 0; i < tabs; i++)
                {
                    writer.Write("\t");
                }

                var spaces = resolvedPadding % context.Options.IndentSize;
                for (var i = 0; i < spaces; i++)
                {
                    writer.Write(" ");
                }
            }
            else
            {
                for (var i = 0; i < resolvedPadding; i++)
                {
                    writer.Write(" ");
                }
            }

            return(writer);

            int CalculatePadding()
            {
                var spaceCount = 0;

                for (var i = span.Value.AbsoluteIndex - 1; i >= 0; i--)
                {
                    var @char = context.SourceDocument[i];
                    if (@char == '\n' || @char == '\r')
                    {
                        break;
                    }
                    else if (@char == '\t')
                    {
                        spaceCount += context.Options.IndentSize;
                    }
                    else
                    {
                        spaceCount++;
                    }
                }

                return(spaceCount);
            }
        }
        public static IDisposable BuildLinePragma(this CodeWriter writer, SourceSpan?span, CodeRenderingContext context)
        {
            if (string.IsNullOrEmpty(span?.FilePath))
            {
                // Can't build a valid line pragma without a file path.
                return(NullDisposable.Default);
            }

            return(new LinePragmaWriter(writer, span.Value, context.Options));
        }
Пример #12
0
 public override void WriteNode(CodeTarget target, CodeRenderingContext context)
 {
     context.CodeWriter.WriteLine("MyExtensionNode");
 }
 public virtual void WriteSetKey(CodeRenderingContext context, SetKeyIntermediateNode node)
 {
     throw new NotSupportedException("This writer does not support components.");
 }
 public virtual void WriteReferenceCapture(CodeRenderingContext context, ReferenceCaptureIntermediateNode node)
 {
     throw new NotSupportedException("This writer does not support components.");
 }
 public virtual void WriteComponentTypeInferenceMethod(CodeRenderingContext context, ComponentTypeInferenceMethodIntermediateNode node)
 {
     throw new NotSupportedException("This writer does not support components.");
 }
Пример #16
0
        public static CodeWriter WritePadding(this CodeWriter writer, int offset, SourceSpan?span, CodeRenderingContext context)
        {
            if (span == null)
            {
                return(writer);
            }

            if (context.SourceDocument.FilePath != null &&
                !string.Equals(context.SourceDocument.FilePath, span.Value.FilePath, StringComparison.OrdinalIgnoreCase))
            {
                // We don't want to generate padding for nodes from imports.
                return(writer);
            }

            var basePadding     = CalculatePadding();
            var resolvedPadding = Math.Max(basePadding - offset, 0);

            writer.Indent(resolvedPadding);

            return(writer);

            int CalculatePadding()
            {
                var spaceCount = 0;

                for (var i = span.Value.AbsoluteIndex - 1; i >= 0; i--)
                {
                    var @char = context.SourceDocument[i];
                    if (@char == '\n' || @char == '\r')
                    {
                        break;
                    }
                    else if (@char == '\t')
                    {
                        spaceCount += writer.TabSize;
                    }
                    else
                    {
                        spaceCount++;
                    }
                }

                return(spaceCount);
            }
        }