当前位置: 首页>>代码示例>>C#>>正文


C# ICompletionSession.Start方法代码示例

本文整理汇总了C#中ICompletionSession.Start方法的典型用法代码示例。如果您正苦于以下问题:C# ICompletionSession.Start方法的具体用法?C# ICompletionSession.Start怎么用?C# ICompletionSession.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICompletionSession的用法示例。


在下文中一共展示了ICompletionSession.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TriggerCompletion

        private bool TriggerCompletion()
        {
            //the caret must be in a non-projection location
            SnapshotPoint? caretPoint =
            m_textView.Caret.Position.Point.GetPoint(
            textBuffer => (!textBuffer.ContentType.IsOfType("projection")), PositionAffinity.Predecessor);
            if (!caretPoint.HasValue)
            {
                return false;
            }

            m_session = m_provider.CompletionBroker.CreateCompletionSession
             (m_textView,
                caretPoint.Value.Snapshot.CreateTrackingPoint(caretPoint.Value.Position, PointTrackingMode.Positive),
                true);

            //subscribe to the Dismissed event on the session
            m_session.Dismissed += this.OnSessionDismissed;
            m_session.Start();

            return true;
        }
开发者ID:kevin1michael,项目名称:VSLua,代码行数:22,代码来源:CompletionCommandHandler.cs

示例2: StartSession

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

      var caret = _wpfTextView.Caret.Position.BufferPosition;
      var snapshot = caret.Snapshot;

      _session = _provider.CompletionBroker.CreateCompletionSession(
        _wpfTextView, snapshot.CreateTrackingPoint(caret, PointTrackingMode.Positive), true);
      _session.Dismissed += _currentSession_Dismissed;
      _session.Start();

      return true;
    }
开发者ID:rsdn,项目名称:nitra,代码行数:15,代码来源:NitraCompletionCommandHandler.cs

示例3: VisualElement_KeyDown

        /// <summary>
        /// Triggers Statement completion when appropriate keys are pressed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void VisualElement_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            // Make sure that this event happened on the same text view to which we're attached.
            ITextView textView = sender as ITextView;
            if (this.subjectTextView != textView)
                return;

            // if there is a session already leave it be
            if (activeSession != null)
                return;

            // determine which subject buffer is affected by looking at the caret position
            SnapshotPoint? caret = textView.Caret.Position.Point.GetPoint
                (textBuffer =>
                    (
                        subjectBuffers.Contains(textBuffer)
                        && provider.nodeProviderBroker.IsNDjango(textBuffer, context)
                        && provider.CompletionBrokerMapService.GetBrokerForTextView(textView, textBuffer) != null
                    ),
                    PositionAffinity.Predecessor);

            // return if no suitable buffer found
            if (!caret.HasValue)
                return;

            SnapshotPoint caretPoint = caret.Value;

            var subjectBuffer = caretPoint.Snapshot.TextBuffer;

            CompletionContext completionContext =
                CompletionSet.GetCompletionContext(e.Key, subjectBuffer, caretPoint.Position);

            if (completionContext == CompletionContext.None)
                return;

            // the invocation occurred in a subject buffer of interest to us
            ICompletionBroker broker = provider.CompletionBrokerMapService.GetBrokerForTextView(textView, subjectBuffer);
            triggerPosition = caretPoint.Position;
            ITrackingPoint triggerPoint = caretPoint.Snapshot.CreateTrackingPoint(triggerPosition, PointTrackingMode.Negative);
            completionSpan = caretPoint.Snapshot.CreateTrackingSpan(caretPoint.Position, 0, SpanTrackingMode.EdgeInclusive);

            // attach filter to intercept the Enter key
            attachKeyboardFilter();

            // Create a completion session
            activeSession = broker.CreateCompletionSession(triggerPoint, true);

            // Put the completion context and original (empty) completion span
            // on the session so that it can be used by the completion source
            activeSession.Properties.AddProperty(typeof(CompletionContext), completionContext);
            activeSession.Properties.AddProperty(typeof(Controller), completionSpan);

            // Attach to the session events
            activeSession.Dismissed += new System.EventHandler(OnActiveSessionDismissed);
            activeSession.Committed += new System.EventHandler(OnActiveSessionCommitted);

            // Start the completion session. The intellisense will be triggered.
            activeSession.Start();
        }
