public IIntellisensePresenter TryCreateIntellisensePresenter(IIntellisenseSession session)
        {
            ICompletionSession completionSession = session as ICompletionSession;
            if (completionSession == null) return null;

            return new SparkSensePresenter(completionSession);
        }
 private ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, IIntellisenseSession session)
 {
     var currentPoint = (session.TextView.Caret.Position.BufferPosition) - 1;
     var navigator = _sourceProvider.NavigatorService.GetTextStructureNavigator(_textBuffer);
     var extent = navigator.GetExtentOfWord(currentPoint);
     return currentPoint.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive);
 }
		public IIntellisensePresenter TryCreateIntellisensePresenter(IIntellisenseSession session) {
			var quickInfoSession = session as IQuickInfoSession;
			if (quickInfoSession == null)
				return null;
			if (quickInfoSession.TrackMouse)
				return new QuickInfoPresenter(quickInfoSession);
			return new SpaceReservationQuickInfoPresenter(quickInfoSession);
		}
 public IIntellisensePresenter TryCreateIntellisensePresenter(IIntellisenseSession session) {
   IQuickInfoSession qiSession = session as IQuickInfoSession;
   if ( qiSession != null ) {
     if ( qiSession.Get<RainbowToolTipContext>() != null ) {
       return new RainbowToolTipPresenter(qiSession, this);
     }
   }
   return null;
 }
        public IIntellisensePresenter TryCreateIntellisensePresenter(IIntellisenseSession session)
        {
            ICompletionSession completionSession = session as ICompletionSession;
            if (completionSession != null)
            {
                return new CompletionSessionPresenter(ServiceProvider, completionSession);
            }

            return null;
        }
		public void SessionCreated(IIntellisenseSession session) {
			if (session == null)
				throw new ArgumentNullException(nameof(session));
			if (!CurrentLineSpaceReservationAgent.IsSupportedSession(session))
				return;
			var wpfTextView = session.TextView as IWpfTextView;
			Debug.Assert(wpfTextView != null);
			if (wpfTextView == null)
				return;
			var currentLineAgent = session.TextView.Properties.GetOrCreateSingletonProperty(typeof(CurrentLineSpaceReservationAgent), () => new CurrentLineSpaceReservationAgent(wpfTextView));
			currentLineAgent.SessionCreated(session);
		}
		public IIntellisensePresenter TryCreateIntellisensePresenter(IIntellisenseSession session) {
			if (session == null)
				throw new ArgumentNullException(nameof(session));
			var contentTypes = session.TextView.BufferGraph.GetTextBuffers(a => session.GetTriggerPoint(a) != null).Select(a => a.ContentType).ToArray();
			foreach (var lz in intellisensePresenterProviders) {
				foreach (var contentType in contentTypes) {
					if (!contentType.IsOfAnyType(lz.Metadata.ContentTypes))
						continue;
					var presenter = lz.Value.TryCreateIntellisensePresenter(session);
					if (presenter != null)
						return presenter;
				}
			}
			return null;
		}
        IIntellisensePresenter IIntellisensePresenterProvider.TryCreateIntellisensePresenter(IIntellisenseSession session)
        {
            // If this is not associated with an IWordCompletionSession then we don't want to special case
            // this in any way
            if (!session.Properties.ContainsProperty(WordCompletionSessionFactoryService.WordCompletionSessionKey))
            {
                return null;
            }

            foreach (var provider in Providers)
            {
                if (provider == this)
                {
                    // Don't consider 'this' here.  It would lead to an infinite loop
                    continue;
                }

                try
                {
                    var presenter = provider.TryCreateIntellisensePresenter(session);
                    var popupPresenter = presenter as IPopupIntellisensePresenter;

                    // We only need to wrap IPopupIntellisensePresenter values as they are the
                    // only ones which expose opacity
                    if (popupPresenter != null)
                    {
                        return new WordCompletionPresenter(popupPresenter);
                    }

                    if (presenter != null)
                    {
                        return presenter;
                    }
                }
                catch (Exception)
                {
                    // Move onto the next provider
                }
            }

            return null;
        }
        public void MoveSessionToTop(IIntellisenseSession session)
        {
            if (wpfTextView.IsClosed)
            {
                throw new InvalidOperationException();
            }
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }
            int index = sessions.IndexOf(session);

            if (index < 0)
            {
                throw new InvalidOperationException();
            }
            if (index == 0)
            {
                return;
            }
            sessions.Move(index, 0);
        }
