/// <summary> /// コメントのあとの意図的なスペースをコメントにくっつける /// </summary> /// <param name="node"></param> /// <returns></returns> //public override bool Transform(WhiteSpace node) //{ // if (node.BeforeNode.GetType() == typeof (MultiLineComment)) // { // if (!_deleteComment) // { // node.BeforeNode.Value += node.OriginalValue; // } // } // return base.Transform(node); //} private string TransformComment(MultiLineComment node) { if (_deleteComment) { return(string.Empty); } StringBuilder sb = new StringBuilder(); if (node.BeforeNode.GetType() == typeof(WhiteSpace)) { // コメントの前の意図的なインデントや空白を残す sb.Append(node.BeforeNode.Value); } sb.Append(node.Value); if (node.AfterNode.GetType() == typeof(WhiteSpace)) { string value = node.AfterNode.Value; int lineSeparateIdx = value.IndexOf("\n", StringComparison.Ordinal); if (lineSeparateIdx >= 0) { // 改行以降は意図的なものがほとんど考えられないため対象外 value = value.Substring(0, lineSeparateIdx + 1); } sb.Append(value); } return(sb.ToString()); }
public EditLongComment(Asm65.Formatter formatter) { InitializeComponent(); mFormatter = formatter; LongComment = new MultiLineComment(string.Empty); }
public EditNote(Window owner, MultiLineComment note) { InitializeComponent(); Owner = owner; DataContext = this; if (note == null) { Note = new MultiLineComment(string.Empty); } else { Note = note; } mColorButtons = new RadioButton[] { colorDefaultRadio, colorGreenRadio, colorBlueRadio, colorYellowRadio, colorPinkRadio, colorOrangeRadio }; Debug.Assert(mColorButtons.Length == sColors.Length); }
private void Window_Closing(object sender, CancelEventArgs e) { if (DialogResult != true) { Debug.WriteLine("Skip it"); return; } if (string.IsNullOrEmpty(UserInput)) { Note = null; } else { Color bkgndColor = Colors.Fuchsia; for (int i = 0; i < mColorButtons.Length; i++) { if (mColorButtons[i].IsChecked == true) { bkgndColor = sColors[i]; break; } } Note = new MultiLineComment(UserInput, bkgndColor); } }
/// <summary> /// Formats entryTextBox.Text into displayTextBox.Text. /// </summary> private void FormatInput() { if (!IsLoaded) { return; } MultiLineComment mlc = CreateMLC(); if (mlc == null) { return; } List <string> lines = mlc.FormatText(mFormatter, string.Empty); StringBuilder sb = new StringBuilder(UserInput.Length + lines.Count * 2); //sb.AppendFormat("### got {0} lines\r\n", lines.Count); bool first = true; foreach (string line in lines) { if (first) { first = false; } else { sb.Append("\r\n"); } sb.Append(line); } TextOutput = sb.ToString(); }
public EditLongComment(Window owner, Asm65.Formatter formatter) { InitializeComponent(); Owner = owner; DataContext = this; mFormatter = formatter; LongComment = new MultiLineComment(string.Empty); }
private void EditLongComment_FormClosing(object sender, FormClosingEventArgs e) { if (string.IsNullOrEmpty(entryTextBox.Text)) { LongComment = null; } else { LongComment = CreateMLC(); } }
public void TestMultiLineCommentWithMultipleLines(string input, string expected) { using (var source = new TextReaderSource(new StringReader(input), true)) { var reader = source.CreateReader(); Assert.IsNotNull(reader); var foundStart = false; var content = new StringBuilder(); var writer = new StringWriter(content) { NewLine = "\n", }; var rangeSearcher = new MultiLineComment(); while (reader != null) { if (!foundStart) { var startIndex = rangeSearcher.FindStartCode(reader); if (startIndex == -1) { reader = reader.Advance(reader.Length); continue; } foundStart = true; reader = reader.Advance(startIndex + rangeSearcher.StartCodeLength); Assert.IsNotNull(reader); } var endInfo = rangeSearcher.FindEndCode(reader); if (endInfo == null) { writer.WriteLine(reader.ReadString(reader.Length)); reader = reader.Advance(reader.Length); continue; } var contentLength = endInfo.Index - reader.Index; writer.Write(reader.ReadString(contentLength)); reader = reader.Advance(contentLength + rangeSearcher.EndCodeLength); foundStart = false; } Assert.IsFalse(foundStart); Assert.AreEqual(expected, content.ToString()); } }
private void EditNote_FormClosing(object sender, FormClosingEventArgs e) { if (string.IsNullOrEmpty(noteTextBox.Text)) { Note = null; } else { Color bkgndColor = Color.Fuchsia; for (int i = 0; i < mColorButtons.Length; i++) { if (mColorButtons[i].Checked) { bkgndColor = sColors[i]; break; } } Note = new MultiLineComment(noteTextBox.Text, bkgndColor); } }
private void Window_Closing(object sender, CancelEventArgs e) { if (DialogResult != true) { return; } if (string.IsNullOrEmpty(UserInput)) { Note = null; } else { Color bkgndColor = Colors.Fuchsia; // make it obvious if we screw up if (IsCustomChecked) { if (Validation.GetHasError(customColorBox)) { bkgndColor = Helper.ZeroColor; } else { bkgndColor = mCustomColor; } } else { for (int i = 0; i < mColorButtons.Length; i++) { if (mColorButtons[i].IsChecked == true) { bkgndColor = sColors[i]; break; } } } Note = new MultiLineComment(UserInput, bkgndColor); } }
public void TestMultiLineCommentWithSingleLine(string input, string expected) { var source = new TextReaderSource(new StringReader(input)); var reader = source.CreateReader(); Assert.IsNotNull(reader); var rangeSearcher = new MultiLineComment(); var startIndex = rangeSearcher.FindStartCode(reader); Assert.AreNotEqual(-1, startIndex); reader = reader.Advance(startIndex + rangeSearcher.StartCodeLength); Assert.IsNotNull(reader); var endInfo = rangeSearcher.FindEndCode(reader); Assert.IsNotNull(endInfo); Assert.IsFalse(endInfo.IsNestedStart); var endIndex = endInfo.Index; var result = reader.ReadString(endIndex - reader.Index); Assert.AreEqual(expected, result); }
public virtual bool Transform(MultiLineComment node) { return(true); }
public EditNote() { InitializeComponent(); Note = new MultiLineComment(string.Empty); }
public static MultiLineComment StartMultiLineComment(this IndentedTextWriter @this, string openingLine = null) { return(MultiLineComment.Start(@this)); }
public virtual bool Visit(MultiLineComment node) { return(true); }
public override bool Transform(MultiLineComment node) { node.Value = TransformComment(node); return(base.Transform(node)); }
public override bool Visit(MultiLineComment node) { AddResultSql(node.Value); return(base.Visit(node)); }