Beispiel #1
0
        private void GetFullWord(TextExtent currentSnapshot)
        {
            int start = currentSnapshot.Span.Start.Position;
            int end   = currentSnapshot.Span.End.Position;

            //  languageTextOps.GetWordExtent((IVsTextLayer)this._docData, ta, WORDEXTFLAGS.WORDEXT_FINDTOKEN, textSpans);
        }
        protected virtual void UpdateWordSelection()
        {
            SnapshotPoint currentRequest = RequestedPoint;
            var           wordSpans      = new List <SnapshotSpan>();

            TextExtent selectedWord = TextStructureNavigator.GetExtentOfWord(currentRequest);

            bool success = TryGetSelectedWord(currentRequest, ref selectedWord);

            if (!success)
            {
                UpdateSelectionState(currentRequest, new NormalizedSnapshotSpanCollection(), null);
                return;
            }

            SnapshotSpan selectedWordSpan = selectedWord.Span;

            if (CurrentWord.HasValue &&
                CurrentWord == selectedWordSpan)
            {
                return;
            }

            IEnumerable <SnapshotSpan> matches = FindAllMatches(selectedWordSpan);

            wordSpans.AddRange(matches);

            UpdateSelectionState(currentRequest, new NormalizedSnapshotSpanCollection(wordSpans), selectedWordSpan);
        }
        public static bool HasBadActions(FileCodeModel fcm, TextExtent word)
        {
            var ctl     = GetController(fcm);
            var methods = ctl.Members.OfType <CodeFunction>().ToList();

            return(false);
        }
