示例#1
0
        protected IIntellisensePresenter FindPresenter
            (IIntellisenseSession session,
            IList <Lazy <IIntellisensePresenterProvider, IOrderableContentTypeMetadata> > orderedPresenterProviders,
            GuardedOperations guardedOperations)
        {
            var buffers = Helpers.GetBuffersForTriggerPoint(session);

            foreach (var presenterProviderExport in orderedPresenterProviders)
            {
                foreach (var buffer in buffers)
                {
                    foreach (var contentType in presenterProviderExport.Metadata.ContentTypes)
                    {
                        if (buffer.ContentType.IsOfType(contentType))
                        {
                            IIntellisensePresenter presenter = guardedOperations.InstantiateExtension(
                                session, presenterProviderExport,
                                factory => factory.TryCreateIntellisensePresenter(session));
                            if (presenter != null)
                            {
                                return(presenter);
                            }
                        }
                    }
                }
            }

            return(null);
        }
示例#2
0
        public void Recalculate()
        {
            if (IsDismissed)
            {
                throw new InvalidOperationException();
            }
            IsStarted = true;

            DisposeQuickInfoSources();
            quickInfoSources = CreateQuickInfoSources();

            var           newContent       = new List <object>();
            ITrackingSpan applicableToSpan = null;

            foreach (var source in quickInfoSources)
            {
                ITrackingSpan applicableToSpanTmp;
                source.AugmentQuickInfoSession(this, newContent, out applicableToSpanTmp);
                if (IsDismissed)
                {
                    return;
                }
                if (applicableToSpan == null)
                {
                    applicableToSpan = applicableToSpanTmp;
                }
            }

            if (newContent.Count == 0 || applicableToSpan == null)
            {
                Dismiss();
            }
            else
            {
                QuickInfoContent.BeginBulkOperation();
                QuickInfoContent.Clear();
                QuickInfoContent.AddRange(newContent);
                QuickInfoContent.EndBulkOperation();

                HasInteractiveContent = CalculateHasInteractiveContent();
                ApplicableToSpan      = applicableToSpan;
                if (quickInfoPresenter == null)
                {
                    quickInfoPresenter = intellisensePresenterFactoryService.TryCreateIntellisensePresenter(this);
                    if (quickInfoPresenter == null)
                    {
                        Dismiss();
                        return;
                    }
                    PresenterChanged?.Invoke(this, EventArgs.Empty);
                }
            }
            Recalculated?.Invoke(this, EventArgs.Empty);
        }
        public void Recalculate()
        {
            if (IsDismissed)
            {
                throw new InvalidOperationException();
            }
            bool firstTime = !IsStarted;

            IsStarted = true;
            if (firstTime && trackCaret)
            {
                TextView.Caret.PositionChanged += Caret_PositionChanged;
            }

            DisposeSignatureHelpSources();
            signatureHelpSources = CreateSignatureHelpSources();

            var list = new List <ISignature>();

            foreach (var source in signatureHelpSources)
            {
                source.AugmentSignatureHelpSession(this, list);
                if (IsDismissed)
                {
                    return;
                }
            }
            signatures.Clear();
            foreach (var sig in list)
            {
                signatures.Add(sig);
            }

            if (signatures.Count == 0)
            {
                Dismiss();
            }
            else
            {
                SelectedSignature = signatures[0];
                if (signatureHelpPresenter == null)
                {
                    signatureHelpPresenter = intellisensePresenterFactoryService.TryCreateIntellisensePresenter(this);
                    if (signatureHelpPresenter == null)
                    {
                        Dismiss();
                        return;
                    }
                    PresenterChanged?.Invoke(this, EventArgs.Empty);
                }
            }
            Recalculated?.Invoke(this, EventArgs.Empty);
        }
示例#4
0
        public void Recalculate()
        {
            if (IsDismissed)
            {
                throw new InvalidOperationException();
            }
            IsStarted = true;

            DisposeQuickInfoSources();
            quickInfoSources = CreateQuickInfoSources();

            QuickInfoContent.Clear();
            ITrackingSpan applicableToSpan = null;

            foreach (var source in quickInfoSources)
            {
                ITrackingSpan applicableToSpanTmp;
                source.AugmentQuickInfoSession(this, QuickInfoContent, out applicableToSpanTmp);
                if (applicableToSpan == null)
                {
                    applicableToSpan = applicableToSpanTmp;
                }
            }

            if (QuickInfoContent.Count == 0 || applicableToSpan == null)
            {
                Dismiss();
            }
            else
            {
                HasInteractiveContent = CalculateHasInteractiveContent();
                ApplicableToSpan      = applicableToSpan;
                if (quickInfoPresenter == null)
                {
                    quickInfoPresenter = quickInfoPresenterProvider.Create(this);
                    Debug.Assert(quickInfoPresenter != null);
                    PresenterChanged?.Invoke(this, EventArgs.Empty);
                }
            }

            Recalculated?.Invoke(this, EventArgs.Empty);
        }
