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


C# Span.IntersectsWith方法代码示例

本文整理汇总了C#中Span.IntersectsWith方法的典型用法代码示例。如果您正苦于以下问题:C# Span.IntersectsWith方法的具体用法?C# Span.IntersectsWith怎么用?C# Span.IntersectsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Span的用法示例。


在下文中一共展示了Span.IntersectsWith方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTokenSpans

        public static List<SyntaxClassifier.SpanInfo> GetTokenSpans(ClassificationParseResult parseResult, Span span)
        {
            var tokenSpans = new List<SyntaxClassifier.SpanInfo>(16);

              foreach (var c in parseResult.Comments)
              {
            if (c.Position > span.End)
              break;

            var commentSpan = new Span(c.Position, c.Length);
            if (span.IntersectsWith(commentSpan))
            {
              InsertClassification(tokenSpans, new SyntaxClassifier.SpanInfo(commentSpan, c.IsMultiline ? SyntaxClassifier.SpanType.MultiLineComment : SyntaxClassifier.SpanType.SingleLineComment));
              if (c.Type != CommentType.Normal)
              {
            var textSpan = new Span(c.TextPosition, c.TextLength);
            SyntaxClassifier.SpanType spanType;
            switch (c.Type)
            {
              case CommentType.ToDo: spanType = SyntaxClassifier.SpanType.ToDoCommentText; break;
              case CommentType.Bug: spanType = SyntaxClassifier.SpanType.BugCommentText; break;
              case CommentType.Hack: spanType = SyntaxClassifier.SpanType.HackCommentText; break;
              default: spanType = default(SyntaxClassifier.SpanType); Trace.Assert(false); break;
            }
            InsertClassification(tokenSpans, new SyntaxClassifier.SpanInfo(textSpan, spanType));
              }
            }
              }

              foreach (var d in parseResult.Directives)
              {
            if (d.Position > span.End)
              break;

            var directiveSpan = new Span(d.Position, d.Length);
            if (span.IntersectsWith(directiveSpan))
              InsertClassification(tokenSpans, new SyntaxClassifier.SpanInfo(directiveSpan, SyntaxClassifier.SpanType.PreprocessorKeyword));
              }

              List<Span> splices = null; // not used
              WalkTokens(parseResult.Tokens, parseResult.Snapshot, span, tokenSpans, false, ref splices);

              return tokenSpans;
        }
开发者ID:vestild,项目名称:nemerle,代码行数:44,代码来源:ParseUtil.cs

