public static TagSpan <TextMarkerTag> MakeTagSpan(ITextSnapshot lastSnapshot, ITextSnapshot currentSnapshot, NSpan nSpan, string tagType)
        {
            var span           = new SnapshotSpan(lastSnapshot, VsUtils.Convert(nSpan));
            var translatedSpan = span.TranslateTo(currentSnapshot, SpanTrackingMode.EdgeExclusive);

            return(new TagSpan <TextMarkerTag>(translatedSpan, new TextMarkerTag(tagType)));
        }
Esempio n. 2
0
        void TextBuffer_Changed(object sender, TextContentChangedEventArgs e)
        {
            var textBuffer = (ITextBuffer)sender;
            var newVersion = e.AfterVersion.Convert();
            var changes    = e.Changes;

            if (newVersion != _caretPosition.Version)
            {
            }
            var fileModel = textBuffer.Properties.GetProperty <FileModel>(Constants.FileModelKey);
            var id        = fileModel.Id;

            if (changes.Count == 1)
            {
                Server.Client.Send(new ClientMessage.FileChanged(id, newVersion, VsUtils.Convert(changes[0]), _caretPosition));
            }
            else
            {
                var builder = ImmutableArray.CreateBuilder <FileChange>(changes.Count);

                foreach (var change in changes)
                {
                    builder.Add(VsUtils.Convert(change));
                }

                Server.Client.Send(new ClientMessage.FileChangedBatch(id, newVersion, builder.MoveToImmutable(), _caretPosition));
            }
        }
Esempio n. 3
0
        void ShowInFindResultWindow(FileModel fileModel, NSpan span, Location[] locations)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            CheckDisposed();

            if (locations.Length == 0)
            {
                return;
            }

            if (locations.Length == 1)
            {
                GoToLocation(fileModel, locations[0]);
                return;
            }

            var findSvc = (IVsFindSymbol)fileModel.Server.ServiceProvider.GetService(typeof(SVsObjectSearch));

            Debug.Assert(findSvc != null);

            var caption = _wpfTextView.TextBuffer.CurrentSnapshot.GetText(VsUtils.Convert(span));

            var libSearchResults = new LibraryNode("<Nitra>", LibraryNode.LibraryNodeType.References, LibraryNode.LibraryNodeCapabilities.None, null);

            foreach (var location in locations)
            {
                var inner = new GotoInfoLibraryNode(location, caption, fileModel.Server);
                libSearchResults.AddNode(inner);
            }

            var package = NitraCommonVsPackage.Instance;

            package.SetFindResult(libSearchResults);
            var criteria =
                new[]
            {
                new VSOBSEARCHCRITERIA2
                {
                    eSrchType  = VSOBSEARCHTYPE.SO_ENTIREWORD,
                    grfOptions = (uint)_VSOBSEARCHOPTIONS.VSOBSO_CASESENSITIVE,
                    szName     = "<dummy>",
                    dwCustom   = Library.FindAllReferencesMagicNum,
                }
            };

            var scope = Library.MagicGuid;
            var hr    = findSvc.DoSearch(ref scope, criteria);
        }
Esempio n. 4
0
        void ShowInFindResultWindow(FileModel fileModel, NSpan span, Location[] locations)
        {
            CheckDisposed();

            if (locations.Length == 1)
            {
                GoToLocation(fileModel, locations[0]);
                return;
            }

            var findSvc = (IVsObjectSearch)fileModel.Server.ServiceProvider.GetService(typeof(SVsObjectSearch));

            Debug.Assert(findSvc != null);

            var caption = _wpfTextView.TextBuffer.CurrentSnapshot.GetText(VsUtils.Convert(span));

            var libSearchResults = new LibraryNode("<Nitra>", LibraryNode.LibraryNodeType.References, LibraryNode.LibraryNodeCapabilities.None, null);

            foreach (var location in locations)
            {
                var inner = new GotoInfoLibraryNode(location, caption, fileModel.Server);
                libSearchResults.AddNode(inner);
            }

            var package = NitraCommonVsPackage.Instance;

            package.SetFindResult(libSearchResults);
            var criteria =
                new[]
            {
                new VSOBSEARCHCRITERIA
                {
                    eSrchType  = VSOBSEARCHTYPE.SO_ENTIREWORD,
                    grfOptions = (uint)_VSOBSEARCHOPTIONS.VSOBSO_CASESENSITIVE,
                    szName     = "<dummy>",
                    dwCustom   = Library.FindAllReferencesMagicNum,
                }
            };

            IVsObjectList results;
            var           hr = findSvc.Find((uint)__VSOBSEARCHFLAGS.VSOSF_EXPANDREFS, criteria, out results);
        }
        public static TagSpan <TextMarkerTag> MakeTagSpan(ITextSnapshot currentSnapshot, NSpan nSpan, string tagType)
        {
            var span = new SnapshotSpan(currentSnapshot, VsUtils.Convert(nSpan));

            return(new TagSpan <TextMarkerTag>(span, new TextMarkerTag(tagType)));
        }