示例#5
0
        public void Start()
        {
            if (IsStarted)
            {
                throw new InvalidOperationException();
            }
            if (IsDismissed)
            {
                throw new InvalidOperationException();
            }
            IsStarted         = true;
            completionSources = CreateCompletionSources();

            var list = new List <CompletionSet>();

            foreach (var source in completionSources)
            {
                source.AugmentCompletionSession(this, list);
            }
            foreach (var cc in list)
            {
                completionSets.Add(cc);
            }

            if (completionSets.Count == 0)
            {
                Dismiss();
            }
            else
            {
                SelectedCompletionSet = completionSets[0];
                completionPresenter   = intellisensePresenterFactoryService.TryCreateIntellisensePresenter(this);
                if (completionPresenter == null)
                {
                    Dismiss();
                    return;
                }
                PresenterChanged?.Invoke(this, EventArgs.Empty);
                completionSessionCommandTargetFilter = new CompletionSessionCommandTargetFilter(this);
            }
        }
示例#6
0
        public void Start()
        {
            if (IsStarted)
            {
                throw new InvalidOperationException();
            }
            if (IsDismissed)
            {
                throw new InvalidOperationException();
            }
            IsStarted = true;
            this.completionSources = CreateCompletionSources();

            var list = new List <CompletionCollection>();

            foreach (var source in completionSources)
            {
                source.AugmentCompletionSession(this, list);
            }
            foreach (var cc in list)
            {
                completionCollections.Add(cc);
            }

            if (completionCollections.Count == 0)
            {
                Dismiss();
            }
            else
            {
                SelectedCompletionCollection = completionCollections[0];
                completionPresenter          = completionPresenterProvider.Create(this);
                Debug.Assert(completionPresenter != null);
                PresenterChanged?.Invoke(this, EventArgs.Empty);
                completionSessionCommandTargetFilter = new CompletionSessionCommandTargetFilter(this);
            }
        }
示例#7
0
		public void Recalculate() {
			if (IsDismissed)
				throw new InvalidOperationException();
			IsStarted = true;

			DisposeQuickInfoSources();
			quickInfoSources = CreateQuickInfoSources();

			var newContent = new List<object>();
			ITrackingSpan applicableToSpan = null;
			foreach (var source in quickInfoSources) {
				ITrackingSpan applicableToSpanTmp;
				source.AugmentQuickInfoSession(this, newContent, out applicableToSpanTmp);
				if (IsDismissed)
					return;
				if (applicableToSpan == null)
					applicableToSpan = applicableToSpanTmp;
			}

			if (newContent.Count == 0 || applicableToSpan == null)
				Dismiss();
			else {
				QuickInfoContent.BeginBulkOperation();
				QuickInfoContent.Clear();
				QuickInfoContent.AddRange(newContent);
				QuickInfoContent.EndBulkOperation();

				HasInteractiveContent = CalculateHasInteractiveContent();
				ApplicableToSpan = applicableToSpan;
				if (quickInfoPresenter == null) {
					quickInfoPresenter = intellisensePresenterFactoryService.TryCreateIntellisensePresenter(this);
					if (quickInfoPresenter == null) {
						Dismiss();
						return;
					}
					PresenterChanged?.Invoke(this, EventArgs.Empty);
				}
			}
			Recalculated?.Invoke(this, EventArgs.Empty);
		}