Beispiel #4
0
        protected override bool Execute(VSConstants.VSStd97CmdID commandId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            SnapshotPoint?point = TextView.Caret.Position.Point.GetPoint(TextView.TextBuffer, PositionAffinity.Predecessor);

            if (point.HasValue)
            {
                TextExtent wordExtent = _navigator.GetExtentOfWord(point.Value - 1);
                string     wordText   = TextView.TextSnapshot.GetText(wordExtent.Span);

                Find2  find      = (Find2)EditorExtensionsPackage.DTE.Find;
                string types     = find.FilesOfType;
                bool   matchCase = find.MatchCase;
                bool   matchWord = find.MatchWholeWord;

                find.WaitForFindToComplete = false;
                find.Action            = EnvDTE.vsFindAction.vsFindActionFindAll;
                find.Backwards         = false;
                find.MatchInHiddenText = true;
                find.MatchWholeWord    = true;
                find.MatchCase         = true;
                find.PatternSyntax     = EnvDTE.vsFindPatternSyntax.vsFindPatternSyntaxLiteral;
                find.ResultsLocation   = EnvDTE.vsFindResultsLocation.vsFindResults1;
                find.SearchSubfolders  = true;
                find.FilesOfType       = "*.js";
                find.Target            = EnvDTE.vsFindTarget.vsFindTargetSolution;
                find.FindWhat          = wordText;
                find.Execute();

                find.FilesOfType    = types;
                find.MatchCase      = matchCase;
                find.MatchWholeWord = matchWord;
            }

            return(true);
        }
        private bool IsComment(TextExtent extent)
        {
            lock (_spanLock)
            {
                // Assume everything is a comment until we properly parse
                if (_commentSpans == null)
                {
                    return(true);
                }
                else
                {
                    foreach (var commentSpan in _commentSpans)
                    {
                        var translatedSpan = commentSpan.Translated(extent.Span.Snapshot);

                        if (translatedSpan.OverlapsWith(extent.Span))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Beispiel #6
0
        private static CompletionContext GetCompletionContext(PaketDocument paketDocument, ITextStructureNavigator navigator, SnapshotPoint position)
        {
            var startPos = position.Position;
            var length   = 0;

            if (position.Position > 0)
            {
                TextExtent endPosition   = navigator.GetExtentOfWord(position);
                TextExtent startPosition = endPosition;

                // try to extend the span over .
                while (!String.IsNullOrWhiteSpace(paketDocument.GetCharAt(startPosition.Span.Start.Position - 1)))
                {
                    startPosition = navigator.GetExtentOfWord(startPosition.Span.Start - 2);
                }


                startPos = startPosition.Span.Start.Position;
                length   = endPosition.Span.End.Position - startPos;
            }

            var span         = new Span(startPos, length);
            var snapShotSpan = new SnapshotSpan(position.Snapshot, span);

            var context = new CompletionContext(span);

            context.ContextType = CompletionContextType.InstalledNuGet;
            context.Snapshot    = snapShotSpan.Snapshot;
            return(context);
        }
Beispiel #7
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            char typedChar = char.MinValue;

            if (pguidCmdGroup == VSConstants.VSStd2K && nCmdID == (uint)VSConstants.VSStd2KCmdID.TYPECHAR)
            {
                typedChar = (char)(ushort)Marshal.GetObjectForNativeVariant(pvaIn);
                if (typedChar.Equals('(') && (m_session == null || m_session.IsDismissed))
                {
                    //move the point back so it's in the preceding word
                    SnapshotPoint point  = m_textView.Caret.Position.BufferPosition - 1;
                    TextExtent    extent = m_navigator.GetExtentOfWord(point);
                    string        word   = extent.Span.GetText();

                    m_session = m_broker.CreateSignatureHelpSession(m_textView, m_textView.TextSnapshot.CreateTrackingPoint(point.Position, PointTrackingMode.Positive), true);
                    m_session.Properties.AddProperty("word", word);
                    m_session.Start();
                }
                else if (typedChar.Equals(',') && (m_session == null || m_session.IsDismissed))
                {
                    int paramPos;
                    int pos = m_textView.Caret.Position.BufferPosition - 1;
                    while (pos > 0 && m_textView.TextSnapshot[pos] != '(')
                    {
                        pos--;
                    }
                    if (pos > 0)
                    {
                        paramPos = pos;
                        pos--;
                        while (pos > 0 && char.IsWhiteSpace(m_textView.TextSnapshot[pos]))
                        {
                            pos--;
                        }
                        if (pos > 0)
                        {
                            SnapshotPoint point  = new SnapshotPoint(m_textView.TextSnapshot, pos);
                            TextExtent    extent = m_navigator.GetExtentOfWord(point);
                            string        word   = extent.Span.GetText();


                            m_session = m_broker.CreateSignatureHelpSession(m_textView, m_textView.TextSnapshot.CreateTrackingPoint(m_textView.Caret.Position.BufferPosition - 1, PointTrackingMode.Positive), true);
                            m_session.Properties.AddProperty("word", word);
                            m_session.Properties.AddProperty("span", new Span(paramPos, m_textView.Caret.Position.BufferPosition - paramPos));
                            m_session.Start();
                        }
                    }
                }
                else if (typedChar.Equals(')') && m_session != null)
                {
                    m_session.Dismiss();
                    m_session = null;
                }
                else if (m_session != null && m_session.IsDismissed)
                {
                    m_session = null;
                }
            }
            return(m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
        }
Beispiel #8
0
        private bool IsXmlAttributeValue(SnapshotPoint triggerLocation)
        {
            TextExtent extent = _navigator.GetExtentOfWord(triggerLocation - 1);
            IList <ClassificationSpan> spans = _classifier.GetClassificationSpans(extent.Span);

            return(spans.Any(s => s.ClassificationType.IsOfType("XML Attribute Value")));
        }
Beispiel #9
0
        private void OnLayoutChanged(object sender, TextViewLayoutChangedEventArgs e)
        {
            var caretPosition = _view.Caret.Position;

            SnapshotPoint?point = caretPosition.Point.GetPoint(_buffer, caretPosition.Affinity);

            if (!point.HasValue)
            {
                return;
            }

            /*/ If the new caret position is still within the current word (and on the same snapshot), we don't need to check it
             * if (CurrentWord.HasValue
             *  && CurrentWord.Value.Snapshot == m_view.TextSnapshot
             *  && point.Value >= CurrentWord.Value.Start
             *  && point.Value <= CurrentWord.Value.End)
             * {
             *  return;
             * }*/

            List <SnapshotSpan> wordSpans = new List <SnapshotSpan>();
            //Find all words in the buffer like the one the caret is on
            TextExtent word = _textStructureNavigator.GetExtentOfWord(point.Value);

            if (_codeModel == null)
            {
                //If we couldn't find a word, clear out the existing markers
                SynchronousUpdate(new NormalizedSnapshotSpanCollection());
                return;
            }

            FindBadActions(wordSpans, word.Span);

            SynchronousUpdate(new NormalizedSnapshotSpanCollection(wordSpans));
        }
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            // Map the trigger point down to our buffer
            ITextSnapshot snapshot            = _subjectBuffer.CurrentSnapshot;
            SnapshotPoint?subjectTriggerPoint = session.GetTriggerPoint(snapshot);

            if (!subjectTriggerPoint.HasValue)
            {
                applicableToSpan = null;
                return;
            }

            ITextStructureNavigator navigator = _navigatorService.GetTextStructureNavigator(_subjectBuffer);
            TextExtent extent     = navigator.GetExtentOfWord(subjectTriggerPoint.Value);
            string     extentText = extent.Span.GetText();

            // What we are effectively doing here is placing this QuickInfo source at the end so that it
            // can hijack the other previous QuickInfo sources. We replace them with colourised versions.

            applicableToSpan = null;
            if (quickInfoContent.Count > 0)
            {
                ITextBuffer cppQuickInfoContentBuffer = quickInfoContent[0] as ITextBuffer;
                string      cppQuickInfoText          = cppQuickInfoContentBuffer.CurrentSnapshot.GetText();
                TextBlock   newContent = CreateColourisedContent(cppQuickInfoText);

                quickInfoContent.RemoveAt(0);
                quickInfoContent.Add(newContent);

                applicableToSpan = snapshot.CreateTrackingSpan(extent.Span.Start, extent.Span.Length, SpanTrackingMode.EdgeInclusive);
            }
        }
Beispiel #11
0
        internal void ParseSpecifiers(string inputstr, TextExtent extent, SnapshotPoint contentPosition, out bool inMeta, out List <string> specifiersList, out List <string> metaList)
        {
            specifiersList = new List <string>();
            metaList       = new List <string>();

            inMeta = false;

            var matchSpecs = Regex.Matches(inputstr, @"meta\s*=\s*\(([\w\s=""]+\,?)*\)|(\w+\s*=?\s*[\w""]*)\,?", RegexOptions.IgnorePatternWhitespace, TimeSpan.FromMilliseconds(1000));

            foreach (var spec in matchSpecs)
            {
                var mm = (Match)spec;

                if (mm.Groups[1].Success)
                {
                    var metaPositionStart = contentPosition + mm.Groups[1].Index;
                    var metaPositionEnd   = metaPositionStart + mm.Groups[1].Length;

                    inMeta = (extent.Span.Start >= metaPositionStart && extent.Span.End <= metaPositionEnd);

                    foreach (var ms in mm.Groups[1].Captures)
                    {
                        metaList.Add(((Capture)ms).Value.Trim(' ', ','));
                    }
                }

                if (mm.Groups[2].Success)
                {
                    specifiersList.Add(mm.Groups[2].Value.Trim(' ', ','));
                }
            }
        }
Beispiel #12
0
        public void AugmentQuickInfoSession(
            IQuickInfoSession session, IList <object> quickInfoContent,
            out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;
            SnapshotPoint?subjectTriggerPoint =
                session.GetTriggerPoint(this.textBuffer.CurrentSnapshot);

            if (!subjectTriggerPoint.HasValue)
            {
                return;
            }
            ITextSnapshot currentSnapshot = subjectTriggerPoint.Value.Snapshot;
            SnapshotSpan  querySpan       = new SnapshotSpan(subjectTriggerPoint.Value, 0);

            var        tagAggregator = GetAggregator(session);
            TextExtent extent        = FindExtentAtPoint(subjectTriggerPoint);

            if (CheckForPrefixTag(tagAggregator, extent.Span))
            {
                String prefix = extent.Span.GetText();
                String url    = FindNSUri(extent.Span, GetDocText(extent.Span));
                applicableToSpan = currentSnapshot.CreateTrackingSpan(
                    extent.Span, SpanTrackingMode.EdgeInclusive
                    );
                quickInfoContent.Add(CreateInfoText(prefix, url));
            }
        }
Beispiel #13
0
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            SnapshotPoint?subjectTriggerPoint = session.GetTriggerPoint(_subjectBuffer.CurrentSnapshot);

            if (!subjectTriggerPoint.HasValue)
            {
                applicableToSpan = null;
                return;
            }

            //ITextSnapshot currentSnapshot = subjectTriggerPoint.Value.Snapshot;
            //SnapshotSpan querySpan = new SnapshotSpan(subjectTriggerPoint.Value, 0);

            ITextStructureNavigator navigator = _provider.NavigatorService.GetTextStructureNavigator(_subjectBuffer);
            TextExtent extent = navigator.GetExtentOfWord(subjectTriggerPoint.Value);
            //string searchText = extent.Span.GetText();

            string description = _analysisEntry.GetDescription(_subjectBuffer, subjectTriggerPoint.Value);

            if (description != String.Empty && description != null)
            {
                applicableToSpan = subjectTriggerPoint.Value.Snapshot.CreateTrackingSpan(extent.Span.Start, extent.Span.Length, SpanTrackingMode.EdgeInclusive);
                quickInfoContent.Add(description);
                return;
            }

            applicableToSpan = null;
        }
Beispiel #14
0
        public static ImmutableArray <ClassifiedExtent> Classify(SyntaxNode node, TextExtent extent, CancellationToken cancellationToken = default)
        {
            var result = new List <ClassifiedExtent>();

            AddClassifications(node, extent, result, cancellationToken);
            return(result.ToImmutableArray());
        }
        /// <summary>
        /// Gets the quick information item asynchronous.
        /// </summary>
        /// <owner>Anton Patron</owner>
        /// <param name="session">The session.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>The <see cref="QuickInfoItem"/></returns>
        public async Task <QuickInfoItem> GetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken)
        {
            SnapshotPoint?subjectTriggerPoint = session.GetTriggerPoint(this.m_subjectBuffer.CurrentSnapshot);

            if (!subjectTriggerPoint.HasValue)
            {
                return(null);
            }

            ITextSnapshot           currentSnapshot = subjectTriggerPoint.Value.Snapshot;
            ITextStructureNavigator navigator       = this.m_provider.NavigatorService.GetTextStructureNavigator(this.m_subjectBuffer);
            TextExtent extent     = navigator.GetExtentOfWord(subjectTriggerPoint.Value);
            string     searchText = extent.Span.GetText();
            var        elements   = await this.m_provider.TranslatorService.GetTooltipElementsAsync(searchText).ConfigureAwait(false);

            if (!elements.Any())
            {
                return(null);
            }

            var applicableToSpan = currentSnapshot.CreateTrackingSpan(extent.Span.Start, searchText.Length, SpanTrackingMode.EdgeInclusive);
            var element          = QuickInfoSource.ComposeContainerElement(elements);

            return(new QuickInfoItem(applicableToSpan, element));
        }
Beispiel #16
0
        void UpdateWordAdornments()
        {
            SnapshotPoint       currentRequest = RequestedPoint;
            List <SnapshotSpan> wordSpans      = new List <SnapshotSpan>();
            //Find all words in the buffer like the one the caret is on
            TextExtent word      = TextStructureNavigator.GetExtentOfWord(currentRequest);
            bool       foundWord = true;

            //If we've selected something not worth highlighting, we might have missed a "word" by a little bit
            if (!WordExtentIsValid(currentRequest, word))
            {
                //Before we retry, make sure it is worthwhile
                if (word.Span.Start != currentRequest ||
                    currentRequest == currentRequest.GetContainingLine().Start ||
                    char.IsWhiteSpace((currentRequest - 1).GetChar()))
                {
                    foundWord = false;
                }
                else
                {
                    // Try again, one character previous.
                    //If the caret is at the end of a word, pick up the word.
                    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(currentRequest, new NormalizedSnapshotSpanCollection(), null);
                return;
            }

            SnapshotSpan currentWord = word.Span;

            //If this is the current word, and the caret moved within a word, we're done.
            if (CurrentWord.HasValue && currentWord == CurrentWord)
            {
                return;
            }

            //Find the new spans
            FindData findData = new FindData(currentWord.GetText(), currentWord.Snapshot);

            findData.FindOptions = FindOptions.WholeWord | FindOptions.MatchCase;

            wordSpans.AddRange(TextSearchService.FindAll(findData));

            //If another change hasn't happened, do a real update
            if (currentRequest == RequestedPoint)
            {
                SynchronousUpdate(currentRequest, new NormalizedSnapshotSpanCollection(wordSpans), currentWord);
            }
        }
Beispiel #17
0
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList <ISignature> signatures)
        {
            ITextSnapshot snapshot = m_textBuffer.CurrentSnapshot;
            int           position = session.GetTriggerPoint(m_textBuffer).GetPosition(snapshot);

            ITrackingSpan applicableToSpan = m_textBuffer.CurrentSnapshot.CreateTrackingSpan(
                new Span(position, 0), SpanTrackingMode.EdgeInclusive, 0);


            SnapshotPoint point        = session.TextView.Caret.Position.BufferPosition - 2;
            TextExtent    extent       = m_navigator.GetTextStructureNavigator(m_textBuffer).GetExtentOfWord(point);
            string        hintfunction = extent.Span.GetText();

            var knownFunctions = m_parsedProject.GetAvailableFunctionSignatures();

            foreach (var func in knownFunctions)
            {
                if (!func.Name.Text.Equals(hintfunction))
                {
                    continue;
                }

                foreach (var overload in func.Overloads)
                {
                    signatures.Add(CreateSignature(m_textBuffer, func.Name.Text, overload, "Documentation goes here.", applicableToSpan));
                }
            }
        }
        public IEnumerable <ITagSpan <IClassificationTag> > GetTags(NormalizedSnapshotSpanCollection spans)
        {
            var syntaxTreeAndSnapshot = ParserService.SyntaxTreeAndSnapshot;

            if (syntaxTreeAndSnapshot == null)
            {
                yield break;
            }

            foreach (var span in spans)
            {
                var extent = TextExtent.FromBounds(span.Start.Position, span.End.Position);
                var result = SyntaxClassifier.Classify(syntaxTreeAndSnapshot.SyntaxTree.Root, extent);

                foreach (var classifiedExtent in result)
                {
                    _classificationMap.TryGetValue(classifiedExtent.Classification, out var ct);
                    if (ct == null)
                    {
                        continue;
                    }

                    var tokenSpan = new SnapshotSpan(syntaxTreeAndSnapshot.Snapshot, new Span(classifiedExtent.Extent.Start, classifiedExtent.Extent.Length));
                    var tagSpan   = tokenSpan.TranslateTo(span.Snapshot, SpanTrackingMode.EdgeExclusive);
                    var tag       = new ClassificationTag(ct);

                    yield return(new TagSpan <IClassificationTag>(tagSpan, tag));
                }
            }
        }
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> qiContent, out ITrackingSpan applicableToSpan)
        {
            // Map the trigger point down to our buffer.
            SnapshotPoint?subjectTriggerPoint = session.GetTriggerPoint(m_subjectBuffer.CurrentSnapshot);

            if (!subjectTriggerPoint.HasValue)
            {
                applicableToSpan = null;
                return;
            }

            var fileSpecificTooltips = fileSpecificTooltipProvider.GetFileSpecificTooltipDefinitions(GetFileFullPath());

            ITextSnapshot currentSnapshot = subjectTriggerPoint.Value.Snapshot;
            SnapshotSpan  querySpan       = new SnapshotSpan(subjectTriggerPoint.Value, 0);

            //look for occurrences of our QuickInfo words in the span
            ITextStructureNavigator navigator = m_provider.NavigatorService.GetTextStructureNavigator(m_subjectBuffer);
            TextExtent extent     = navigator.GetExtentOfWord(subjectTriggerPoint.Value);
            string     searchText = extent.Span.GetText();

            foreach (TooltipDefinition tooltipDefinition in fileSpecificTooltips)
            {
                int foundIndex = searchText.IndexOf(tooltipDefinition.Input, StringComparison.CurrentCultureIgnoreCase);
                if (foundIndex > -1)
                {
                    var start = extent.Span.Start + foundIndex;
                    applicableToSpan = currentSnapshot.CreateTrackingSpan(start, tooltipDefinition.Input.Length, SpanTrackingMode.EdgeInclusive);
                    qiContent.Add(tooltipDefinition.Description);
                    return;
                }
            }

            applicableToSpan = null;
        }
        private ITrackingSpan FindTokenSpanAtPosition(ICompletionSession session)
        {
            SnapshotPoint currentPoint = session.TextView.Caret.Position.BufferPosition - 1;
            TextExtent    extent       = _textStructureNavigator.GetExtentOfWord(currentPoint);

            var prev = _textStructureNavigator.GetSpanOfPreviousSibling(extent.Span);

            if (prev != null && !prev.Contains(extent.Span))
            {
                string text = prev.GetText();
                if (!string.IsNullOrEmpty(text) && text.Last() != '%' && !char.IsLetter(text[0]))
                {
                    return(null);
                }

                if (text.First() != '%' && CmdLanguage.Keywords.ContainsKey(text.ToLowerInvariant()))
                {
                    text = text.ToLowerInvariant();
                    if (text != "if" && text != "not")
                    {
                        return(null);
                    }
                }
            }

            return(currentPoint.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive));
        }
        public override int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            //the snippet picker code starts here
            if (nCmdID == (uint)VSConstants.VSStd2KCmdID.INSERTSNIPPET)
            {
                _manager.InvokeInsertionUI(
                    _vsTextView,
                    this,                   //the expansion client
                    new Guid(_guid),
                    null,                   //use all snippet types
                    0,                      //number of types (0 for all)
                    0,                      //ignored if iCountTypes == 0
                    null,                   //use all snippet kinds
                    0,                      //use all snippet kinds
                    0,                      //ignored if iCountTypes == 0
                    Constants.LanguageName, //the text to show in the prompt
                    string.Empty);          //only the ENTER key causes insert

                return(VSConstants.S_OK);
            }

            if (_session != null)
            {
                if (nCmdID == (uint)VSConstants.VSStd2KCmdID.BACKTAB)
                {
                    _session.GoToPreviousExpansionField();
                    return(VSConstants.S_OK);
                }
                else if (nCmdID == (uint)VSConstants.VSStd2KCmdID.TAB)
                {
                    _session.GoToNextExpansionField(0); //false to support cycling through all the fields
                    return(VSConstants.S_OK);
                }
                else if (nCmdID == (uint)VSConstants.VSStd2KCmdID.RETURN || nCmdID == (uint)VSConstants.VSStd2KCmdID.CANCEL)
                {
                    if (_session.EndCurrentExpansion(0) == VSConstants.S_OK)
                    {
                        _session = null;
                        return(VSConstants.S_OK);
                    }
                }
            }

            if (_session == null && nCmdID == (uint)VSConstants.VSStd2KCmdID.TAB)
            {
                CaretPosition pos        = _view.Caret.Position;
                TextExtent    word       = _navigator.GetTextStructureNavigator(_view.TextBuffer).GetExtentOfWord(pos.BufferPosition - 1);
                string        textString = word.Span.GetText();

                if (InsertAnyExpansion(textString, null, null))
                {
                    EndSession();
                    return(VSConstants.S_OK);
                }
            }

            ThreadHelper.ThrowIfNotOnUIThread();

            return(Next.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
        }
        public void TestQuotationExtent()
        {
            char quotationChar = '\'';

            var text = "Hi 'Max'!";

            Assert.That(text.QuotedExtent(0, quotationChar), Is.EqualTo(TextExtent.Missing)); // H
            Assert.That(text.QuotedExtent(1, quotationChar), Is.EqualTo(TextExtent.Missing)); // i
            Assert.That(text.QuotedExtent(2, quotationChar), Is.EqualTo(TextExtent.Missing)); //
            Assert.That(text.QuotedExtent(3, quotationChar), Is.EqualTo(TextExtent.Missing)); // '
            // -
            var expectedExtent = new TextExtent(4, 3);                                        // Max

            Assert.That(text.QuotedExtent(4, quotationChar), Is.EqualTo(expectedExtent));     // M
            Assert.That(text.QuotedExtent(5, quotationChar), Is.EqualTo(expectedExtent));     // a
            Assert.That(text.QuotedExtent(6, quotationChar), Is.EqualTo(expectedExtent));     // x
            Assert.That(text.QuotedExtent(7, quotationChar), Is.EqualTo(expectedExtent));     // '
            // -
            Assert.That(text.QuotedExtent(8, quotationChar), Is.EqualTo(TextExtent.Missing)); // !

            // Include Quotation
            Assert.That(text.QuotedExtent(0, quotationChar, true), Is.EqualTo(TextExtent.Missing)); // H
            Assert.That(text.QuotedExtent(1, quotationChar, true), Is.EqualTo(TextExtent.Missing)); // i
            Assert.That(text.QuotedExtent(2, quotationChar, true), Is.EqualTo(TextExtent.Missing)); //
            Assert.That(text.QuotedExtent(3, quotationChar, true), Is.EqualTo(TextExtent.Missing)); // '
            // -
            var expectedFullExtent = new TextExtent(start: 3, length: 5);                           // Max

            Assert.That(text.QuotedExtent(4, quotationChar, true), Is.EqualTo(expectedFullExtent)); // M
            Assert.That(text.QuotedExtent(5, quotationChar, true), Is.EqualTo(expectedFullExtent)); // a
            Assert.That(text.QuotedExtent(6, quotationChar, true), Is.EqualTo(expectedFullExtent)); // x
            Assert.That(text.QuotedExtent(7, quotationChar, true), Is.EqualTo(expectedFullExtent)); // '
            // -
            Assert.That(text.QuotedExtent(8, quotationChar, true), Is.EqualTo(TextExtent.Missing)); // !
        }