Exemplo n.º 10
0
        internal static Xwt.Rectangle GetScreenRect(IIntellisenseSession session)
        {
            return(Xwt.MessageDialog.RootWindow.Screen.VisibleBounds);
            //TODO
            //if ((session != null) && (session.TextView != null)) {
            //  Visual sessionViewVisual = ((IWpfTextView)session.TextView).VisualElement;
            //  if ((sessionViewVisual != null) && PresentationSource.FromVisual (sessionViewVisual) != null) {
            //      Rect nativeScreenRect = WpfHelper.GetScreenRect (sessionViewVisual.PointToScreen (new Point (0, 0)));
            //      return new Rect
            //         (0,
            //          0,
            //          nativeScreenRect.Width * WpfHelper.DeviceScaleX,
            //          nativeScreenRect.Height * WpfHelper.DeviceScaleY);
            //  }
            //}

            //return new Rect
            //  (0,
            //   0,
            //   SystemParameters.PrimaryScreenWidth * WpfHelper.DeviceScaleX,
            //   SystemParameters.PrimaryScreenHeight * WpfHelper.DeviceScaleY);
        }
Exemplo n.º 11
0
 public void PushSession(IIntellisenseSession session)
 {
     if (wpfTextView.IsClosed)
     {
         throw new InvalidOperationException();
     }
     if (session == null)
     {
         throw new ArgumentNullException(nameof(session));
     }
     if (sessions.Contains(session))
     {
         throw new InvalidOperationException();
     }
     if (sessions.Count == 0)
     {
         commandTargetFilter.HookKeyboard();
     }
     sessions.Insert(0, session);
     session.Dismissed        += Session_Dismissed;
     session.PresenterChanged += Session_PresenterChanged;
     PresenterUpdated(session);
 }
Exemplo n.º 12
0
        private void DoleOutKeyboard()
        {
            if (_keyboardSession != null)
            {
                this.ReleaseKeyboard();
            }

            // The idea is to walk down the stack from top to bottom, looking for the first session that has a presenter.  When we
            // find it, give it the keyboard, unless it already has it.

            foreach (IIntellisenseSession session in _sessions)
            {
                ICustomKeyboardHandler keyboardHandler = session.Presenter as ICustomKeyboardHandler;
                if (keyboardHandler != null)
                {
                    if (keyboardHandler.CaptureKeyboard())
                    {
                        _keyboardSession = session;
                        break;
                    }
                }
            }
        }
Exemplo n.º 13
0
 public static IEditorIntellisenseSession ToEditorIntellisenseSession(this IIntellisenseSession session)
 => session.Properties.TryGetProperty(EditorIntellisenseSession.SessionKey, out IEditorIntellisenseSession es) ? es : null;
Exemplo n.º 14
0
        IIntellisensePresenter IIntellisensePresenterProvider.TryCreateIntellisensePresenter(IIntellisenseSession session)
        {
            // If this is not associated with an IWordCompletionSession then we don't want to special case
            // this in any way
            if (!session.Properties.ContainsProperty(WordCompletionSessionFactoryService.WordCompletionSessionKey))
            {
                return(null);
            }

            foreach (var provider in Providers)
            {
                if (provider == this)
                {
                    // Don't consider 'this' here.  It would lead to an infinite loop
                    continue;
                }

                try
                {
                    var presenter      = provider.TryCreateIntellisensePresenter(session);
                    var popupPresenter = presenter as IPopupIntellisensePresenter;

                    // We only need to wrap IPopupIntellisensePresenter values as they are the
                    // only ones which expose opacity
                    if (popupPresenter != null)
                    {
                        return(new WordCompletionPresenter(popupPresenter));
                    }

                    if (presenter != null)
                    {
                        return(presenter);
                    }
                }
                catch (Exception)
                {
                    // Move onto the next provider
                }
            }

            return(null);
        }
		public IIntellisensePresenter TryCreateIntellisensePresenter(IIntellisenseSession session) {
			var completionSession = session as ICompletionSession;
			if (completionSession == null)
				return null;
			return new CompletionPresenter(imageMonikerService, completionSession, completionTextElementProviderService.Value.Create(), completionUIElementProviders);
		}
 public SimpleCompletionEntry(string displayText, string insertionText, string description, IIntellisenseSession session)
     : base(displayText, insertionText, description, _glyph, null, false, session as ICompletionSession)
 { }
