コード例 #1
0
        public IEnumerable <IMappingTagSpan <T> > GetTags(SnapshotSpan span)
        {
            foreach (var tagSpan in _tagger.GetTags(new NormalizedSnapshotSpanCollection(span.Snapshot, new Span[] { span })))
            {
                var mappingSpan = VsxStubObjects.CreateObject <IMappingSpan>("Microsoft.VisualStudio.Text.Utilities.MappingSpanSnapshot, Microsoft.VisualStudio.Platform.VSEditor", span.Snapshot, tagSpan.Span,
                                                                             SpanTrackingMode.EdgeExclusive, _bufferGraph);

                yield return(new MappingTagSpan <T>(mappingSpan, tagSpan.Tag));
            }
        }
コード例 #2
0
        public static ITextBuffer CreateTextBuffer(string content)
        {
            VsxStubObjects.Initialize();

            var stringRebuilder = CallStaticMethod("Microsoft.VisualStudio.Text.Implementation.StringRebuilder, Microsoft.VisualStudio.Platform.VSEditor",
                                                   "Create", content);
            var contentTypeImpl = CreateInstance(
                "Microsoft.VisualStudio.Utilities.Implementation.ContentTypeImpl, Microsoft.VisualStudio.Platform.VSEditor",
                "deveroom", null, null);
            var defaultTextDifferencingService = CreateInstance(
                "Microsoft.VisualStudio.Text.Differencing.Implementation.DefaultTextDifferencingService, Microsoft.VisualStudio.Platform.VSEditor");
            var textBuffer = CreateInstance(
                "Microsoft.VisualStudio.Text.Implementation.TextBuffer, Microsoft.VisualStudio.Platform.VSEditor",
                contentTypeImpl, stringRebuilder, defaultTextDifferencingService, GuardedOperations);

            return((ITextBuffer)textBuffer);
        }
コード例 #3
0
        public static StubWpfTextView CreateTextView(StubIdeScope ideScope, TestText inputText, string newLine = null, IProjectScope projectScope = null, string contentType = "deveroom", string filePath = null)
        {
            var textBuffer = VsxStubObjects.CreateTextBuffer(inputText.ToString(newLine));

            textBuffer.Properties.AddProperty(typeof(IProjectScope), projectScope);
            if (filePath != null)
            {
                textBuffer.Properties.AddProperty(typeof(IVsTextBuffer), new FilePathProvider(filePath));
            }
            var textView = new StubWpfTextView(textBuffer);

            if (contentType == "deveroom")
            {
                var tagAggregator = new StubBufferTagAggregatorFactoryService(ideScope).CreateTagAggregator <DeveroomTag>(textView.TextBuffer);
                tagAggregator.GetTags(new SnapshotSpan(textView.TextSnapshot, 0, textView.TextSnapshot.Length)).ToArray();
            }

            inputText.SetSelection(textView);
            inputText.SetCaret(textView);

            return(textView);
        }