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


C# SnapshotSpan.OverlapsWith方法代码示例

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


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

示例1: GetClassificationSpans

        public IList<ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
        {
          if (span.Length == 0) return emptyClassification;
          // classifications are cached by textbuffer and invalidated as the version of the snapshot changes
          Tuple<int, FSharp.Collections.FSharpList<SyntaxHighlighting.Ast.Span>> cacheEntry;
          FSharp.Collections.FSharpList<SyntaxHighlighting.Ast.Span> cachedSpans;

          if (this.classificationCache.TryGetValue(span.Snapshot.TextBuffer, out cacheEntry) && cacheEntry.Item1 == span.Snapshot.Version.VersionNumber) {
            cachedSpans = cacheEntry.Item2;
          } else {
            // previously unknown or version changed
            try {
              cachedSpans = SyntaxHighlighting.Parser.Parse(span.Snapshot.GetText());
              this.classificationCache[span.Snapshot.TextBuffer] = Tuple.Create(span.Snapshot.Version.VersionNumber, cachedSpans);
            } catch {
              // errors in syntax highlighting should not bring down VS
              return emptyClassification;
            }
          }

          this.highlightedSpans[span.Snapshot.TextBuffer] = new SnapshotSpan(span.Snapshot, 0, span.Snapshot.Length);

          var options = VSPackagePackage.Instance.OptionPage;
          var kt = options.DimAnnotations ? this.dimmedKeywordType : this.keywordType;
          var st = options.DimAnnotations ? this.dimmedSpecType : this.specType;

          // return list of detected spans filtered to those that overlap the given span
          List<ClassificationSpan> result = new List<ClassificationSpan>();
          foreach (var pos in cachedSpans) {
            if (pos.IsSpec) {
              var spec = (SyntaxHighlighting.Ast.Span.Spec)pos;
              var specSpan = new Span(spec.Item1, spec.Item2);
              if (span.OverlapsWith(specSpan)) result.Add(new ClassificationSpan(new SnapshotSpan(span.Snapshot, specSpan), st));
            } else if (pos.IsKeyword) {
              var kw = (SyntaxHighlighting.Ast.Span.Keyword)pos;
              var kwSpan = new Span(kw.Item1, kw.Item2);
              if (span.OverlapsWith(kwSpan)) result.Add(new ClassificationSpan(new SnapshotSpan(span.Snapshot, kwSpan), kt));
            }
          }

          return result;
        }
开发者ID:edgar-pek,项目名称:VCDryad,代码行数:42,代码来源:VccClassifier.cs

示例2: RemoveMatchingAdornments

		public void RemoveMatchingAdornments(SnapshotSpan visualSpan, Predicate<IAdornmentLayerElement> match) {
			if (visualSpan.Snapshot == null)
				throw new ArgumentException();
			if (match == null)
				throw new ArgumentNullException(nameof(match));
			for (int i = adornmentLayerElements.Count - 1; i >= 0; i--) {
				var elem = adornmentLayerElements[i];
				if (elem.VisualSpan != null && visualSpan.OverlapsWith(GetOverlapsWithSpan(elem.VisualSpan.Value)) && match(elem)) {
					adornmentLayerElements.RemoveAt(i);
					Children.RemoveAt(i);
					elem.RemovedCallback?.Invoke(elem.Tag, elem.Adornment);
				}
			}
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:14,代码来源:AdornmentLayer.cs

示例3: Classify

        public IEnumerable<ClassificationSpan> Classify(SnapshotSpan span)
        {
            SnapshotSpan prefixSpan, commandSpan, argumentsSpan;
            var command = TryParseCommand(span.Snapshot.GetExtent(), out prefixSpan, out commandSpan, out argumentsSpan);
            if (command == null)
            {
                yield break;
            }

            if (span.OverlapsWith(prefixSpan))
            {
                yield return Classification(span.Snapshot, prefixSpan, _classificationRegistry.Keyword);
            }

            if (span.OverlapsWith(commandSpan))
            {
                yield return Classification(span.Snapshot, commandSpan, _classificationRegistry.Keyword);
            }

            if (argumentsSpan.Length > 0)
            {
                foreach (var classifiedSpan in command.ClassifyArguments(span.Snapshot, argumentsSpan.Span, span.Span))
                {
                    yield return classifiedSpan;
                }
            }
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:27,代码来源:InteractiveWindowCommands.cs

示例4: RemoveAdornmentsByVisualSpan

		public void RemoveAdornmentsByVisualSpan(SnapshotSpan visualSpan) {
			if (visualSpan.Snapshot == null)
				throw new ArgumentException();
			for (int i = adornmentLayerElements.Count - 1; i >= 0; i--) {
				var elem = adornmentLayerElements[i];
				if (elem.VisualSpan != null && visualSpan.OverlapsWith(GetOverlapsWithSpan(elem.VisualSpan.Value))) {
					adornmentLayerElements.RemoveAt(i);
					Children.RemoveAt(i);
					elem.RemovedCallback?.Invoke(elem.Tag, elem.Adornment);
				}
			}
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:12,代码来源:AdornmentLayer.cs


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