开发者ID:IntranetFactory,项目名称:ndjango,代码行数:64,代码来源:Controller.cs

示例4: PresentItems

        public void PresentItems(
            ITrackingSpan triggerSpan,
            IList<PresentationItem> completionItems,
            PresentationItem selectedItem,
            PresentationItem suggestionModeItem,
            bool suggestionMode,
            bool isSoftSelected,
            ImmutableArray<CompletionItemFilter> completionItemFilters,
            IReadOnlyDictionary<CompletionItem, string> completionItemToFilterText)
        {
            AssertIsForeground();

            // check if this update is still relevant
            if (_textView.IsClosed || _isDismissed)
            {
                return;
            }

            if (triggerSpan != null)
            {
                _completionSet.SetTrackingSpan(triggerSpan);
            }

            _ignoreSelectionStatusChangedEvent = true;
            try
            {
                _completionSet.SetCompletionItems(
                    completionItems, selectedItem, suggestionModeItem, suggestionMode, 
                    isSoftSelected, completionItemFilters, completionItemToFilterText);
            }
            finally
            {
                _ignoreSelectionStatusChangedEvent = false;
            }

            if (_editorSessionOpt == null)
            {
                // We're tracking the caret.  Don't have the editor do it. 
                // Map the span instead of a point to avoid affinity problems.
                _editorSessionOpt = _completionBroker.CreateCompletionSession(
                    _textView,
                    triggerSpan.GetStartTrackingPoint(PointTrackingMode.Negative),
                    trackCaret: false);

                var debugTextView = _textView as IDebuggerTextView;
                if (debugTextView != null && !debugTextView.IsImmediateWindow)
                {
                    debugTextView.HACK_StartCompletionSession(_editorSessionOpt);
                }

                _editorSessionOpt.Dismissed += (s, e) => OnEditorSessionDismissed();

                // So here's the deal.  We cannot create the editor session and give it the right
                // items (even though we know what they are).  Instead, the session will call
                // back into the ICompletionSourceProvider (which is us) to get those values. It
                // will pass itself along with the calls back into ICompletionSourceProvider.
                // So, in order to make that connection work, we add properties to the session
                // so that we can call back into ourselves, get the items and add it to the
                // session.
                _editorSessionOpt.Properties.AddProperty(Key, this);
                _editorSessionOpt.Start();
            }

            // Call so that the editor will refresh the completion text to embolden.
            _editorSessionOpt?.Match();
        }
开发者ID:rgani,项目名称:roslyn,代码行数:66,代码来源:CompletionPresenterSession.cs

示例5: TriggerCompletion

        private void TriggerCompletion()
        {
            //the caret must be in a non-projection location 
            var caretPoint =
                _textView.Caret.Position.Point.GetPoint(x => (true), PositionAffinity.Predecessor);

            if (!caretPoint.HasValue) return;

            _session = _provider.CompletionBroker.CreateCompletionSession
                (_textView,
                    caretPoint.Value.Snapshot.CreateTrackingPoint(caretPoint.Value.Position, PointTrackingMode.Positive),
                    true);

            //subscribe to the Dismissed event on the session
            _session.Dismissed += OnSessionDismissed;
            _session.Start();
        }
开发者ID:kkrnt,项目名称:hsp.vs,代码行数:17,代码来源:HSPCompletionHandler.cs

示例6: StartAutoCompleteSession

        protected bool StartAutoCompleteSession()
        {
            if (IsAutoCompleteSessionActive)
                return false;

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

            if (!ShouldCompletionBeDiplayed(caret)) 
                return false;

            currentAutoCompleteSession = !Broker.IsCompletionActive(TextView) ? 
                                                                                  Broker.CreateCompletionSession(TextView, snapshot.CreateTrackingPoint(caret, PointTrackingMode.Positive), true) : 
                                                                                                                                                                                                      Broker.GetSessions(TextView)[0];

            currentAutoCompleteSession.Start();
            currentAutoCompleteSession.Dismissed += (sender, args) => currentAutoCompleteSession = null;

            return true;
        }
