static void ConvertVerbatimStringToNormal(ITextDocument textEditorData, int offset) { var endOffset = offset; while (endOffset < textEditorData.Length) { char ch = textEditorData.GetCharAt(endOffset); if (ch == '"' && (endOffset + 1 < textEditorData.Length && textEditorData.GetCharAt(endOffset + 1) == '"')) { endOffset += 2; continue; } if (ch == '"') { break; } endOffset++; } var plainText = TextPasteUtils.VerbatimStringStrategy.Decode(textEditorData.GetTextAt(offset, endOffset - offset)); var newText = TextPasteUtils.StringLiteralPasteStrategy.Instance.Encode(plainText); textEditorData.ReplaceText(offset, endOffset - offset, newText); }
static void ConvertNormalToVerbatimString(ITextDocument textEditorData, int offset) { var endOffset = offset; while (endOffset < textEditorData.Length) { char ch = textEditorData.GetCharAt(endOffset); if (ch == '\\') { if (endOffset + 1 < textEditorData.Length && NewLine.IsNewLine(textEditorData.GetCharAt(endOffset + 1))) { return; } endOffset += 2; continue; } if (ch == '"') { break; } if (NewLine.IsNewLine(ch)) { return; } endOffset++; } if (offset > endOffset || endOffset == textEditorData.Length) { return; } var plainText = CSharpTextPasteHandler.TextPasteUtils.StringLiteralPasteStrategy.Instance.Decode(textEditorData.GetTextAt(offset, endOffset - offset)); var newText = CSharpTextPasteHandler.TextPasteUtils.VerbatimStringStrategy.Encode(plainText); textEditorData.ReplaceText(offset, endOffset - offset, newText); }
static void ConvertVerbatimStringToNormal (ITextDocument textEditorData, int offset) { var endOffset = offset; while (endOffset < textEditorData.Length) { char ch = textEditorData.GetCharAt (endOffset); if (ch == '"' && (endOffset + 1 < textEditorData.Length && textEditorData.GetCharAt (endOffset + 1) == '"')) { endOffset += 2; continue; } if (ch == '"') { break; } endOffset++; } var plainText = TextPasteUtils.VerbatimStringStrategy.Decode (textEditorData.GetTextAt (offset, endOffset - offset)); var newText = TextPasteUtils.StringLiteralPasteStrategy.Instance.Encode (plainText); textEditorData.ReplaceText (offset, endOffset - offset, newText); }
static void ConvertNormalToVerbatimString (ITextDocument textEditorData, int offset) { var endOffset = offset; while (endOffset < textEditorData.Length) { char ch = textEditorData.GetCharAt (endOffset); if (ch == '\\') { if (endOffset + 1 < textEditorData.Length && NewLine.IsNewLine (textEditorData.GetCharAt (endOffset + 1))) return; endOffset += 2; continue; } if (ch == '"') break; if (NewLine.IsNewLine (ch)) return; endOffset++; } if (offset > endOffset || endOffset == textEditorData.Length) return; var plainText = TextPasteUtils.StringLiteralPasteStrategy.Instance.Decode (textEditorData.GetTextAt (offset, endOffset - offset)); var newText = TextPasteUtils.VerbatimStringStrategy.Encode (plainText); textEditorData.ReplaceText (offset, endOffset - offset, newText); }
static string GetSearchResultItemText(SearchResult result) { ITextDocument document = TextFileProvider.Instance.GetTextEditorData(result.FileName); return(document.GetTextAt(result.Offset, result.Length)); }