Exemple #1
0
 public XAMLCompletionSource(XAMLCompletionSourceProvider provider, ITextBuffer buffer)
 {
     _provider   = provider;
     _buffer     = buffer;
     _fileName   = buffer.GetXAMLFile();
     _file       = buffer.GetFile();
     package     = XSharpProjectPackage.Instance;
     optionsPage = package.GetIntellisenseOptionsPage();
 }
Exemple #2
0
        public override int CreateEditorInstance(
            uint grfCreateDoc,
            string pszMkDocument,
            string pszPhysicalView,
            IVsHierarchy pvHier,
            uint itemid,
            System.IntPtr punkDocDataExisting,
            out System.IntPtr ppunkDocView,
            out System.IntPtr ppunkDocData,
            out string pbstrEditorCaption,
            out Guid pguidCmdUI,
            out int pgrfCDW)
        {
            if (CalledFromVulcanDLL())
            {
                IVsEditorFactory factory = GetVulcanFactory("VulcanVSPackage.VOMenuEditorFactory", pszMkDocument) as IVsEditorFactory;
                if (factory != null)
                {
                    return(factory.CreateEditorInstance(grfCreateDoc, pszMkDocument, pszPhysicalView, pvHier, itemid, punkDocDataExisting,
                                                        out ppunkDocView, out ppunkDocData, out pbstrEditorCaption, out pguidCmdUI, out pgrfCDW));
                }
            }
            // Initialize to null
            ppunkDocView       = IntPtr.Zero;
            ppunkDocData       = IntPtr.Zero;
            pguidCmdUI         = GuidStrings.guidVOMenuEditorFactory;
            pgrfCDW            = 0;
            pbstrEditorCaption = null;

            // Validate inputs
            if ((grfCreateDoc & (VSConstants.CEF_OPENFILE | VSConstants.CEF_SILENT)) == 0)
            {
                return(VSConstants.E_INVALIDARG);
            }
            if (punkDocDataExisting != IntPtr.Zero)
            {
                return(VSConstants.VS_E_INCOMPATIBLEDOCDATA);
            }

            // Create the Document (editor)
            var editor = new VOMenuEditorPane(editorPackage);

            ppunkDocView       = Marshal.GetIUnknownForObject(editor);
            ppunkDocData       = Marshal.GetIUnknownForObject(editor);
            pbstrEditorCaption = "";
            XSharpModel.XFile file = XSharpModel.XSolution.FindFile(pszMkDocument);
            if (file != null)
            {
                editor.Project = file.Project.ProjectNode;
            }
            return(VSConstants.S_OK);
        }
 public XSharpPeekItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
     _file = textBuffer.GetFile();
 }
Exemple #4
0
 public XSharpQuickInfoSource(XSharpQuickInfoSourceProvider provider, ITextBuffer subjectBuffer)
 {
     _provider      = provider;
     _subjectBuffer = subjectBuffer;
     _file          = _subjectBuffer.GetFile();
 }
Exemple #5
0
        private void OnSelectionChanged(object sender, object e)
        {
            try
            {
                String selectedText = this.View.Selection.StreamSelectionSpan.GetText();
                if (!string.IsNullOrEmpty(selectedText) && !string.IsNullOrWhiteSpace(selectedText))
                {
                    // where are we
                    SnapshotPoint       currentRequest = this.View.Selection.Start.Position;
                    List <SnapshotSpan> wordSpans      = new List <SnapshotSpan>();
                    // Search for me please
                    TextExtent word      = TextStructureNavigator.GetExtentOfWord(currentRequest);
                    bool       foundWord = true;
                    //
                    if (!WordExtentIsValid(currentRequest, word))
                    {
                        //Same context ?
                        if (word.Span.Start != currentRequest ||
                            currentRequest == currentRequest.GetContainingLine().Start ||
                            char.IsWhiteSpace((currentRequest - 1).GetChar()))
                        {
                            foundWord = false;
                        }
                        else
                        {
                            // Move back, and start again
                            word = TextStructureNavigator.GetExtentOfWord(currentRequest - 1);

                            //If the word still isn't valid, we're done
                            if (!WordExtentIsValid(currentRequest, word))
                            {
                                foundWord = false;
                            }
                        }
                    }

                    if (!foundWord)
                    {
                        //If we couldn't find a word, clear out the existing markers
                        SynchronousUpdate(new NormalizedSnapshotSpanCollection());
                        return;
                    }
                    SnapshotSpan currentWord = word.Span;
                    selectedWord = this.View.Selection.StreamSelectionSpan.SnapshotSpan;


                    //If this is the current word, and the caret moved within a word, we're done.
                    if (!(selectedWord.HasValue && currentWord == selectedWord))
                    {
                        return;
                    }
                    //Find the new spans
                    FindData findData = new FindData(currentWord.GetText(), currentWord.Snapshot);
                    findData.FindOptions = FindOptions.WholeWord | FindOptions.MatchCase;
                    // Values are zero-based
                    SnapshotPoint point = View.Caret.Position.BufferPosition;
                    // Retrieve the XFile
                    XSharpModel.XFile xFile = this.View.TextBuffer.GetFile();
                    if (xFile != null)
                    {
                        // Now, retrieve the current member
                        XSharpModel.XTypeMember member = XSharpTokenTools.FindMemberAtPosition(point.Position, xFile);
                        if (member == null)
                        {
                            return;
                        }
                        // Ok, so we now have the "range" of the Member, and will only select text in THIS member
                        SnapshotSpan memberSpan = new SnapshotSpan(currentWord.Snapshot, member.Interval.Start, member.Interval.Width);
                        // Get all the corresponding Words
                        Collection <SnapshotSpan> allFound    = TextSearchService.FindAll(findData);
                        Collection <SnapshotSpan> memberFound = new Collection <SnapshotSpan>();
                        foreach (SnapshotSpan ssp in allFound)
                        {
                            // Inside the Member ?
                            if (memberSpan.Contains(ssp))
                            {
                                memberFound.Add(ssp);
                            }
                        }
                        //
                        wordSpans.AddRange(memberFound);
                        // Show please
                        SynchronousUpdate(new NormalizedSnapshotSpanCollection(wordSpans));
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("HighlightWordTag Exception: " + ex.Message);
            }
        }