Exemplo n.º 17
0
 public void PushSession(IIntellisenseSession session)
 {
     session.Dismissed += session_Dismissed;
     _stack.Add(session);
 }
		public IIntellisensePresenter TryCreateIntellisensePresenter(IIntellisenseSession session) {
			var signatureHelpSession = session as ISignatureHelpSession;
			if (signatureHelpSession == null)
				return null;
			return new SignatureHelpPresenter(signatureHelpSession, textBufferFactoryService, contentTypeRegistryService, classifierAggregatorService, classificationFormatMapService.GetClassificationFormatMap(AppearanceCategoryConstants.SignatureHelpToolTip));
		}
Exemplo n.º 19
0
		public void MoveSessionToTop(IIntellisenseSession session) {
			if (wpfTextView.IsClosed)
				throw new InvalidOperationException();
			if (session == null)
				throw new ArgumentNullException(nameof(session));
			int index = sessions.IndexOf(session);
			if (index < 0)
				throw new InvalidOperationException();
			if (index == 0)
				return;
			sessions.Move(index, 0);
		}
Exemplo n.º 20
0
 public SimpleCompletionEntry(string text, ImageSource glyph, IIntellisenseSession session)
     : this(text, null, glyph, session)
 { }
Exemplo n.º 21
0
 public SimpleCompletionEntry(string text, string description, ImageMoniker moniker, IIntellisenseSession session)
     : base(text, "\"" + text + "\"", description, WpfUtil.GetIconForImageMoniker(moniker, 16, 16), null, false, session as ICompletionSession)
 { }
Exemplo n.º 22
0
			public SessionState(IIntellisenseSession session) {
				Session = session;
			}
Exemplo n.º 23
0
 public SimpleCompletionEntry(string text, ImageMoniker moniker, IIntellisenseSession session)
     : this(text, null, WpfUtil.GetIconForImageMoniker(moniker, 16, 16), session)
 { }
Exemplo n.º 24
0
		void PresenterUpdated(IIntellisenseSession session) {
			var sessionState = GetSessionState(session);
			if (sessionState.SpaceReservationAgent != null)
				sessionState.SpaceReservationManager.RemoveAgent(sessionState.SpaceReservationAgent);
			Debug.Assert(sessionState.SpaceReservationAgent == null);

			var presenter = session.Presenter;
			var popupPresenter = presenter as IPopupIntellisensePresenter;
			if (popupPresenter != null) {
				if (sessionState.SpaceReservationManager == null) {
					sessionState.SetSpaceReservationManager(wpfTextView.GetSpaceReservationManager(popupPresenter.SpaceReservationManagerName));
					sessionState.SpaceReservationManager.AgentChanged += SpaceReservationManager_AgentChanged;
				}
				UnregisterPopupIntellisensePresenterEvents(sessionState.PopupIntellisensePresenter);
				sessionState.PopupIntellisensePresenter = popupPresenter;
				RegisterPopupIntellisensePresenterEvents(sessionState.PopupIntellisensePresenter);

				var presentationSpan = popupPresenter.PresentationSpan;
				var surfaceElement = popupPresenter.SurfaceElement;
				if (presentationSpan != null && surfaceElement != null) {
					sessionState.SpaceReservationAgent = sessionState.SpaceReservationManager.CreatePopupAgent(presentationSpan, popupPresenter.PopupStyles, surfaceElement);
					sessionState.SpaceReservationManager.AddAgent(sessionState.SpaceReservationAgent);
				}
			}
			else {
				var customPresenter = presenter as ICustomIntellisensePresenter;
				if (customPresenter != null)
					customPresenter.Render();
				else
					Debug.Assert(presenter == null, $"Unsupported presenter: {presenter?.GetType()}");
			}
		}
Exemplo n.º 25
0
		SessionState GetSessionState(IIntellisenseSession session) {
			int index = GetSessionStateIndex(session);
			if (index >= 0)
				return sessionStates[index];

			var sessionState = new SessionState(session);
			sessionStates.Add(sessionState);
			return sessionState;
		}