Beispiel #23
0
        private bool IsExtentTokenExpected(SnapshotSpan range, TextExtent extent, out ITrackingSpan trackSpan, out PSharpParser parser)
        {
            string extentText  = extent.Span.GetText();
            var    extentToken = string.IsNullOrWhiteSpace(extentText) ? null : new PSharpLexer().Tokenize(extentText).FirstOrDefault();

            if (extentToken == null)
            {
                trackSpan = null;
                parser    = null;
                return(false);
            }

            // TODO: Minimize the re-parse span for speed.
            var snapshot = extent.Span.Snapshot;

            trackSpan = range.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive);
            var preSpan = new SnapshotSpan(snapshot, new Span(snapshot.GetLineFromLineNumber(0).Start,
                                                              trackSpan.GetStartPoint(snapshot).Position));

            var tokens = new PSharpLexer().Tokenize(preSpan.GetText());

            parser = new PSharpParser(ParsingOptions.CreateForVsLanguageService());
            try
            {
                parser.ParseTokens(tokens);
            }
            catch (ParsingException)
            {
                // Parsing exception is expected
            }
            return(this.IsExpectedTokenType(extentToken, parser.GetExpectedTokenTypes()));
        }
Beispiel #24
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            char typedChar = char.MinValue;

            if (pguidCmdGroup == VSConstants.VSStd2K && nCmdID == (uint)VSConstants.VSStd2KCmdID.TYPECHAR)
            {
                typedChar = (char)(ushort)Marshal.GetObjectForNativeVariant(pvaIn);
                if (typedChar.Equals('('))
                {
                    //move the point back so it's in the preceding word
                    SnapshotPoint point  = m_textView.Caret.Position.BufferPosition - 1;
                    TextExtent    extent = m_navigator.GetExtentOfWord(point);
                    string        word   = extent.Span.GetText();
                    /******************************************************************/
                    //if (word.Equals("add"))
                    if (!String.IsNullOrEmpty(word))
                    {
                        m_session = m_broker.TriggerSignatureHelp(m_textView);
                    }
                }
                else if (typedChar.Equals(')') && m_session != null)
                {
                    m_session.Dismiss();
                    m_session = null;
                }
            }
            return(m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
        }
        private void UpdateWordAdornments()
        {
            var point = _requestedPoint;

            // Find all words in the buffer like the one the caret is on
            TextExtent extent = _textStructureNavigator.GetExtentOfWord(point);

            // If we've selected something not worth highlighting, we might have missed a "word" by a little bit
            if (!IsExtentValid(extent, point))
            {
                //Before we retry, make sure it is worthwhile
                if (extent.Span.Start != point || point == point.GetContainingLine().Start || char.IsWhiteSpace((point - 1).GetChar()))
                {
                    // If we couldn't find a word, clear out the existing markers
                    SynchronousUpdate(point, new NormalizedSnapshotSpanCollection(), null);
                    return;
                }
                else
                {
                    // Try again, one character previous. If the caret is at the end of a word, pick up the word.
                    extent = _textStructureNavigator.GetExtentOfWord(point - 1);

                    // If the word still isn't valid, we're done
                    if (!IsExtentValid(extent, point))
                    {
                        // If we couldn't find a word, clear out the existing markers
                        SynchronousUpdate(point, new NormalizedSnapshotSpanCollection(), null);
                        return;
                    }
                }
            }

            FindAndUpdateSpans(extent, point);
        }
        /// <summary>
        /// Determine if this text point's current word is a blank line on the next line.
        /// </summary>
        /// <param name="currentWord">The current word to check.</param>
        private bool IsCurrentWordABlankLine(TextExtent currentWord)
        {
            TextPoint endOfCurrentWord = Clone();

            endOfCurrentWord.MoveTo(currentWord.Span.End);
            return((EndOfLine == CurrentPosition) && (currentWord.Span.End == endOfCurrentWord.EndOfLine));
        }