开发者ID:heinrichbreedt,项目名称:SpecFlow,代码行数:20,代码来源:CompletionCommandFilter.cs

示例7: TriggerCompletion

        void TriggerCompletion()
        {
            if (CommandExpansion == null)
            {
                return; // Host CommandExpansion service not available
            }

            if (IsCompletionSessionActive)
            {
                _completionSession.Dismiss();
                _completionSession = null;
            }

            string line = WpfConsole.InputLineText;
            int caretIndex = CaretPosition - WpfConsole.InputLineStart.Value;
            Debug.Assert(caretIndex >= 0);

            SimpleExpansion simpleExpansion = null;
            try
            {
                simpleExpansion = CommandExpansion.GetExpansions(line, caretIndex);
            }
            catch (Exception x)
            {
                // Ignore exception from expansion, but write it to the activity log
                ExceptionHelper.WriteToActivityLog(x);
            }

            if (simpleExpansion != null && simpleExpansion.Expansions != null)
            {
                IList<string> expansions = simpleExpansion.Expansions;
                if (expansions.Count == 1) // Shortcut for 1 TabExpansion candidate
                {
                    ReplaceTabExpansion(simpleExpansion.Start, simpleExpansion.Length, expansions[0]);
                }
                else if (expansions.Count > 1) // Only start intellisense session for multiple expansion candidates
                {
                    _completionSession = CompletionBroker.CreateCompletionSession(
                        WpfTextView,
                        WpfTextView.TextSnapshot.CreateTrackingPoint(CaretPosition.Position, PointTrackingMode.Positive),
                        true);
                    _completionSession.Properties.AddProperty("TabExpansion", simpleExpansion);
                    _completionSession.Dismissed += CompletionSession_Dismissed;
                    _completionSession.Start();
                }
            }
        }
开发者ID:happylancer,项目名称:node-tools,代码行数:47,代码来源:WpfConsoleKeyProcessor.cs

示例8: OnKeyDown

        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            // Make sure that this event happened on the same text view to which we're attached.
            ITextView textView = sender as ITextView;
            if (this.subjectTextView != textView)
                return;

            // if there is a session already leave it be
            if (activeSession != null)
                return;

            // determine which subject buffer is affected by looking at the caret position
            SnapshotPoint? caret = textView.Caret.Position.Point.GetPoint(textBuffer => (
                    subjectBuffers.Contains(textBuffer)),
                    PositionAffinity.Predecessor);

            // return if no suitable buffer found
            if (!caret.HasValue)
                return;

            SnapshotPoint caretPoint = caret.Value;
            ITextSnapshotLine line = caretPoint.GetContainingLine();
            SnapshotSpan span = new SnapshotSpan(line.Start, line.End);

            if (span.IsComment() || span.IsCommand())
                return;

            // the invocation occurred in a subject buffer of interest to us
            triggerPosition = caretPoint.Position;
            ITrackingPoint triggerPoint = caretPoint.Snapshot.CreateTrackingPoint(triggerPosition, PointTrackingMode.Negative);
            completionSpan = caretPoint.Snapshot.CreateTrackingSpan(caretPoint.Position, 0, SpanTrackingMode.EdgeInclusive);

            // Create a completion session
            activeSession = completionBroker.CreateCompletionSession(textView, triggerPoint, true);

            // Put the completion context and original (empty) completion span
            // on the session so that it can be used by the completion source
            activeSession.Properties.AddProperty(typeof(ApacheIntellisenseController), completionSpan);

            // Attach to the session events
            activeSession.Dismissed += new System.EventHandler(OnActiveSessionDismissed);
            activeSession.Committed += new System.EventHandler(OnActiveSessionCommitted);

            // Start the completion session. The intellisense will be triggered.
            activeSession.Start();
        }
