Пример #1
0
        public void Replace(AstNode node, AstNode replaceWith)
        {
            var startOffset = Context.GetOffset(node.StartLocation);
            var endOffset   = Context.GetOffset(node.EndLocation);
            int level       = 0;

            if (!(replaceWith is Expression) && !(replaceWith is AstType))
            {
                level = GetIndentLevelAt(startOffset);
            }
            NodeOutput output = OutputNode(level, replaceWith);

            output.Trim();
            Queue(Context.CreateNodeOutputAction(startOffset, endOffset - startOffset, output));
        }
Пример #2
0
        protected NodeOutput OutputNode(int indentLevel, AstNode node, bool startWithNewLine = false)
        {
            var result       = new NodeOutput();
            var stringWriter = new StringWriter();
            var formatter    = new SegmentTrackingOutputFormatter(result, stringWriter);

            formatter.Indentation = indentLevel;
            stringWriter.NewLine  = Context.EolMarker;
            if (startWithNewLine)
            {
                formatter.NewLine();
            }
            var visitor = new CppOutputVisitor(formatter, Context.FormattingOptions);

            node.AcceptVisitor(visitor, null);
            result.Text = stringWriter.ToString().TrimEnd();
            if (node is FieldDeclaration)
            {
                result.Text += Context.EolMarker;
            }

            return(result);
        }
Пример #3
0
		public NodeOutputAction (int offset, int removedChars, NodeOutput output) : base (offset, removedChars)
		{
			if (output == null)
				throw new ArgumentNullException ("output");
			this.NodeOutput = output;
		}
Пример #4
0
 public SegmentTrackingOutputFormatter(NodeOutput result, StringWriter stringWriter)
     : base(stringWriter)
 {
     this.result       = result;
     this.stringWriter = stringWriter;
 }
Пример #5
0
		public virtual NodeOutputAction CreateNodeOutputAction (int offset, int removedChars, NodeOutput output)
		{
			throw new NotImplementedException ();
		}
Пример #6
0
 public virtual NodeOutputAction CreateNodeOutputAction(int offset, int removedChars, NodeOutput output)
 {
     throw new NotImplementedException();
 }
Пример #7
0
		protected NodeOutput OutputNode (int indentLevel, AstNode node, bool startWithNewLine = false)
		{
			var result = new NodeOutput ();
			var stringWriter = new StringWriter ();
			var formatter = new SegmentTrackingOutputFormatter (result, stringWriter);
			formatter.Indentation = indentLevel;
			stringWriter.NewLine = Context.EolMarker;
			if (startWithNewLine)
				formatter.NewLine ();
			var visitor = new CppOutputVisitor (formatter, Context.FormattingOptions);
			node.AcceptVisitor (visitor, null);
			result.Text = stringWriter.ToString ().TrimEnd ();
			if (node is FieldDeclaration)
				result.Text += Context.EolMarker;

			return result;
		}
Пример #8
0
			public SegmentTrackingOutputFormatter(NodeOutput result, StringWriter stringWriter)
				: base(stringWriter)
			{
				this.result = result;
				this.stringWriter = stringWriter;
			}