示例#8
0
 public virtual void Dismiss()
 {
     this.properties = null;
     this.presenter  = null;
 }
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (autocompleteMode == AutocompleteModeType.Off ||
                VsShellUtilities.IsInAutomationFunction(m_provider.ServiceProvider))
            {
                return(m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }
            //make a copy of this so we can look at it after forwarding some commands
            uint commandID = nCmdID;
            char typedChar = char.MinValue;

            //make sure the input is a char before getting it
            if (pguidCmdGroup == VSConstants.VSStd2K && nCmdID == (uint)VSConstants.VSStd2KCmdID.TYPECHAR)
            {
                typedChar = (char)(ushort)Marshal.GetObjectForNativeVariant(pvaIn);
            }

            //check for a commit character
            if (nCmdID == (uint)VSConstants.VSStd2KCmdID.RETURN ||
                nCmdID == (uint)VSConstants.VSStd2KCmdID.TAB ||
                char.IsPunctuation(typedChar) && typedChar != '.')
            {
                //check for a a selection
                if (m_session != null && !m_session.IsDismissed)
                {
                    //if the selection is fully selected, commit the current session
                    if (m_session.SelectedCompletionSet.SelectionStatus.IsSelected)
                    {
                        m_session.Commit();
                        //also, don't add the character to the buffer
                        if (typedChar != '.')
                        {
                            return(VSConstants.S_OK);
                        }
                    }
                    else
                    {
                        //if there is no selection, dismiss the session
                        m_session.Dismiss();
                    }
                }
            }

            // Dismiss session when whitespace is pressed.
            if (char.IsWhiteSpace(typedChar) && m_session != null && !m_session.IsDismissed)
            {
                m_session.Dismiss();
            }

            //pass along the command so the char is added to the buffer
            int  retVal  = m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
            bool handled = false;

            if (!typedChar.Equals(char.MinValue) && (char.IsLetterOrDigit(typedChar) || typedChar == '.'))
            {
                if ((m_session == null || m_session.IsDismissed) && autocompleteMode == AutocompleteModeType.Automatic) // If there is no active session, bring up completion
                {
                    this.TriggerCompletion();
                    if (m_session != null && typedChar != '.')
                    {
                        m_session.Filter();
                    }
                }
                else     //the completion session is already active, so just filter
                {
                    if (m_session.SelectedCompletionSet != null &&
                        m_session.SelectedCompletionSet.Completions != null &&
                        m_session.SelectedCompletionSet.Completions.Count > 0 &&
                        m_session.SelectedCompletionSet.Completions[0].InsertionText.StartsWith("."))
                    {
                        // For sorm reason m_session.Filter() filters by DisplayName, not InsertionText no matter what.
                        // Probbly need to remimplement it in order to work properly, otherwise just restarting completion session.
                        m_session.Dismiss();
                        this.TriggerCompletion();
                    }
                    else
                    {
                        m_session.Filter();
                    }
                }

                if (m_session != null && m_session.Presenter != null)
                {
                    handled = true;
                    dynamic presenter = ExposedObject.From(m_session.Presenter);
                    IIntellisensePresenter intelisensePresenter           = m_session.Presenter;
                    System.Windows.Controls.ContentControl surfaceElement = (System.Windows.Controls.ContentControl)presenter.SurfaceElement;
                    surfaceElement.Focus();
                }
            }
            else if ((autocompleteMode == AutocompleteModeType.Automatic || autocompleteMode == AutocompleteModeType.CtrlSpace) &&
                     (commandID == (uint)VSConstants.VSStd2KCmdID.AUTOCOMPLETE || commandID == (uint)VSConstants.VSStd2KCmdID.COMPLETEWORD))
            {
                // Trigger completion on Ctrl + Space
                if (m_session == null || m_session.IsDismissed) // If there is no active session, bring up completion
                {
                    this.TriggerCompletion();


                    if (m_session != null && GetLastTypedCharter() != '.')
                    {
                        m_session.Filter();
                    }
                }
            }
            else if (commandID == (uint)VSConstants.VSStd2KCmdID.BACKSPACE || //redo the filter if there is a deletion
                     commandID == (uint)VSConstants.VSStd2KCmdID.DELETE)
            {
                if (m_session != null && !m_session.IsDismissed)
                {
                    m_session.Filter();
                }
                handled = true;
            }
            if (handled)
            {
                return(VSConstants.S_OK);
            }
            return(retVal);
        }
示例#10
0
		public void Recalculate() {
			if (IsDismissed)
				throw new InvalidOperationException();
			bool firstTime = !IsStarted;
			IsStarted = true;
			if (firstTime && trackCaret)
				TextView.Caret.PositionChanged += Caret_PositionChanged;

			DisposeSignatureHelpSources();
			signatureHelpSources = CreateSignatureHelpSources();

			var list = new List<ISignature>();
			foreach (var source in signatureHelpSources) {
				source.AugmentSignatureHelpSession(this, list);
				if (IsDismissed)
					return;
			}
			signatures.Clear();
			foreach (var sig in list)
				signatures.Add(sig);

			if (signatures.Count == 0)
				Dismiss();
			else {
				SelectedSignature = signatures[0];
				if (signatureHelpPresenter == null) {
					signatureHelpPresenter = intellisensePresenterFactoryService.TryCreateIntellisensePresenter(this);
					if (signatureHelpPresenter == null) {
						Dismiss();
						return;
					}
					PresenterChanged?.Invoke(this, EventArgs.Empty);
				}
			}
			Recalculated?.Invoke(this, EventArgs.Empty);
		}
示例#11
0
		public void Start() {
			if (IsStarted)
				throw new InvalidOperationException();
			if (IsDismissed)
				throw new InvalidOperationException();
			IsStarted = true;
			completionSources = CreateCompletionSources();

			var list = new List<CompletionSet>();
			foreach (var source in completionSources)
				source.AugmentCompletionSession(this, list);
			foreach (var cc in list)
				completionSets.Add(cc);

			if (completionSets.Count == 0)
				Dismiss();
			else {
				SelectedCompletionSet = completionSets[0];
				completionPresenter = intellisensePresenterFactoryService.TryCreateIntellisensePresenter(this);
				if (completionPresenter == null) {
					Dismiss();
					return;
				}
				PresenterChanged?.Invoke(this, EventArgs.Empty);
				completionSessionCommandTargetFilter = new CompletionSessionCommandTargetFilter(this);
			}
		}