Beispiel #27
0
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;
            // Map the trigger point down to our buffer.
            SnapshotPoint?subjectTriggerPoint = session.GetTriggerPoint(_subjectBuffer.CurrentSnapshot);

            if (!subjectTriggerPoint.HasValue)
            {
                return;
            }

            ITextSnapshot           currentSnapshot = subjectTriggerPoint.Value.Snapshot;
            ITextStructureNavigator navigator       = _provider.NavigatorService.GetTextStructureNavigator(_subjectBuffer);
            TextExtent extent = navigator.GetExtentOfWord(subjectTriggerPoint.Value);

            string key = extent.Span.GetText();
            //look for occurrences of our QuickInfo words in the span
            SQDeclaration dec = _languageService.Find(key);

            if (dec != null)
            {
                quickInfoContent.Add(dec.GetDescription());
                //quickInfoContent.Add(searchText);

                applicableToSpan = currentSnapshot.CreateTrackingSpan(extent.Span.Start, key.Length, SpanTrackingMode.EdgeInclusive);
            }
        }
        static TextExtent CreateExtent(IToken startToken, IToken endToken)
        {
            if (startToken == null || endToken == null)
            {
                return(TextExtent.Missing);
            }

            if (startToken.StartIndex == -1 || endToken.StopIndex < -1)
            {
                return(TextExtent.Missing);
            }

            var start = startToken.StartIndex;
            var end   = endToken.StopIndex + 1;

            // Warum auch immer Antlr so etwas absurdes liefert...
            if (end < start)
            {
                return(TextExtent.Missing);
            }

            return(TextExtent.FromBounds(
                       start: start,
                       end: end
                       ));
        }
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            // Map the trigger point down to our buffer.
            SnapshotPoint?subjectTriggerPoint = session.GetTriggerPoint(m_subjectBuffer.CurrentSnapshot);

            if (!subjectTriggerPoint.HasValue)
            {
                applicableToSpan = null;
                return;
            }

            ITextSnapshot currentSnapshot = subjectTriggerPoint.Value.Snapshot;
            SnapshotSpan  querySpan       = new SnapshotSpan(subjectTriggerPoint.Value, 0);

            //look for occurrences of our QuickInfo words in the span
            ITextStructureNavigator navigator = m_provider.NavigatorService.GetTextStructureNavigator(m_subjectBuffer);
            TextExtent extent     = navigator.GetExtentOfWord(subjectTriggerPoint.Value);
            string     searchText = extent.Span.GetText();

            searchText = searchText?.Trim();
            String text = null;

            if (!String.IsNullOrEmpty(searchText))
            {
                text             = TranslateApi.TranslateEn_Zh(searchText);
                applicableToSpan = currentSnapshot.CreateTrackingSpan
                                   (
                    //querySpan.Start.Add(foundIndex).Position, 9, SpanTrackingMode.EdgeInclusive
                    extent.Span.Start, text.Length, SpanTrackingMode.EdgeInclusive
                                   );
                quickInfoContent.Add(text);
                return;
            }


            //foreach (string key in m_dictionary.Keys)
            //{
            //    int foundIndex = searchText.IndexOf(key, StringComparison.CurrentCultureIgnoreCase);
            //    if (foundIndex > -1)
            //    {
            //        applicableToSpan = currentSnapshot.CreateTrackingSpan
            //            (
            //                                    //querySpan.Start.Add(foundIndex).Position, 9, SpanTrackingMode.EdgeInclusive
            //                                    extent.Span.Start + foundIndex, key.Length, SpanTrackingMode.EdgeInclusive
            //            );

            //        string value;
            //        m_dictionary.TryGetValue(key, out value);
            //        if (value != null)
            //            quickInfoContent.Add(value);
            //        else
            //            quickInfoContent.Add("");

            //        return;
            //    }
            //}

            applicableToSpan = null;
        }
