本文整理汇总了C#中VisualStudio.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# VisualStudio.Insert方法的具体用法?C# VisualStudio.Insert怎么用?C# VisualStudio.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisualStudio
的用法示例。
在下文中一共展示了VisualStudio.Insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteStatement
private static void DeleteStatement(VisualStudio.Text.ITextEdit edit, SourceSpan span, bool insertPass) {
// remove the entire node, leave any trailing whitespace/comments, but include the
// newline and any indentation.
int start = span.Start.Index;
int length = span.Length;
int cur = start - 1;
if (!insertPass) {
// backup to remove any indentation
while (start - 1 > 0) {
var curChar = edit.Snapshot.GetText(start - 1, 1);
if (curChar[0] == ' ' || curChar[0] == '\t' || curChar[0] == '\f') {
length++;
start--;
} else {
break;
}
}
}
// extend past any trailing whitespace characters
while (start + length < edit.Snapshot.Length) {
var curChar = edit.Snapshot.GetText(start + length, 1);
if (curChar[0] == ' ' || curChar[0] == '\t' || curChar[0] == '\f') {
length++;
} else {
break;
}
}
// remove the trailing newline as well.
if (!insertPass) {
if (start + length < edit.Snapshot.Length) {
var newlineText = edit.Snapshot.GetText(start + length, 1);
if (newlineText == "\r") {
if (start + length + 1 < edit.Snapshot.Length) {
newlineText = edit.Snapshot.GetText(start + length + 1, 1);
if (newlineText == "\n") {
length += 2;
} else {
length++;
}
} else {
length++;
}
} else if (newlineText == "\n") {
length++;
}
}
}
edit.Delete(start, length);
if (insertPass) {
edit.Insert(start, "pass");
}
}