示例2: WalkToken

        public static Token WalkToken(Span chunkSpan, Token token, ITextSnapshot textSnapshot, Span span, List<SyntaxClassifier.SpanInfo> classifications, bool isQuotation, ref List<Span> splices)
        {
            Token.Operator spliceOp2;
              Token spliceToken;

              if (isQuotation && IsSpliceSequence(token, out spliceToken))
              {
            var spliceOp1Span = Utils.NLocationToSpan(textSnapshot, token.Location);
            if (span.IntersectsWith(spliceOp1Span))
              classifications.Add(new SyntaxClassifier.SpanInfo(spliceOp1Span, SyntaxClassifier.SpanType.Operator));

            if (splices == null)
              splices = new List<Span>();
            splices.Add(chunkSpan);

            var spliceSpan = Utils.NLocationToSpan(textSnapshot, spliceToken.Location);
            if (span.IntersectsWith(spliceSpan))
            {
              List<Span> innerSplices = null; // not used
              return WalkToken(spliceSpan, spliceToken, textSnapshot, span, classifications, false, ref innerSplices);
            }
            else
              return spliceToken.Next;
              }
              else if (isQuotation && IsSpliceListSequence(token, out spliceOp2, out spliceToken))
              {
            var spliceOp1Span = Utils.NLocationToSpan(textSnapshot, token.Location);
            if (span.IntersectsWith(spliceOp1Span))
              classifications.Add(new SyntaxClassifier.SpanInfo(spliceOp1Span, SyntaxClassifier.SpanType.Operator));

            var spliceOp2Span = Utils.NLocationToSpan(textSnapshot, spliceOp2.Location);
            if (span.IntersectsWith(spliceOp2Span))
              classifications.Add(new SyntaxClassifier.SpanInfo(spliceOp2Span, SyntaxClassifier.SpanType.Operator));

            if (splices == null)
              splices = new List<Span>();
            splices.Add(chunkSpan);

            var spliceSpan = Utils.NLocationToSpan(textSnapshot, spliceToken.Location);
            if (span.IntersectsWith(spliceSpan))
            {
              List<Span> innerSplices = null; // not used
              return WalkToken(spliceSpan, spliceToken, textSnapshot, span, classifications, false, ref innerSplices);
            }
            else
              return spliceToken.Next;
              }
              else if (token is Token.Identifier
            || token is Token.IdentifierToComplete
            || token is Token.QuotedIdentifier)
              {
            classifications.Add(new SyntaxClassifier.SpanInfo(chunkSpan, SyntaxClassifier.SpanType.Identifier));
              }
              else if (token is Token.Operator
            || token is Token.Semicolon
            || token is Token.Comma)
              {
            classifications.Add(new SyntaxClassifier.SpanInfo(chunkSpan, SyntaxClassifier.SpanType.Operator));
              }
              else if (token is Token.LooseGroup)
              {
            var group = (Token.LooseGroup)token;
            WalkTokens(group.Child, textSnapshot, span, classifications, isQuotation, ref splices);
              }
              else if (token is Token.RoundGroup)
              {
            var group = (Token.RoundGroup)token;
            if (group.OpenBrace != null)
            {
              var braceSpan = Utils.NLocationToSpan(textSnapshot, group.OpenBrace.Location);
              if (span.IntersectsWith(braceSpan))
            classifications.Add(new SyntaxClassifier.SpanInfo(braceSpan, SyntaxClassifier.SpanType.Brace));
            }
            WalkTokens(group.Child, textSnapshot, span, classifications, isQuotation, ref splices);
            if (group.CloseBrace != null)
            {
              var braceSpan = Utils.NLocationToSpan(textSnapshot, group.CloseBrace.Location);
              if (span.IntersectsWith(braceSpan))
            classifications.Add(new SyntaxClassifier.SpanInfo(braceSpan, SyntaxClassifier.SpanType.Brace));
            }
              }
              else if (token is Token.SquareGroup)
              {
            var group = (Token.SquareGroup)token;
            if (group.OpenBrace != null)
            {
              var braceSpan = Utils.NLocationToSpan(textSnapshot, group.OpenBrace.Location);
              if (span.IntersectsWith(braceSpan))
            classifications.Add(new SyntaxClassifier.SpanInfo(braceSpan, SyntaxClassifier.SpanType.Brace));
            }
            WalkTokens(group.Child, textSnapshot, span, classifications, isQuotation, ref splices);
            if (group.CloseBrace != null)
            {
              var braceSpan = Utils.NLocationToSpan(textSnapshot, group.CloseBrace.Location);
              if (span.IntersectsWith(braceSpan))
            classifications.Add(new SyntaxClassifier.SpanInfo(braceSpan, SyntaxClassifier.SpanType.Brace));
            }
              }
              else if (token is Token.BracesGroup)
              {
//.........这里部分代码省略.........
开发者ID:vestild,项目名称:nemerle,代码行数:101,代码来源:ParseUtil.cs

示例3: WalkTokens

        public static void WalkTokens(Token token, ITextSnapshot textSnapshot, Span span, List<SyntaxClassifier.SpanInfo> classifications, bool isQuotation, ref List<Span> splices)
        {
            while (token != null)
              {
            var chunkSpan = GetNextChunkSpan(token, textSnapshot, isQuotation);
            if (chunkSpan.Start > span.End)
              break;

            if (span.IntersectsWith(chunkSpan))
              token = WalkToken(chunkSpan, token, textSnapshot, span, classifications, isQuotation, ref splices);
            else
              token = token.Next;
              }
        }
开发者ID:vestild,项目名称:nemerle,代码行数:14,代码来源:ParseUtil.cs

示例4: ElementInSpan

        private static bool ElementInSpan(SnapshotSpan span, SnapshotSpan target, LexicalElement element)
        {

            var classificationSpan = new Span(span.Start.Position + element.StartCursor.Location,
                                            element.EndCursor.Location - element.StartCursor.Location);
            return classificationSpan.IntersectsWith(target);
        }
开发者ID:jkoritzinsky,项目名称:Kerbal-Space-Program-For-Visual-Studio,代码行数:7,代码来源:Classifier.cs


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