bool StartSession()
        {
            if (_currentSession != null)
            {
                return(false);
            }

            SnapshotPoint caret    = TextView.Caret.Position.BufferPosition;
            ITextSnapshot snapshot = caret.Snapshot;

            if (!Broker.IsCompletionActive(TextView))
            {
                _currentSession = Broker.CreateCompletionSession(TextView, snapshot.CreateTrackingPoint(caret, PointTrackingMode.Positive), true);
            }
            else
            {
                _currentSession = Broker.GetSessions(TextView)[0];
            }
            _currentSession.Dismissed += (sender, args) => _currentSession = null;

            if (!_currentSession.IsStarted)
            {
                _currentSession.Start();
            }

            return(true);
        }
Пример #2
0
    public void AugmentCompletionSession(Microsoft.VisualStudio.Language.Intellisense.ICompletionSession session, IList <Microsoft.VisualStudio.Language.Intellisense.CompletionSet> completionSets)
    {
        TextExtent extent;
        var        trackSpan           = FindTokenSpanAtPosition(session.GetTriggerPoint(textBuffer), session, out extent);
        var        textToComplete      = extent.Span.Snapshot.GetText(extent.Span.Start.Position, extent.Span.Length);
        var        textToCompleteLower = textToComplete.ToLower();

        var completionList = CompletionCodeContainer.Instance.GetCompletionListForFile(textDocument.FilePath, textBuffer);
        var completionSet  = new CompletionSet
                             (
            "Tokens",    //the non-localized title of the tab
            "Tokens",    //the display title of the tab
            trackSpan,
            completionList.Where(compl =>
        {
            string complStr = ((string)compl.Properties[CompletionCodeContainer.lowerDisplayName]);
            if (complStr.Contains(textToCompleteLower) && complStr != textToCompleteLower)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }),
            null
                             );

        completionSets.Insert(0, completionSet);
    }
        public void AugmentCompletionSession(Intel.ICompletionSession session, IList <Intel.CompletionSet> completionSets)
        {
            var position = session.GetTriggerPoint(_buffer).GetPoint(_buffer.CurrentSnapshot);
            var line     = position.GetContainingLine();

            if (line == null)
            {
                return;
            }

            var text         = line.GetText();
            var linePosition = position - line.Start;

            foreach (var source in completionSources)
            {
                var span = source.GetInvocationSpan(text, linePosition, position);
                if (span == null)
                {
                    continue;
                }

                if (span.Value.Length == 0)
                {
                    return;
                }

                var trackingSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(span.Value.Start + line.Start,
                                                                              span.Value.Length, SpanTrackingMode.EdgeInclusive);
                completionSets.Add(new StringCompletionSet(
                                       source.GetType().Name,
                                       trackingSpan,
                                       source.GetEntries(text[span.Value.Start], session.TextView.Caret.Position.BufferPosition)
                                       ));
            }
        }
Пример #4
0
 internal override List <Completion> GetCompletions(Microsoft.VisualStudio.Language.Intellisense.ICompletionSession session)
 {
     return(new List <Completion>()
     {
         new RegexCompletion("{N} : Exactly N", "{}", 1),
         new RegexCompletion("{N,M} : From N to M", "{,}", 2)
     });
 }
 internal override List <Completion> GetCompletions(Microsoft.VisualStudio.Language.Intellisense.ICompletionSession session)
 {
     return(new List <Completion>()
     {
         new RegexCompletion("[<chars>] : Group", "[]", 1),
         new RegexCompletion("[^<chars>] : Negated Group", "[^]", 1)
     });
 }
 internal override List <Completion> GetCompletions(Microsoft.VisualStudio.Language.Intellisense.ICompletionSession session)
 {
     return(new List <Completion>()
     {
         new RegexCompletion("(<group>) : Capture group", "()", 1),
         new RegexCompletion("(<group>|<group>) : Choice", "(|)", 2),
         new RegexCompletion("(?<group>) : Named Capture", "(?<>)", 2),
         new RegexCompletion("(?:<group>) : Passive group", "(?:)", 1),
         new RegexCompletion("(?i:<group>) : Case insensitive group", "(?i:)", 1),
         new RegexCompletion("(?m:<group>) : Multiline group", "(?m:)", 1),
         new RegexCompletion("(?n:<group>) : Explicit capture group", "(?n:)", 1),
         new RegexCompletion("(?s:<group>) : Single line group", "(?s:)", 1),
         new RegexCompletion("(?x:<group>) : Allow whitespace in group", "(?x:)", 1),
         new RegexCompletion("(?-i:<group>) : Case sensitive group", "(?-i:)", 1),
         new RegexCompletion("(?-m:<group>) : Non-multiline group", "(?-m:)", 1),
         new RegexCompletion("(?-n:<group>) : Non-explicit capture group", "(?-n:)", 1),
         new RegexCompletion("(?-s:<group>) : Non-single line group", "(?-s:)", 1),
         new RegexCompletion("(?-x:<group>) : Disallow whitespace in group", "(?-x:)", 1)
     });
 }
Пример #7
0
 internal override List <Completion> GetCompletions(Microsoft.VisualStudio.Language.Intellisense.ICompletionSession session)
 {
     return(new List <Completion>()
     {
         new RegexCompletion("\\d : Digits", "\\d", 0),
         new RegexCompletion("\\D : Non-digit characters", "\\D", 0),
         new RegexCompletion("\\w : Letters", "\\w", 0),
         new RegexCompletion("\\W : Non-letter characters", "\\W", 0),
         new RegexCompletion("\\s : Spaces", "\\s", 0),
         new RegexCompletion("\\S : Non-space characters", "\\S", 0),
         new RegexCompletion("\\A : Start of string", "\\A", 0),
         new RegexCompletion("\\Z : End of string", "\\Z", 0),
         new RegexCompletion("\\B : Word boundary", "\\B", 0),
         new RegexCompletion("\\b : Non-word boundary", "\\B", 0),
         new RegexCompletion("\\t : Tab", "\\t", 0),
         new RegexCompletion("\\v : Vertical Tab", "\\v", 0),
         new RegexCompletion("\\r : Carriage return", "\\r", 0),
         new RegexCompletion("\\f : Form feed", "\\f", 0),
         new RegexCompletion("\\n : New line", "\\n", 0)
     });
 }
        bool StartSession()
        {
            if (_currentSession != null)
                return false;

            SnapshotPoint caret = TextView.Caret.Position.BufferPosition;
            ITextSnapshot snapshot = caret.Snapshot;

            if (!Broker.IsCompletionActive(TextView))
            {
                _currentSession = Broker.CreateCompletionSession(TextView, snapshot.CreateTrackingPoint(caret, PointTrackingMode.Positive), true);
            }
            else
            {
                _currentSession = Broker.GetSessions(TextView)[0];
            }
            _currentSession.Dismissed += (sender, args) => _currentSession = null;

            if (!_currentSession.IsStarted)
                _currentSession.Start();

            return true;
        }
Пример #9
0
 public SimpleHtmlCompletion(string displayText, string description, string insertion, ImageSource glyph, vs.ICompletionSession session)
     : base(displayText, insertion, description, glyph, HtmlIconAutomationText.AttributeIconText, session)
 {
 }
Пример #10
0
 public SimpleHtmlCompletion(string displayText, string description, vs.ICompletionSession session)
     : base(displayText, displayText, description, _glyph, HtmlIconAutomationText.AttributeIconText, session)
 {
 }