Exemplo n.º 26
0
		int GetSessionStateIndex(IIntellisenseSession session) {
			for (int i = 0; i < sessionStates.Count; i++) {
				if (sessionStates[i].Session == session)
					return i;
			}
			return -1;
		}
Exemplo n.º 27
0
 public SimpleCompletionEntry(string text, StandardGlyphGroup glyph, IIntellisenseSession session)
     : this(text, null, glyph, session)
 {
 }
 public SimpleCompletionEntry(string text, IIntellisenseSession session)
     : this(text, null, session)
 { }
Exemplo n.º 29
0
 public SimpleCompletionEntry(string text, string description, StandardGlyphGroup glyph, IIntellisenseSession session)
     : base(text, "\"" + text + "\"", description, GlyphService.GetGlyph(glyph, StandardGlyphItem.GlyphItemPublic), null, false, session as ICompletionSession)
 {
 }
 public SimpleCompletionEntry(string text, string description, IIntellisenseSession session)
     : base(text, "\"" + text + "\"", description, _glyph, null, false, session as ICompletionSession)
 { }
 public SimpleCompletionEntry(string text, string insertionText, ImageSource glyph, IIntellisenseSession session)
     : base(text, "\"" + insertionText + "\"", null, glyph ?? _glyph, null, false, session as ICompletionSession)
 {
 }
Exemplo n.º 32
0
		public void PushSession(IIntellisenseSession session) {
			if (wpfTextView.IsClosed)
				throw new InvalidOperationException();
			if (session == null)
				throw new ArgumentNullException(nameof(session));
			if (sessions.Contains(session))
				throw new InvalidOperationException();
			if (sessions.Count == 0)
				commandTargetFilter.HookKeyboard();
			sessions.Insert(0, session);
			session.Dismissed += Session_Dismissed;
			session.PresenterChanged += Session_PresenterChanged;
			PresenterUpdated(session);
		}
 public SimpleCompletionEntry(string text, StandardGlyphGroup glyph, IIntellisenseSession session)
     : this(text, null, glyph, session)
 { }
Exemplo n.º 34
0
 public static void ClearCompleteWordMode(this IIntellisenseSession session)
 => session.Properties.RemoveProperty(CompleteWord);
 public SimpleCompletionEntry(string text, string description, StandardGlyphGroup glyph, IIntellisenseSession session)
     : base(text, "\"" + text + "\"", description, GlyphService.GetGlyph(glyph, StandardGlyphItem.GlyphItemPublic), null, false, session as ICompletionSession)
 { }
Exemplo n.º 36
0
 public static void SetTriggerCharacter(this IIntellisenseSession session, char triggerChar)
 => session.Properties[TriggerChar] = triggerChar;
Exemplo n.º 37
0
 public SessionState(IIntellisenseSession session) => Session = session;
 TryCreateIntellisensePresenter(IIntellisenseSession session)
 {
     // returning null will
     // trigger the default Intellisense provider
     return(null);
 }
Exemplo n.º 39
0
 public NpmVersionCompletionEntry(string text, string description, IIntellisenseSession session)
     : base(text, "\"" + text + "\"", description, Constants.Icon, null, false, session as ICompletionSession)
 {
 }
Exemplo n.º 40
0
 public SimpleCompletionEntry(string text, ImageSource glyph, IIntellisenseSession session)
     : this(text, null, glyph, session)
 {
 }
 public void HACK_StartCompletionSession(IIntellisenseSession editorSessionOpt)
 {
     HACK_SetShimCompletionSession();
     editorSessionOpt.Dismissed += CompletionOrSignatureHelpSession_Dismissed;
 }
Exemplo n.º 42
0
 internal static Collection <ITextBuffer> GetBuffersForTriggerPoint(IIntellisenseSession session)
 {
     return(session.TextView.BufferGraph.GetTextBuffers(
                buffer => session.GetTriggerPoint(buffer) != null));
 }
Exemplo n.º 43
0
 public static void SetCompleteWordMode(this IIntellisenseSession session)
 => session.Properties[CompleteWord] = true;
 public SimpleCompletionEntry(string text, string insertionText, ImageSource glyph, IIntellisenseSession session)
     : base(text, "\"" + insertionText + "\"", null, glyph ?? _glyph, null, false, session as ICompletionSession)
 {
 }