Beispiel #30
0
        private ITrackingSpan FindTokenSpanAtPosition(ICompletionSession session)
        {
            SnapshotPoint           currentPoint = (session.TextView.Caret.Position.BufferPosition) - 1;
            ITextStructureNavigator navigator    = _navigator.GetTextStructureNavigator(_buffer);
            TextExtent extent = navigator.GetExtentOfWord(currentPoint);

            return(currentPoint.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive));
        }
        internal TaskNodeDeclarationSyntax(TextExtent extent,
                            CodeDoNotInjectDeclarationSyntax codeDoNotInjectDeclaration, 
                            CodeAbstractMethodDeclarationSyntax codeAbstractMethodDeclaration)
             : base(extent) {

            AddChildNode(_codeDoNotInjectDeclaration = codeDoNotInjectDeclaration);
            AddChildNode(_codeAbstractMethodDeclaration = codeAbstractMethodDeclaration);
        }
        public void TestManualEmpty() {

            var extent = TextExtent.FromBounds(0, 0);
            Assert.That(extent.IsEmpty, Is.True);

            extent = new TextExtent(0, 0);
            Assert.That(extent.IsEmpty, Is.True);
        }
        internal TransitionDefinitionBlockSyntax(TextExtent extent, 
            IReadOnlyList<TransitionDefinitionSyntax> transitionDefinitions,
             IReadOnlyList<ExitTransitionDefinitionSyntax> exitTransitionDefinitions) 
            : base(extent) {

            AddChildNodes(_transitionDefinitions     = transitionDefinitions);
            AddChildNodes(_exitTransitionDefinitions = exitTransitionDefinitions);
        }
        internal static SnapshotSpan? GetPreviousWord(this ITextStructureNavigator navigator, SnapshotPoint position)
        {
            var word = new TextExtent(new SnapshotSpan(position, 0), false);
            while(!word.IsSignificant && word.Span.Start.Position > 0)
            {
                word = navigator.GetExtentOfWord(new SnapshotPoint(word.Span.Snapshot, word.Span.Start.Position - 1));
            }

            return word.IsSignificant ? new SnapshotSpan?(word.Span) : null;
        }
        internal InitNodeDeclarationSyntax(TextExtent extent,
                CodeAbstractMethodDeclarationSyntax codeAbstractMethodDeclaration, 
                CodeParamsDeclarationSyntax codeParamsDeclaration,
                DoClauseSyntax doClause)
                : base(extent) {

            AddChildNode(_codeAbstractMethodDeclaration = codeAbstractMethodDeclaration);
            AddChildNode(_codeParamsDeclaration         = codeParamsDeclaration);
            AddChildNode(_doClause                  = doClause);
        }
        public TextExtent GetExtentOfWord(SnapshotPoint currentPosition)
        {
            TextExtent extent = _delegateNavigator.GetExtentOfWord(currentPosition);
            if (extent.IsSignificant)
            {
                var span = extent.Span;
                if (span.Start > 0 && IsIdentifierStartChar(span.Start.GetChar()) && IsIdentifierStartChar((span.Start - 1).GetChar()))
                    extent = new TextExtent(new SnapshotSpan(span.Start - 1, span.End), true);
            }

            return extent;
        }
        internal TaskDeclarationSyntax(TextExtent extent, 
                                       CodeNamespaceDeclarationSyntax      codeNamespaceDeclaration,
                                       CodeNotImplementedDeclarationSyntax codeNotImplementedDeclaration, 
                                       CodeResultDeclarationSyntax         codeResultDeclaration, 
                                       IReadOnlyList<ConnectionPointNodeSyntax> connectionPointNodeDeclarations) 
            : base(extent) {

            AddChildNode(_codeNamespaceDeclaration  = codeNamespaceDeclaration);
            AddChildNode(_codeNotImplementedDeclaration = codeNotImplementedDeclaration);
            AddChildNode(_codeResultDeclaration         = codeResultDeclaration);
            AddChildNodes(_connectionPointNodes     = connectionPointNodeDeclarations);
        }
 internal ExitTransitionDefinitionSyntax(TextExtent extent,
                                         IdentifierSourceNodeSyntax sourceNode,
                                         EdgeSyntax edge,
                                         TargetNodeSyntax targetNode,
                                         ConditionClauseSyntax conditionClause, 
                                         DoClauseSyntax doClause) : base(extent) {
     
     AddChildNode(_sourceNode      = sourceNode);
     AddChildNode(_edge            = edge);
     AddChildNode(_targetNode      = targetNode);
     AddChildNode(_conditionClause = conditionClause);
     AddChildNode(_doClause        = doClause);
 }
        internal CodeGenerationUnitSyntax(
                TextExtent extent,
                CodeNamespaceDeclarationSyntax            codeNamespaceDeclaration,
                IReadOnlyList<CodeUsingDeclarationSyntax> codeUsingDeclarations,
                IReadOnlyList<MemberDeclarationSyntax>    memberDeclarations
                ) 
            : base(extent) {
            _members = memberDeclarations;

            AddChildNode( _codeNamespace = codeNamespaceDeclaration);
            AddChildNodes(_codeUsings    = codeUsingDeclarations   );
            AddChildNodes(_members       = memberDeclarations      );
        }
        internal TransitionDefinitionSyntax(TextExtent extent,
                                            SourceNodeSyntax sourceNode,
                                            EdgeSyntax edgeSyntax,
                                            TargetNodeSyntax targetNode,
                                            TriggerSyntax trigger,
                                            ConditionClauseSyntax conditionClause,
                                            DoClauseSyntax doClause) : base(extent) {

            AddChildNode(_sourceNode      = sourceNode);
            AddChildNode(_edge            = edgeSyntax);
            AddChildNode(_targetNode      = targetNode);
            AddChildNode(_trigger         = trigger);
            AddChildNode(_conditionClause = conditionClause);
            AddChildNode(_doClause        = doClause);
        }
        internal TaskDefinitionSyntax(TextExtent extent, 
                                      CodeDeclarationSyntax codeDeclaration, 
                                      CodeBaseDeclarationSyntax codeBaseDeclaration,
                                      CodeGenerateToDeclarationSyntax codeGenerateToDeclaration, 
                                      CodeParamsDeclarationSyntax codeParamsDeclaration,
                                      CodeResultDeclarationSyntax codeResultDeclaration, 
                                      NodeDeclarationBlockSyntax nodeDeclarationBlock,
                                      TransitionDefinitionBlockSyntax transitionDefinitionBlock)
                : base(extent) {

            AddChildNode(_codeDeclaration           = codeDeclaration);
            AddChildNode(_codeBaseDeclaration           = codeBaseDeclaration);
            AddChildNode(_codeGenerateToDeclaration     = codeGenerateToDeclaration);
            AddChildNode(_codeParamsDeclaration         = codeParamsDeclaration);
            AddChildNode(_codeResultDeclaration         = codeResultDeclaration);
            AddChildNode(_nodeDeclarationBlock      = nodeDeclarationBlock);
            AddChildNode(_transitionDefinitionBlock = transitionDefinitionBlock);
        }
        private bool TryGetWordUnderCaret(out TextExtent wordExtent)
        {
            ITextCaret caret = _textView.Caret;
            SnapshotPoint point;

            if (caret.Position.BufferPosition > 0)
            {
                point = caret.Position.BufferPosition - 1;
            }
            else
            {
                wordExtent = default(TextExtent);
                return false;
            }

            ITextStructureNavigator navigator = _factory.NavigatorService.GetTextStructureNavigator(_textBuffer);

            wordExtent = navigator.GetExtentOfWord(point);
            return true;
        }
        LinePositionExtent GetLinePositionExtent(TextExtent extent) {

            var start = GetLinePosition(extent.Start);
            var end   = GetLinePosition(extent.End);

            return new LinePositionExtent(start, end);
        }
 public Location GetLocation(TextExtent extent) {
     return new Location(extent, GetLinePositionExtent(extent), FileInfo?.FullName);
 }
 internal CodeUsingDeclarationSyntax(TextExtent extent, IdentifierOrStringSyntax namespaceSyntax) : base(extent) {
     AddChildNode(_namespace = namespaceSyntax);
 }
 protected ConditionClauseSyntax(TextExtent extent) : base(extent) {}
 internal ElseConditionClauseSyntax(TextExtent extent) : base(extent) {
 }
        public override void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if (session == null || completionSets == null)
                return;

            ITrackingPoint triggerPoint = session.GetTriggerPoint(TextBuffer);
            if (triggerPoint != null)
            {
                IntellisenseController controller = GetControllerForView(session.TextView);
                CompletionInfo completionInfo = controller.CompletionInfo;
                ITextSnapshot snapshot = triggerPoint.TextBuffer.CurrentSnapshot;
                SnapshotPoint point = triggerPoint.GetPoint(snapshot);
                ITrackingPoint point2 = triggerPoint;
                bool flag = false;
                bool extend = true;

                IntellisenseInvocationType invocationType = completionInfo.InvocationType;
                CompletionInfoType infoType = completionInfo.InfoType;

                switch (invocationType)
                {
                case IntellisenseInvocationType.Default:
                    extend = infoType == CompletionInfoType.GlobalInfo;
                    break;

                case IntellisenseInvocationType.BackspaceDeleteOrBackTab:
                case IntellisenseInvocationType.IdentifierChar:
                case IntellisenseInvocationType.Sharp:
                case IntellisenseInvocationType.Space:
                case IntellisenseInvocationType.ShowMemberList:
                    break;

                default:
                    flag = true;
                    break;
                }

                TextExtent extentOfWord = default(TextExtent);
                if (extend)
                {
                    ITextBuffer textBuffer = TextBuffer;
                    ITextStructureNavigator navigator = TextStructureNavigatorSelectorService.CreateTextStructureNavigator(textBuffer, textBuffer.ContentType);
                    SnapshotPoint currentPosition = new SnapshotPoint(snapshot, point2.GetPosition(snapshot));
                    extentOfWord = navigator.GetExtentOfWord(currentPosition);
                    if (extentOfWord.Span.Start == point)
                    {
                        TextExtent extentOfPreviousWord = navigator.GetExtentOfWord(currentPosition - 1);
                        if (extentOfPreviousWord.IsSignificant && extentOfPreviousWord.Span.End == point && IsCompletionPrefix(extentOfPreviousWord))
                            extentOfWord = extentOfPreviousWord;
                        else
                            extend = false;
                    }
                }

                if (!extend || !extentOfWord.IsSignificant)
                {
                    SnapshotSpan span = new SnapshotSpan(point, 0);
                    extentOfWord = new TextExtent(span, false);
                }

                if (invocationType == IntellisenseInvocationType.BackspaceDeleteOrBackTab && extentOfWord.Span.Length > 0)
                {
                    string str3 = snapshot.GetText(extentOfWord.Span);
                    if (!string.IsNullOrWhiteSpace(str3))
                    {
                        while ("!^()=<>\\:;.,+-*/{}\" '&%@?".IndexOf(str3[0]) > 0)
                        {
                            SnapshotSpan span2 = extentOfWord.Span;
                            SnapshotSpan span3 = new SnapshotSpan(snapshot, span2.Start + 1, span2.Length - 1);
                            extentOfWord = new TextExtent(span3, false);
                            str3 = snapshot.GetText(extentOfWord.Span);
                            if (string.IsNullOrEmpty(str3))
                                break;
                        }
                    }
                    else
                    {
                        SnapshotSpan span4 = new SnapshotSpan(snapshot, extentOfWord.Span.End, 0);
                        extentOfWord = new TextExtent(span4, false);
                        completionInfo.InvocationType = IntellisenseInvocationType.Default;
                    }
                }

                ITrackingSpan applicableTo = snapshot.CreateTrackingSpan(extentOfWord.Span, SpanTrackingMode.EdgeInclusive, TrackingFidelityMode.Forward);
                if (flag)
                {
                    SnapshotSpan textSoFarSpan = new SnapshotSpan(snapshot, extentOfWord.Span.Start, triggerPoint.GetPoint(snapshot));
                    string textSoFar = textSoFarSpan.GetText();
                    applicableTo = snapshot.CreateTrackingSpan(point.Position - textSoFar.Length, textSoFar.Length, SpanTrackingMode.EdgeInclusive, TrackingFidelityMode.Forward);
                }

                IEnumerable<Completion> context = GetContextCompletions(triggerPoint.GetPoint(snapshot), (AlloyIntellisenseController)controller, session);
                IEnumerable<Completion> keywords = GetKeywordCompletions();
                IEnumerable<Completion> snippets = GetSnippetCompletions();
                //List<Completion> signatures = GetSignatureCompletions();
                //List<Completion> relations = GetRelationCompletions();
                //List<Completion> predicates = GetPredicateCompletions();
                //List<Completion> functions = GetFunctionCompletions();
                //SnapshotSpan? Provider.IntellisenseCache.GetExpressionSpan(triggerPoint.GetPoint(snapshot));

                IEnumerable<Completion> completions = context.Concat(keywords).Concat(snippets);
                IEnumerable<Completion> orderedCompletions = completions.Distinct(CompletionDisplayNameComparer.CurrentCulture).OrderBy(i => i.DisplayText, StringComparer.CurrentCultureIgnoreCase);

                CompletionSet completionSet = new CompletionSet("AlloyCompletions", "Alloy Completions", applicableTo, orderedCompletions, EmptyCompletions);
                completionSets.Add(completionSet);
            }
        }
 internal SpontaneousTriggerSyntax(TextExtent extent) : base(extent) {}
 internal SimpleTypeSyntax(TextExtent extent) : base(extent) {
 }
 internal ExitNodeDeclarationSyntax(TextExtent extent)
     : base(extent) {
 }
 internal SignalTriggerSyntax(TextExtent extent, IdentifierOrStringListSyntax identifierOrStringList) 
     : base(extent) {
     AddChildNode(_identifierOrStringList = identifierOrStringList);
 }
 internal IfConditionClauseSyntax(TextExtent extent, IdentifierOrStringSyntax identifierOrString) : base(extent) {
     AddChildNode(_identifierOrString = identifierOrString);
 }
 internal CodeAbstractMethodDeclarationSyntax(TextExtent extent) : base(extent) {
 }
 internal ElseIfConditionClauseSyntax(TextExtent extent, ElseConditionClauseSyntax elseCondition, IfConditionClauseSyntax ifCondition) : base(extent) {
     AddChildNode(_elseCondition = elseCondition);
     AddChildNode(_ifCondition   = ifCondition);
 }
        internal ArrayTypeSyntax(TextExtent extent, CodeTypeSyntax type, List<ArrayRankSpecifierSyntax> rankSpecifiers) 
            : base(extent) {

            AddChildNode( _type           = type);
            AddChildNodes(_rankSpecifiers = rankSpecifiers);
        }
        private bool TryGetWordUnderCaret(out TextExtent wordExtent)
        {
            var caret = this.TextView.Caret;
            SnapshotPoint point;

            if (caret.Position.BufferPosition > 0)
            {
                point = caret.Position.BufferPosition - 1;
            }
            else
            {
                wordExtent = default(TextExtent);
                return false;
            }

            var navigator = this.SourceProvider.NavigatorService.GetTextStructureNavigator(this.Buffer);
            wordExtent = navigator.GetExtentOfWord(point);

            return true;
        }
 protected TriggerSyntax(TextExtent extent) : base(extent) {}       
 private bool IsSignificantText(TextExtent extent, out String word)
 {
     word = "";
       if ( !extent.IsSignificant ) return false;
       if ( extent.Span.IsEmpty ) return false;
       char ch = extent.Span.Start.GetChar();
       if ( Char.IsLetter(ch) || ch == '_' || ch == '$' ) {
     word = extent.Span.GetText();
     return true;
       }
       return false;
 }
        private static bool IsCompletionPrefix(TextExtent extent)
        {
            string text = extent.Span.GetText();
            if (string.IsNullOrEmpty(text))
                return false;

            return IdentifierRegex.IsMatch(text);
        }