本文整理汇总了C#中ITextSnapshotLine.GetFragment方法的典型用法代码示例。如果您正苦于以下问题:C# ITextSnapshotLine.GetFragment方法的具体用法?C# ITextSnapshotLine.GetFragment怎么用?C# ITextSnapshotLine.GetFragment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextSnapshotLine
的用法示例。
在下文中一共展示了ITextSnapshotLine.GetFragment方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckLine
public IEnumerable<TextLineCheckerError> CheckLine(ITextSnapshotLine line)
{
if (_chromiumSourceFiles.ApplyCodingStyle(_fileSystem, line)) {
int indent = 0;
var fragment = line.GetFragment(line.Start, line.End, TextLineFragment.Options.Default);
foreach (var point in fragment.GetPoints()) {
if (WhitespaceCharacters.IndexOf(point.GetChar()) >= 0) {
// continue as long as we find whitespaces
indent++;
} else if (GetMarker(line, fragment, point) != null) {
if (indent % 2 == 0) // even indentation is not ok
{
var marker = GetMarker(line, fragment, point);
yield return new TextLineCheckerError {
Span = new SnapshotSpan(point, marker.Length),
Message =
string.Format("Accessor \"{0}\" should always be indented 1 character less than rest of class body.",
marker)
};
}
} else {
// Stop at the first non-whitespace character.
yield break;
}
}
}
}
示例2: IsAllowedOverflow
private bool IsAllowedOverflow(ITextSnapshotLine line) {
var keywords = new string[] {
"#include",
"#define",
"#if",
"#endif",
};
var text =
line.GetFragment(line.Start.Position, line.Start.Position + 30, TextLineFragment.Options.Default)
.SnapshotSpan.GetText();
return keywords.Any(k => text.Contains(k));
}
示例3: CheckLine
public IEnumerable<TextLineCheckerError> CheckLine(ITextSnapshotLine line)
{
if (_chromiumSourceFiles.ApplyCodingStyle(line)) {
foreach (var point in line.GetFragment(line.Start, line.End, TextLineFragment.Options.Reverse).GetPoints()) {
if (_whitespaceCharacters.IndexOf(point.GetChar()) >= 0) {
yield return new TextLineCheckerError {
Span = new SnapshotSpan(point, point + 1),
Message = "Trailing whitespaces are not allowed.",
};
} else
yield break;
}
}
}
示例4: CheckLine
public IEnumerable<TextLineCheckerError> CheckLine(ITextSnapshotLine line)
{
if (_chromiumSourceFiles.ApplyCodingStyle(_fileSystem, line)) {
if (line.Length == 0) {
yield break;
}
foreach (var point in line.GetFragment(line.Start, line.End, TextLineFragment.Options.Default).GetPoints()) {
if (point.GetChar() == '\t') {
yield return new TextLineCheckerError {
Span = new SnapshotSpan(point, point + 1),
Message = "TAB characters are not allowed."
};
}
}
}
}
示例5: GetMarker
private string GetMarker(ITextSnapshotLine line, TextLineFragment fragment, SnapshotPoint point) {
string[] markers = {
"else",
"else if",
};
var match = markers
.Where(marker => fragment.GetText(point - line.Start, marker.Length) == marker)
.FirstOrDefault();
if (match != null) {
// If last character of line is not "{", we are good
var end = line.GetFragment(line.End.Position - 1, line.End.Position, TextLineFragment.Options.Default);
if (end.GetText() != "{")
return null;
}
return match;
}
示例6: CheckLine
public IEnumerable<TextLineCheckerError> CheckLine(ITextSnapshotLine line)
{
if (_chromiumSourceFiles.ApplyCodingStyle(_fileSystem, line)) {
var fragment = line.GetFragment(line.Start, line.End, TextLineFragment.Options.Default);
foreach (var point in fragment.GetPoints()) {
if (WhitespaceCharacters.IndexOf(point.GetChar()) >= 0) {
// continue as long as we find whitespaces
} else if (GetMarker(line, fragment, point) != null) {
var marker = GetMarker(line, fragment, point);
yield return new TextLineCheckerError {
Span = new SnapshotSpan(point, marker.Length),
Message = string.Format("Missing space before ( in \"{0}\".", marker)
};
} else {
// Stop at the first non-whitespace character.
yield break;
}
}
}
}