当前位置: 首页>>代码示例>>C#>>正文


C# ITextSnapshotLine.GetFragment方法代码示例

本文整理汇总了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;
       }
     }
       }
 }
开发者ID:nick-chromium,项目名称:vs-chromium,代码行数:27,代码来源:AccessorIndentChecker.cs

示例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));
 }
开发者ID:mbbill,项目名称:vs-chromium,代码行数:12,代码来源:LongLineChecker.cs

示例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;
     }
       }
 }
开发者ID:,项目名称:,代码行数:14,代码来源:

示例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."
            };
              }
            }
              }
        }
开发者ID:nick-chromium,项目名称:vs-chromium,代码行数:17,代码来源:TabCharacterChecker.cs

示例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;
    }
开发者ID:mbbill,项目名称:vs-chromium,代码行数:17,代码来源:ElseIfOnNewLineChecker.cs

示例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;
       }
     }
       }
 }
开发者ID:nick-chromium,项目名称:vs-chromium,代码行数:20,代码来源:SpaceAfterForKeywordChecker.cs


注:本文中的ITextSnapshotLine.GetFragment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。