开发者ID:managedfusion,项目名称:managedfusion-rewriter-visualstudio,代码行数:46,代码来源:ApacheIntellisenseController.cs

示例9: TriggerCompletion

        /// <summary>
        /// Trigger completion.
        /// </summary>
        private void TriggerCompletion()
        {
            // the caret must be in a non-projection location
            var caretPoint = textView.Caret.Position.Point.GetPoint(textBuffer => (!textBuffer.ContentType.IsOfType("projection")), PositionAffinity.Predecessor);
            if (!caretPoint.HasValue)
            {
                return;
            }

            var cp = (SnapshotPoint)caretPoint;
            var position = cp.Position;

            // check for "//" before the current cursor position in this line
            var line = ((SnapshotPoint)caretPoint).Snapshot.GetLineFromPosition(((SnapshotPoint)caretPoint).Position);

            // get the text of this line
            var text = line.GetText();

            // get only the text portion which is left of the actual position
            text = text.Substring(0, position - line.Start.Position);

            // if there is a comment starting, don't do auto completion
            if (text.IndexOf("//", StringComparison.CurrentCultureIgnoreCase) != -1)
            {
                return;
            }

            var lex = new Lexer(cp.Snapshot.GetText());
            lex.AnalyzeForCommentsOnly();

            var res = lex.Tokens.FirstOrDefault(x => x.Position < cp.Position && x.Position + x.Length >= cp.Position);

            if (res != null)
            {
                return;
            }

            session = provider.CompletionBroker.CreateCompletionSession(textView, caretPoint.Value.Snapshot.CreateTrackingPoint(caretPoint.Value.Position, PointTrackingMode.Positive), true);

            // subscribe to the Dismissed event on the session
            session.Dismissed += OnSessionDismissed;
            session.Start();
        }
开发者ID:mreu,项目名称:ProtobufLanguageService,代码行数:46,代码来源:CompletionHandler.cs

示例10: VisualElement_KeyDown

        /// <summary>
        /// Triggers Statement completion when appropriate keys are pressed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void VisualElement_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            // Make sure that this event happened on the same text view to which we're attached.
            ITextView textView = sender as ITextView;
            if (this.subjectTextView != textView)
            {
                return;
            }

            // we only start the session when an alphanumeric key is pressed
            if (!(e.Key >= Key.A && e.Key <= Key.Z))
                return;

            // if there is a session already leave it be
            if (activeSession != null)
                return;

            // determine which subject buffer is affected by looking at the caret position
            SnapshotPoint? caretPoint = textView.Caret.Position.Point.GetPoint
                (textBuffer =>
                    (
                        subjectBuffers.Contains(textBuffer)
                        && provider.nodeProviderBroker.IsNDjango(textBuffer, context)
                        && provider.CompletionBrokerMapService.GetBrokerForTextView(textView, textBuffer) != null
                    ),
                    PositionAffinity.Predecessor);

            // return if no suitable buffer found
            if (!caretPoint.HasValue)
                return;

            List<INode> completionNodes =
                provider.nodeProviderBroker.GetNodeProvider(caretPoint.Value.Snapshot.TextBuffer).GetNodes(caretPoint.Value)
                    .FindAll(node => node.Values.Count() > 0);

            // return if there is no information to show
            if (completionNodes.Count == 0)
                return;

            // attach filter to intercept the Enter key
            attachKeyboardFilter();

            // the invocation occurred in a subject buffer of interest to us
            ICompletionBroker broker = provider.CompletionBrokerMapService.GetBrokerForTextView(textView, caretPoint.Value.Snapshot.TextBuffer);
            ITrackingPoint triggerPoint = caretPoint.Value.Snapshot.CreateTrackingPoint(caretPoint.Value.Position, PointTrackingMode.Positive);

            // Create a completion session
            activeSession = broker.CreateCompletionSession(triggerPoint, true);

            // Put the list of completion nodes on the session so that it can be used by the completion source
            activeSession.Properties.AddProperty(typeof(Source), completionNodes);

            // Attach to the session events
            activeSession.Dismissed += new System.EventHandler(OnActiveSessionDismissed);
            activeSession.Committed += new System.EventHandler(OnActiveSessionCommitted);

            // Start the completion session. The intellisense will be triggered.
            activeSession.Start();
        }
