Esempio n. 1
0
#pragma warning restore 67

        public IList <ClassificationSpan> GetClassificationSpans(SnapshotSpan span)
        {
            PreCondition.AssertNotNull(span, nameof(span));

            ITextSnapshot textSnapshot      = span.Snapshot;
            ITextBuffer   textBuffer        = textSnapshot.TextBuffer;
            ITextVersion  textVersion       = textSnapshot.Version;
            int           textVersionNumber = textVersion.VersionNumber;

            if (!this.textSnapshotClassifications.TryGet(textBuffer, textVersionNumber, out IReadOnlyList <ClassificationSpan> classificationSpans))
            {
                PkgdefDocument parsedDocument = PkgdefDocument.Parse(textSnapshot.GetText());

                List <ClassificationSpan> spans = new List <ClassificationSpan>();
                foreach (PkgdefSegment segment in parsedDocument.GetSegments())
                {
                    switch (segment.GetSegmentType())
                    {
                    case PkgdefSegmentType.LineComment:
                        spans.Add(PkgdefClassifier.CreateClassificationSpan(textSnapshot, segment, this.commentClassificationType));
                        break;

                    case PkgdefSegmentType.RegistryKeyPath:
                        spans.Add(PkgdefClassifier.CreateClassificationSpan(textSnapshot, segment, this.registryKeyRelativePathClassificationType));
                        break;

                    case PkgdefSegmentType.RegistryKeyDataItem:
                        PkgdefRegistryKeyDataItemSegment registryKeyDataItemSegment = (PkgdefRegistryKeyDataItemSegment)segment;
                        spans.Add(PkgdefClassifier.CreateClassificationSpan(textSnapshot, registryKeyDataItemSegment.GetNameSegment(), this.registryKeyDataItemNameClassificationType));
                        break;
                    }
                }
                classificationSpans = spans;
                this.textSnapshotClassifications.Set(textBuffer, textVersionNumber, classificationSpans);
            }

            return(classificationSpans
                   .Where((ClassificationSpan classificationSpan) => classificationSpan.Span.IntersectsWith(span.Span))
                   .ToList());
        }
Esempio n. 2
0
 public bool Equals(PkgdefRegistryKeyDataItemSegment rhs)
 {
     return(rhs != null &&
            this.tokens.SequenceEqual(rhs.tokens));
 }