Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
		public NodeOutputAction (int offset, int removedChars, NodeOutput output) : base (offset, removedChars)
		{
			if (output == null)
				throw new ArgumentNullException ("output");
			this.NodeOutput = output;
		}
Ejemplo n.º 4
0
 public SegmentTrackingOutputFormatter(NodeOutput result, StringWriter stringWriter)
     : base(stringWriter)
 {
     this.result       = result;
     this.stringWriter = stringWriter;
 }
Ejemplo n.º 5
0
		public virtual NodeOutputAction CreateNodeOutputAction (int offset, int removedChars, NodeOutput output)
		{
			throw new NotImplementedException ();
		}
Ejemplo n.º 6
0
 public virtual NodeOutputAction CreateNodeOutputAction(int offset, int removedChars, NodeOutput output)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 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;
		}
Ejemplo n.º 8
0
			public SegmentTrackingOutputFormatter(NodeOutput result, StringWriter stringWriter)
				: base(stringWriter)
			{
				this.result = result;
				this.stringWriter = stringWriter;
			}