Exemplo n.º 45
0
 public static bool IsCompleteWordMode(this IIntellisenseSession session)
 => session.Properties.TryGetProperty(CompleteWord, out bool prop) && prop;
 public static bool IsSupportedSession(IIntellisenseSession session) => session is ICompletionSession || session is ISignatureHelpSession;
Exemplo n.º 47
0
 public static char GetTriggerCharacter(this IIntellisenseSession session)
 => session.Properties.TryGetProperty(TriggerChar, out char c) ? c : '\0';
 public BowerNameCompletionEntry(string text, IIntellisenseSession session, DTE2 dte, JSONDocument doc)
     : base(text, "\"" + text + "\"", null, Constants.Icon, null, false, session as ICompletionSession)
 {
     _dte = dte;
     _doc = doc;
 }
 public BowerNameCompletionEntry(string text, IIntellisenseSession session, JSONDocument doc)
     : base(text, "\"" + text + "\"", null, Constants.Icon, null, false, session as ICompletionSession)
 {
     _doc = doc;
 }
 public void MoveSessionToTop(IIntellisenseSession session) {
     if (!_stack.Remove(session)) {
         throw new InvalidOperationException();
     }
     PushSession(session);
 }
Exemplo n.º 51
0
 public SimpleCompletionEntry(string text, ImageMoniker moniker, IIntellisenseSession session, int specificVersion)
     : this(text, null, WpfUtil.GetIconForImageMoniker(moniker, 16, 16), session)
 {
     _specificVersion = specificVersion;
 }
 public void PushSession(IIntellisenseSession session) {
     session.Dismissed += session_Dismissed;
     _stack.Add(session);
 }
Exemplo n.º 53
0
 public SimpleCompletionEntry(string text, string description, ImageMoniker moniker, IIntellisenseSession session)
     : base(text, "\"" + text + "\"", description, WpfUtil.GetIconForImageMoniker(moniker, 16, 16), null, false, session as ICompletionSession)
 {
 }
Exemplo n.º 54
0
 public VersionCompletionEntry(string displayText, string insertionText, string description, ImageMoniker moniker, ITrackingSpan span, IIntellisenseSession session, int specificVersion)
     : base(displayText, insertionText, description, moniker, span, session, specificVersion)
 {
     if (!string.IsNullOrEmpty(displayText))
     {
         SemVersion = SemanticVersion.Parse(displayText);
     }
 }
Exemplo n.º 55
0
 public SimpleCompletionEntry(string text, IIntellisenseSession session)
     : this(text, null, session)
 {
 }
        /// <summary>
        /// Returns the span to use for the provided intellisense session.
        /// </summary>
        /// <returns>A tracking span. The span may be of length zero if there
        /// is no suitable token at the trigger point.</returns>
        internal static ITrackingSpan GetApplicableSpan(IIntellisenseSession session, ITextBuffer buffer) {
            var snapshot = buffer.CurrentSnapshot;
            var triggerPoint = session.GetTriggerPoint(buffer);

            var span = GetApplicableSpan(snapshot, triggerPoint);
            if (span != null) {
                return span;
            }
            return snapshot.CreateTrackingSpan(triggerPoint.GetPosition(snapshot), 0, SpanTrackingMode.EdgeInclusive);
        }
Exemplo n.º 57
0
 public SimpleCompletionEntry(string text, string description, IIntellisenseSession session)
     : base(text, "\"" + text + "\"", description, _glyph, null, false, session as ICompletionSession)
 {
 }
 public NpmVersionCompletionEntry(string text, string description, IIntellisenseSession session, DTE2 dte)
     : base(text, "\"" + text + "\"", description, Constants.Icon, null, false, session as ICompletionSession)
 {
     _dte = dte;
 }
Exemplo n.º 59
0
 public SimpleCompletionEntry(string displayText, string insertionText, string description, IIntellisenseSession session)
     : base(displayText, insertionText, description, _glyph, null, false, session as ICompletionSession)
 {
 }
Exemplo n.º 60
0
 public void HACK_StartCompletionSession(IIntellisenseSession editorSessionOpt)
 {
     HACK_SetShimCompletionSession();
     editorSessionOpt.Dismissed += CompletionOrSignatureHelpSession_Dismissed;
 }