开发者ID:IntranetFactory,项目名称:ndjango,代码行数:64,代码来源:Controller.cs

示例11: StartSession

        private void StartSession()
        {
            var caretPosition = wpfTextView.Caret.Position.Point.GetPoint(
                buffer => (!buffer.ContentType.IsOfType("projection")), PositionAffinity.Predecessor);

            if (!caretPosition.HasValue)
            {
                throw new InvalidOperationException("Cannot get carret point.");
            }

            session = autoCompletionHandlerProvider.CompletionBroker.CreateCompletionSession(
                wpfTextView,
                caretPosition.Value.Snapshot.CreateTrackingPoint(caretPosition.Value.Position, PointTrackingMode.Positive),
                true);

            session.Dismissed += SessionDismissed;

            session.Start();

            if (session != null)
            {
                session.Filter();
            }
        }
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:24,代码来源:AutoCompletionHandler.cs

示例12: TriggerCompletion

        private bool TriggerCompletion()
        {
            //the caret must be in a non-projection location
            SnapshotPoint? caretPoint =
                    _TextView.Caret.Position.Point
                            .GetPoint( textBuffer => !IsProjection( textBuffer ), PositionAffinity.Predecessor );
            if ( !caretPoint.HasValue )
            {
                return false;
            }

            _Session = _CompletionHandlerProvider.CompletionBroker.CreateCompletionSession
                    ( _TextView,
                      caretPoint.Value.Snapshot.CreateTrackingPoint( caretPoint.Value.Position,
                                                                     PointTrackingMode.Positive ),
                      true );

            //subscribe to the Dismissed event on the session
            _Session.Dismissed += OnSessionDismissed;
            _Session.Start();

            return true;
        }
开发者ID:IntelliTect,项目名称:PowerStudio,代码行数:23,代码来源:CompletionCommandHandler.cs

示例13: TriggerCompletion

        private bool TriggerCompletion()
        {
            SnapshotPoint? caretPoint = textView.Caret.Position.Point.GetPoint(textBuffer => !textBuffer.ContentType.IsOfType("projection"), PositionAffinity.Predecessor);
            if (caretPoint.HasValue)
            {

                completionSession = completionHandlerProvider.CompletionBroker.CreateCompletionSession(textView, caretPoint.Value.Snapshot.CreateTrackingPoint(caretPoint.Value.Position, PointTrackingMode.Positive), true);
                completionSession.Dismissed += completionSession_Dismissed;
                completionSession.Start();
                return true;
            }

            return false;
        }
开发者ID:WilliamChao,项目名称:ShaderlabVS,代码行数:14,代码来源:ShaderlabCodeCompletion.cs

示例14: StartSession

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

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

            _currentSession = Broker.CreateCompletionSession(TextView, snapshot.CreateTrackingPoint(caret, PointTrackingMode.Positive), true);
            _currentSession.Start();

            _currentSession.Dismissed += (sender, args) => _currentSession = null;

            return true;
        }
开发者ID:smartmobili,项目名称:parsing,代码行数:15,代码来源:CompletionController.cs

示例15: StartSession

 private void StartSession(ITrackingPoint triggerPoint)
 {
     Log.Debug("Creating new completion session...");
     _activeSession = _broker.CreateCompletionSession(_textView, triggerPoint, true);
     _activeSession.Properties.AddProperty(BufferProperties.SessionOriginIntellisense, "Intellisense");
     _activeSession.Dismissed += CompletionSession_Dismissed;
     _activeSession.Start();
 }
开发者ID:vairam-svs,项目名称:poshtools,代码行数:8,代码来源:IntelliSenseManager.cs


注:本文中的ICompletionSession.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。