public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            if (!session.TextView.Properties.ContainsProperty(SessionKey))
            {
                return;
            }

            // Map the trigger point down to our buffer.
            var subjectTriggerPoint = session.GetTriggerPoint(subjectBuffer.CurrentSnapshot);
            if (!subjectTriggerPoint.HasValue)
            {
                return;
            }

            var currentSnapshot = subjectTriggerPoint.Value.Snapshot;
            var querySpan = new SnapshotSpan(subjectTriggerPoint.Value, 0);
            var applicableToSpan = currentSnapshot.CreateTrackingSpan(
                querySpan.Start.Position,
                0,
                SpanTrackingMode.EdgeInclusive);

            string encouragement = encouragements.GetRandomEncouragement();
            var signature = new Signature(applicableToSpan, encouragement, "", "");
            signatures.Add(signature);
        }
Ejemplo n.º 2
0
        public async System.Threading.Tasks.Task CollectSignatureLists(ISignatureHelpSession newSession)
        {
            JavaEditor javaEditor = null;
            if (TextBuffer.Properties.TryGetProperty<JavaEditor>(typeof(JavaEditor), out javaEditor) &&
                javaEditor.TypeRootIdentifier != null)
            {
                var textReader = new TextSnapshotToTextReader(TextBuffer.CurrentSnapshot) as TextReader;
                var position = newSession.GetTriggerPoint(TextBuffer).GetPosition(TextBuffer.CurrentSnapshot);
                var paramHelpRequest = ProtocolHandlers.CreateParamHelpRequest(
                    textReader,
                    javaEditor.TypeRootIdentifier,
                    position);
                var paramHelpResponse = await javaEditor.JavaPkgServer.Send(javaEditor, paramHelpRequest);

                if (paramHelpResponse.responseType == Protocol.Response.ResponseType.ParamHelp &&
                    paramHelpResponse.paramHelpResponse != null)
                {
                    if (paramHelpResponse.paramHelpResponse.status && paramHelpResponse.paramHelpResponse.signatures.Count != 0)
                    {
                        var applicableTo = TextBuffer.CurrentSnapshot.CreateTrackingSpan(new Span(paramHelpResponse.paramHelpResponse.scopeStart, paramHelpResponse.paramHelpResponse.scopeLength), SpanTrackingMode.EdgeInclusive, 0);
                        int selectedParameterIndex = paramHelpResponse.paramHelpResponse.paramCount;
                        Signatures = TransformSignatures(TextBuffer, paramHelpResponse.paramHelpResponse.signatures, applicableTo, selectedParameterIndex); 
                    }
                }
            }
        }
        public ValueOrderSignature(
            string syntax,
            string description,
            ITrackingSpan trackingSpan,
            ISignatureHelpSession session)
        {

            _propertyName = "Syntax";
            _syntax = syntax ?? string.Empty;
            _description = description;
            _trackingSpan = trackingSpan;

            _content = string.Format(CultureInfo.InvariantCulture, "{0}: {1}", _propertyName, _syntax);
            _nameParam = new CssPropertyNameParameter(this);
            _currentParam = _nameParam;

            _session = session;

            // In order to dismiss this tip at the appropriate time, I need to listen
            // to changes in the text buffer
            if (_trackingSpan != null && _session != null)
            {
                _session.Dismissed += OnSessionDismissed;
                _trackingSpan.TextBuffer.Changed += OnTextBufferChanged;
            }
        }
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
            if (!point.HasValue)
                return;

            CssEditorDocument document = CssEditorDocument.FromTextBuffer(_buffer);
            ParseItem item = document.StyleSheet.ItemBeforePosition(point.Value.Position);

            if (item == null)
                return;

            Declaration dec = item.FindType<Declaration>();
            if (dec == null || dec.PropertyName == null || dec.Colon == null)
                return;

            foreach (ISignature signature in signatures)
            {
                if (signature is ValueOrderSignature)
                {
                    signatures.RemoveAt(signatures.Count - 1);
                    break;
                }
            }
        }
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            if (!session.TextView.Properties.ContainsProperty(SessionKey))
            {
                return;
            }

            // At the moment there is a bug in the javascript provider which causes it to
            // repeatedly insert the same Signature values into an ISignatureHelpSession
            // instance.  There is no way, other than reflection, for us to prevent this
            // from happening.  Instead we just ensure that our provider runs after
            // Javascript and then remove the values they add here
            signatures.Clear();

            // Map the trigger point down to our buffer.
            var subjectTriggerPoint = session.GetTriggerPoint(subjectBuffer.CurrentSnapshot);
            if (!subjectTriggerPoint.HasValue)
            {
                return;
            }

            var currentSnapshot = subjectTriggerPoint.Value.Snapshot;
            var querySpan = new SnapshotSpan(subjectTriggerPoint.Value, 0);
            var applicableToSpan = currentSnapshot.CreateTrackingSpan(
                querySpan.Start.Position,
                0,
                SpanTrackingMode.EdgeInclusive);

            string encouragement = encouragements.GetRandomEncouragement();
            if (encouragement != null)
            {
                var signature = new Signature(applicableToSpan, encouragement, "", "");
                signatures.Add(signature);
            }
        }
Ejemplo n.º 6
0
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, System.Collections.Generic.IList<ISignature> signatures)
        {
            var textBuffer = session.TextView.TextBuffer;
            var span = session.CreateTrackingSpan(textBuffer);

            var sigs = _provider._Analysis.GetSignatures(textBuffer.CurrentSnapshot, textBuffer, span);

            ISignature curSig = null;

            foreach (var sig in sigs.Signatures) {
                if (sigs.ParameterIndex == 0 || sig.Parameters.Count > sigs.ParameterIndex) {
                    curSig = sig;
                    break;
                }
            }

            foreach (var sig in sigs.Signatures) {
                signatures.Add(sig);
            }

            if (curSig != null) {
                // save the current sig so we don't need to recalculate it (we can't set it until
                // the signatures are added by our caller).
                session.Properties.AddProperty(typeof(PythonSignature), curSig);
            }
        }
            public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
            {
                ITextSnapshot snapshot = _textBuffer.CurrentSnapshot;

                // trigger point
                SnapshotPoint? point = session.GetTriggerPoint(snapshot);
                if (point == null)
                    return;

                // get syntax tree
                SyntaxTree syntaxTree = snapshot.GetSyntaxTree();
                var root = syntaxTree.Root as RobotsTxtDocumentSyntax;

                // find line in syntax tree
                ITextSnapshotLine line = point.Value.GetContainingLine();
                RobotsTxtLineSyntax lineSyntax = root.Records.SelectMany(r => r.Lines)
                    .Where(l => !l.NameToken.IsMissing && !l.DelimiterToken.IsMissing)
                    .FirstOrDefault(l => l.Span.IntersectsWith(line.Extent));

                // found
                if (lineSyntax != null)
                {
                    if (lineSyntax.DelimiterToken.Span.Span.End <= point.Value)
                    {
                        // get semantic model
                        ISemanticModel model = syntaxTree.GetSemanticModel();

                        // add signature
                        signatures.Add(new RobotsTxtSignature(model, lineSyntax));
                    }
                }
            }
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            SnapshotPoint? point = session.GetTriggerPoint(_buffer.CurrentSnapshot);
            if (!point.HasValue)
                return;

            CssEditorDocument document = CssEditorDocument.FromTextBuffer(_buffer);
            ParseItem item = document.StyleSheet.ItemBeforePosition(point.Value.Position);

            if (item == null)
                return;

            Declaration dec = item.FindType<Declaration>();
            if (dec == null || dec.PropertyName == null || dec.Colon == null)
                return;

            var span = _buffer.CurrentSnapshot.CreateTrackingSpan(dec.Colon.Start, dec.Length - dec.PropertyName.Length, SpanTrackingMode.EdgeNegative);

            ValueOrderFactory.AddSignatures method = ValueOrderFactory.GetMethod(dec);

            if (method != null)
            {
                signatures.Clear();
                method(session, signatures, dec, span);

                Dispatcher.CurrentDispatcher.BeginInvoke(
                    new Action(() => {
                        session.Properties.AddProperty("dec", dec);
                        session.Match();
                    }),
                    DispatcherPriority.Normal, null);
            }
        }
Ejemplo n.º 9
0
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, System.Collections.Generic.IList<ISignature> signatures)
        {
            var span = session.GetApplicableSpan(_textBuffer);

            var sigs = _textBuffer.CurrentSnapshot.GetSignatures(span);

            ISignature curSig = null;

            foreach (var sig in sigs.Signatures) {
                if (sigs.ParameterIndex == 0 || sig.Parameters.Count > sigs.ParameterIndex) {
                    curSig = sig;
                    break;
                }
            }

            foreach (var sig in sigs.Signatures) {
                signatures.Add(sig);
            }

            if (curSig != null) {
                // save the current sig so we don't need to recalculate it (we can't set it until
                // the signatures are added by our caller).
                session.Properties.AddProperty(typeof(JSignature), curSig);
            }
        }
Ejemplo n.º 10
0
        public ISignature GetBestMatch(ISignatureHelpSession session)
        {
            if (session.Signatures.Count <= 0) return null;

            //TODO: Rob G - Flesh this out to cover various signatures

            return session.Signatures[0];
        }
Ejemplo n.º 11
0
		/// <summary>
		/// Gets the Roslyn sig help session stored in a <see cref="ISignatureHelpSession"/> or null if none
		/// </summary>
		/// <param name="session">Intellisense sig help session</param>
		/// <returns></returns>
		public static SignatureHelpSession TryGetSession(ISignatureHelpSession session) {
			if (session == null)
				return null;
			SignatureHelpSession ourSession;
			if (session.Properties.TryGetProperty(sigHelpSessionKey, out ourSession))
				return ourSession;
			return null;
		}
 void OnSaved(Document document)
 {
     var point = textView.Caret.Position.BufferPosition;
     var triggerPoint = point.Snapshot.CreateTrackingPoint(point.Position, PointTrackingMode.Positive);
     if (!provider.SignatureHelpBroker.IsSignatureHelpActive(textView))
     {
         session = provider.SignatureHelpBroker.TriggerSignatureHelp(textView, triggerPoint, true);
     }
 }
Ejemplo n.º 13
0
 public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
 {
     JavaSignatureHelpSessionSignatures storedSigs;
     if (session.Properties.TryGetProperty<JavaSignatureHelpSessionSignatures>(typeof(JavaSignatureHelpSessionSignatures), out storedSigs))
     {
         foreach (var sig in storedSigs.Signatures)
             signatures.Add(sig);
     }
 }
            public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
            {
                AssertIsForeground();
                if (!session.Properties.TryGetProperty<SignatureHelpPresenterSession>(s_augmentSessionKey, out var presenterSession))
                {
                    return;
                }

                session.Properties.RemoveProperty(s_augmentSessionKey);
                presenterSession.AugmentSignatureHelpSession(signatures);
            }
Ejemplo n.º 15
0
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            ITextSnapshot currentSnapshot = _textBuffer.CurrentSnapshot;
            int currentPosition = session.GetTriggerPoint(_textBuffer).GetPosition(currentSnapshot);
            ITrackingSpan currentApplicableSpan = currentSnapshot.CreateTrackingSpan(new Span(currentPosition, 0), SpanTrackingMode.EdgeInclusive, TrackingFidelityMode.Forward);

            signatures.Add(CreateSignature(_textBuffer, "<content name=\"namedContentArea\" />", "Spools all output in the content element into a named text writer", currentApplicableSpan));
            signatures.Add(CreateSignature(_textBuffer, "<content var=\"variable\" />", "Spools all output into a temporary text writer", currentApplicableSpan));
            signatures.Add(CreateSignature(_textBuffer, "<content def=\"variable\" />", "Spools all output into a temporary text writer (same as 'var')", currentApplicableSpan));
            signatures.Add(CreateSignature(_textBuffer, "<default x=\"xValue\" y=\"yValue\" />", "Declares local variables if a symbol of a given name is not known to be in scope", currentApplicableSpan));
        }
 void DisplayEncouragement()
 {
     var point = textView.Caret.Position.BufferPosition;
     var triggerPoint = point.Snapshot.CreateTrackingPoint(point.Position, PointTrackingMode.Positive);
     if (!provider.SignatureHelpBroker.IsSignatureHelpActive(textView))
     {
         textView.Properties.AddProperty(EncourageSignatureHelpSource.SessionKey, null);
         session = provider.SignatureHelpBroker.TriggerSignatureHelp(textView, triggerPoint, true);
         textView.Properties.RemoveProperty(EncourageSignatureHelpSource.SessionKey);
     }
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="type">Context type, eg. <see cref="SignatureHelpClassifierContextTypes.ParameterDocumentation"/></param>
 /// <param name="session">Signature help session</param>
 protected internal SignatureHelpClassifierContext(string type, ISignatureHelpSession session)
 {
     if (type == null)
     {
         throw new ArgumentNullException(nameof(type));
     }
     if (session == null)
     {
         throw new ArgumentNullException(nameof(session));
     }
     Type    = type;
     Session = session;
 }
Ejemplo n.º 18
0
            public void Dismiss()
            {
                AssertIsForeground();

                if (_editorSessionOpt == null)
                {
                    // No editor session, nothing to do here.
                    return;
                }

                _editorSessionOpt.Dismiss();
                _editorSessionOpt = null;
            }
Ejemplo n.º 19
0
        public ISignatureHelpSession TriggerSignatureHelp(ITextView textView, ITrackingPoint triggerPoint, bool trackCaret)
        {
            ISignatureHelpSession session = this.CreateSignatureHelpSession(textView, triggerPoint, trackCaret);

            session.Start();

            if (session.IsDismissed)
            {
                return(null);
            }

            return(session);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// I'm about to be destroyed, so stop listening to events
        /// </summary>
        private void OnSessionDismissed(object sender, System.EventArgs eventArgs)
        {
            if (_trackingSpan != null)
            {
                _trackingSpan.TextBuffer.Changed -= OnTextBufferChanged;
            }

            if (_session != null)
            {
                _session.Dismissed -= OnSessionDismissed;
                _session            = null;
            }
        }
Ejemplo n.º 21
0
        public virtual void TriggerSignatureHelp([NotNull] ITrackingPoint triggerPoint)
        {
            Requires.NotNull(triggerPoint, nameof(triggerPoint));

            DismissSignatureHelp();
            ISignatureHelpSession session = Provider.SignatureHelpBroker.TriggerSignatureHelp(TextView, triggerPoint, true);

            if (session != null)
            {
                session.Dismissed   += HandleSignatureHelpDismissed;
                SignatureHelpSession = session;
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Gets the Roslyn sig help session stored in a <see cref="ISignatureHelpSession"/> or null if none
        /// </summary>
        /// <param name="session">Intellisense sig help session</param>
        /// <returns></returns>
        public static SignatureHelpSession TryGetSession(ISignatureHelpSession session)
        {
            if (session == null)
            {
                return(null);
            }
            SignatureHelpSession ourSession;

            if (session.Properties.TryGetProperty(sigHelpSessionKey, out ourSession))
            {
                return(ourSession);
            }
            return(null);
        }
Ejemplo n.º 23
0
    //</Snippet19>

    //<Snippet20>
    public ISignature GetBestMatch(ISignatureHelpSession session)
    {
        if (session.Signatures.Count > 0)
        {
            ITrackingSpan applicableToSpan = session.Signatures[0].ApplicableToSpan;
            string        text             = applicableToSpan.GetText(applicableToSpan.TextBuffer.CurrentSnapshot);

            if (text.Trim().Equals("add"))  //get only "add"
            {
                return(session.Signatures[0]);
            }
        }
        return(null);
    }
Ejemplo n.º 24
0
        internal static Task AugmentSignatureHelpSessionAsync(this SignatureHelpSource signatureHelpSource, ISignatureHelpSession session, IList<ISignature> signatures, AstRoot ast) {
            var tcs = new TaskCompletionSource<object>();

            var ready = signatureHelpSource.AugmentSignatureHelpSession(session, signatures, ast, (o, p) => {
                signatureHelpSource.AugmentSignatureHelpSession(session, signatures, ast, null);
                tcs.TrySetResult(null);
            });

            if (ready) {
                tcs.TrySetResult(null);
            }

            return tcs.Task;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="session">Signature help session</param>
 /// <param name="parameter">Parameter to classify</param>
 /// <param name="nameOffset">Offset of <see cref="IParameter.Name"/> in the text buffer</param>
 public ParameterNameSignatureHelpClassifierContext(ISignatureHelpSession session, IParameter parameter, int nameOffset)
     : base(SignatureHelpClassifierContextTypes.ParameterName, session)
 {
     if (parameter == null)
     {
         throw new ArgumentNullException(nameof(parameter));
     }
     if (nameOffset < 0)
     {
         throw new ArgumentOutOfRangeException(nameof(nameOffset));
     }
     Parameter  = parameter;
     NameOffset = nameOffset;
 }
Ejemplo n.º 26
0
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList <ISignature> signatures)
        {
            if (!REditorSettings.SignatureHelpEnabled || session.IsDismissed)
            {
                return;
            }

            var document = REditorDocument.TryFromTextBuffer(_textBuffer);

            if (document != null)
            {
                document.EditorTree.EnsureTreeReady();
                AugmentSignatureHelpSession(session, signatures, document.EditorTree.AstRoot, TriggerSignatureHelp);
            }
        }
        public ISignature GetBestMatch(ISignatureHelpSession session)
        {
            if (session.Signatures.Count > 0)
            {
                var applicableToSpan = session.Signatures.First().ApplicableToSpan;
                var text             = applicableToSpan.GetText(applicableToSpan.TextBuffer.CurrentSnapshot);

                if (text.Trim().Equals("add"))
                {
                    return(session.Signatures.First());
                }
            }

            return(null);
        }
Ejemplo n.º 28
0
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList <ISignature> signatures)
        {
            SnapshotPoint?point = session.GetTriggerPoint(_buffer.CurrentSnapshot);

            if (!point.HasValue)
            {
                return;
            }

            CssEditorDocument document = CssEditorDocument.FromTextBuffer(_buffer);
            ParseItem         item     = document.StyleSheet.ItemBeforePosition(point.Value.Position);

            if (item == null)
            {
                return;
            }

            Declaration dec = item.FindType <Declaration>();

            if (dec == null || dec.PropertyName == null || dec.Colon == null)
            {
                return;
            }

            int length = dec.Length - (dec.Colon.Start - dec.Start);
            var span   = _buffer.CurrentSnapshot.CreateTrackingSpan(dec.Colon.Start, length, SpanTrackingMode.EdgeNegative);

            ValueOrderFactory.AddSignatures method = ValueOrderFactory.GetMethod(dec);

            if (method != null)
            {
                signatures.Clear();
                method(session, signatures, dec, span);

                Dispatcher.CurrentDispatcher.BeginInvoke(
                    new Action(() =>
                {
                    if (session == null || session.Properties == null)
                    {
                        return;
                    }

                    session.Properties.AddProperty("dec", dec);
                    session.Match();
                }),
                    DispatcherPriority.Normal, null);
            }
        }
Ejemplo n.º 29
0
        public List <ClassificationSpan> GetReplacementSpans(ISignatureHelpSession session)
        {
            ITextSnapshot snapshot       = this.textBuffer.CurrentSnapshot;
            int           currentVersion = snapshot.Version.VersionNumber;
            SnapshotPoint currentPoint   = session.GetTriggerPoint(snapshot).Value;

            if (replacementSpansVersion != currentVersion || replacementSpansPoint != currentPoint)
            {
                // TODO: detect when the current point is within the spans and re-use?
                this.replacementSpans        = this.GetReplacementSpans(currentPoint);
                this.replacementSpansVersion = currentVersion;
                this.replacementSpansPoint   = currentPoint;
            }

            return(this.replacementSpans);
        }
Ejemplo n.º 30
0
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures) {
            if (!REditorSettings.SignatureHelpEnabled || session.IsDismissed) {
                return;
            }

            var document = REditorDocument.TryFromTextBuffer(_textBuffer);
            if (document != null) {
                if (!document.EditorTree.IsReady) {
                    document.EditorTree.InvokeWhenReady((p) => {
                        var broker = _shell.ExportProvider.GetExportedValue<ISignatureHelpBroker>();
                        broker.DismissAllSessions((ITextView)p);
                        broker.TriggerSignatureHelp((ITextView)p);
                    }, session.TextView, this.GetType(), processNow: true);
                }
                AugmentSignatureHelpSession(session, signatures, document.EditorTree.AstRoot, TriggerSignatureHelp);
            }
        }
Ejemplo n.º 31
0
        public SignatureHelp(ISignatureHelpSession session, ITextBuffer subjectBuffer, string functionName,
                             string documentation, ISignatureInfo signatureInfo) {
            FunctionName = functionName;
            _signatureInfo = signatureInfo;

            Documentation = documentation;
            Parameters = null;

            Session = session;
            Session.Dismissed += OnSessionDismissed;

            TextView = session.TextView;
            TextView.Caret.PositionChanged += OnCaretPositionChanged;

            SubjectBuffer = subjectBuffer;
            SubjectBuffer.Changed += OnSubjectBufferChanged;
        }
Ejemplo n.º 32
0
        public ISignature GetBestMatch(ISignatureHelpSession session)
        {
            if (session.Signatures.Count > 0)
            {
                ITrackingSpan applicableToSpan = session.Signatures[0].ApplicableToSpan;
                string        text             = applicableToSpan.GetText(applicableToSpan.TextBuffer.CurrentSnapshot).Trim();

                foreach (var sig in session.Signatures)
                {
                    if (text.Equals(sig.Content))
                    {
                        return(sig);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 33
0
 public void Dispose()
 {
     if (isDisposed)
     {
         return;
     }
     isDisposed = true;
     CancelFetchItems();
     if (session != null)
     {
         session.Dismissed -= Session_Dismissed;
         session.Dismiss();
     }
     session = null;
     signatures.Clear();
     Disposed?.Invoke(this, EventArgs.Empty);
 }
        private void HandleTypeChar(char typedChar)
        {
            switch (typedChar)
            {
            case '(':
                StartSignatureSession();
                break;

            case ')':
                if (_signatureSession != null)
                {
                    _signatureSession.Dismiss();
                    _signatureSession = null;
                }
                break;
            }
        }
Ejemplo n.º 35
0
 public ISignature GetBestMatch(ISignatureHelpSession session)
 {
     if (session.Signatures.Count > 0)
     {
         var applicableToSpan = session.Signatures[0].ApplicableToSpan;
         var text             = applicableToSpan.GetText(applicableToSpan.TextBuffer.CurrentSnapshot);
         foreach (var sig in session.Signatures)
         {
             var sh = sig as RSignatureHelp;
             if (sh != null && sh.FunctionName.StartsWithOrdinal(text))
             {
                 return(sig);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 36
0
        public ISignature GetBestMatch(ISignatureHelpSession session)
        {
            int number = 0;

            if (session.Properties.ContainsProperty("dec"))
            {
                Declaration dec        = session.Properties["dec"] as Declaration;
                string      methodName = ValueOrderFactory.GetMethod(dec).Method.Name;
                if (dec.Values.Count > 0 && (methodName == "Margins" || methodName == "Corners"))
                {
                    number = 4 - dec.Values.Count;
                }
            }

            return((session.Signatures != null && session.Signatures.Count > number && number > -1)
                ? session.Signatures[number]
                : null);
        }
Ejemplo n.º 37
0
        public SignatureHelp(ISignatureHelpSession session, ITextBuffer subjectBuffer, string functionName,
                             string documentation, ISignatureInfo signatureInfo)
        {
            FunctionName   = functionName;
            _signatureInfo = signatureInfo;

            Documentation = documentation;
            Parameters    = null;

            Session            = session;
            Session.Dismissed += OnSessionDismissed;

            TextView = session.TextView;
            TextView.Caret.PositionChanged += OnCaretPositionChanged;

            SubjectBuffer          = subjectBuffer;
            SubjectBuffer.Changed += OnSubjectBufferChanged;
        }
Ejemplo n.º 38
0
 public SignatureHelpTagger(ISignatureHelpSession session, ITextBuffer buffer, IThemeClassificationTypeService themeClassificationTypeService)
 {
     if (session == null)
     {
         throw new ArgumentNullException(nameof(session));
     }
     if (buffer == null)
     {
         throw new ArgumentNullException(nameof(buffer));
     }
     if (themeClassificationTypeService == null)
     {
         throw new ArgumentNullException(nameof(themeClassificationTypeService));
     }
     this.session = session;
     this.buffer  = buffer;
     this.themeClassificationTypeService = themeClassificationTypeService;
 }
Ejemplo n.º 39
0
        public ISignatureHelpSession GetSignatureSession()
        {
            ISignatureHelpBroker broker = EditorShell.Current.ExportProvider.GetExportedValue <ISignatureHelpBroker>();
            var sessions = broker.GetSessions(EditorWindow.CoreEditor.View);
            ISignatureHelpSession session = sessions.FirstOrDefault();

            int retries = 0;

            while (session == null && retries < 10)
            {
                this.DoIdle(1000);
                sessions = broker.GetSessions(EditorWindow.CoreEditor.View);
                session  = sessions.FirstOrDefault();
                retries++;
            }

            return(session);
        }
Ejemplo n.º 40
0
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList <ISignature> signatures)
        {
            if (!REditorSettings.SignatureHelpEnabled || session.IsDismissed)
            {
                return;
            }

            var document = REditorDocument.TryFromTextBuffer(_textBuffer);

            if (document != null && !document.EditorTree.IsReady)
            {
                document.EditorTree.InvokeWhenReady((p) => {
                    var broker = EditorShell.Current.ExportProvider.GetExportedValue <ISignatureHelpBroker>();
                    broker.TriggerSignatureHelp((ITextView)p);
                }, session.TextView, this.GetType(), processNow: true);
            }
            AugmentSignatureHelpSession(session, signatures, document.EditorTree.AstRoot, TriggerSignatureHelp);
        }
 public SignatureHelpCurrentParameterTagger(ISignatureHelpSession session, ITextBuffer buffer, ClassificationTag signatureHelpCurrentParameterClassificationTag)
 {
     if (session == null)
     {
         throw new ArgumentNullException(nameof(session));
     }
     if (buffer == null)
     {
         throw new ArgumentNullException(nameof(buffer));
     }
     if (signatureHelpCurrentParameterClassificationTag == null)
     {
         throw new ArgumentNullException(nameof(signatureHelpCurrentParameterClassificationTag));
     }
     this.session = session;
     this.buffer  = buffer;
     this.signatureHelpCurrentParameterClassificationTag = signatureHelpCurrentParameterClassificationTag;
 }
Ejemplo n.º 42
0
        public GLSLSignature(Definition definition, TrackingSpan trackingSpan, Snapshot snapshot, ITextView textView, ISignatureHelpSession session)
        {
            GLSL.Text.Span span = trackingSpan.GetSpan(snapshot);

            this.ApplicableToSpan = snapshot.CreateTrackingSpan(GLSL.Text.Span.Create(span.Start, span.End - 1)).ToITrackingSpan();
            this.Content          = definition.ToString();
            this.Documentation    = definition.Documentation;
            this.Parameters       = new ReadOnlyCollection <IParameter>(definition.GetParameters(this));
            this.textView         = textView;
            this.session          = session;

            this.textView.TextBuffer.Changed    += this.TextBufferChanged;
            this.textView.Caret.PositionChanged += this.CaretPositionChanged;

            this.session.Dismissed += this.OnDismissed;

            this.ComputeCurrentParamter(this.textView.TextBuffer.CurrentSnapshot);
        }
        public ISignature GetBestMatch(ISignatureHelpSession session)
        {
            int number = 0;

            if (session.Properties.ContainsProperty("dec"))
            {
                Declaration dec = session.Properties["dec"] as Declaration;
                string methodName = ValueOrderFactory.GetMethod(dec).Method.Name;
                if (dec.Values.Count > 0 && (methodName == "Margins" || methodName == "Corners"))
                {
                    number = 4 - dec.Values.Count;
                }
            }

            return (session.Signatures != null && session.Signatures.Count > number && number > -1)
                ? session.Signatures[number]
                : null;
        }
Ejemplo n.º 44
0
#pragma warning restore 0169

        public SignatureHelpPresenter(ISignatureHelpSession session, ITextBufferFactoryService textBufferFactoryService, IContentTypeRegistryService contentTypeRegistryService, IClassifierAggregatorService classifierAggregatorService, IClassificationFormatMap classificationFormatMap)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }
            if (textBufferFactoryService == null)
            {
                throw new ArgumentNullException(nameof(textBufferFactoryService));
            }
            if (contentTypeRegistryService == null)
            {
                throw new ArgumentNullException(nameof(contentTypeRegistryService));
            }
            if (classifierAggregatorService == null)
            {
                throw new ArgumentNullException(nameof(classifierAggregatorService));
            }
            if (classificationFormatMap == null)
            {
                throw new ArgumentNullException(nameof(classificationFormatMap));
            }
            this.session = session;
            this.control = new SignatureHelpPresenterControl {
                DataContext = this
            };
            this.signatureTextBuffer = textBufferFactoryService.CreateTextBuffer();
            this.otherTextBuffer     = textBufferFactoryService.CreateTextBuffer();
            signatureTextBuffer.Properties[SignatureHelpConstants.SessionBufferKey] = session;
            otherTextBuffer.Properties[SignatureHelpConstants.SessionBufferKey]     = session;
            this.contentTypeRegistryService  = contentTypeRegistryService;
            this.classifierAggregatorService = classifierAggregatorService;
            this.classificationFormatMap     = classificationFormatMap;
            this.defaultExtendedContentType  = contentTypeRegistryService.GetContentType(DefaultExtendedContentTypeName);
            Debug.Assert(defaultExtendedContentType != null);
            classificationFormatMap.ClassificationFormatMappingChanged += ClassificationFormatMap_ClassificationFormatMappingChanged;
            session.Dismissed += Session_Dismissed;
            session.SelectedSignatureChanged += Session_SelectedSignatureChanged;
            control.MouseDown += Control_MouseDown;
            // This isn't exposed but ReadOnlyObservableCollection<ISignature> does implement the interface
            ((INotifyCollectionChanged)session.Signatures).CollectionChanged += Signatures_CollectionChanged;
            UpdateSelectedSignature();
            UpdatePresentationSpan();
        }
        /// <summary>
        /// Triggers Statement completion when appropriate keys are pressed
        /// The key combination is CTRL-J or "."
        /// The intellisense window is dismissed when one presses ESC key
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnPreprocessKeyDown(object sender, TextCompositionEventArgs e)
        {
            // We should only receive pre-process events from our text view
            Debug.Assert(sender == _textView);

            // TODO: We should handle = for signature completion of keyword arguments

            // We trigger completions when the user types . or space.  Our EditFilter will
            // also trigger completions when we receive the VSConstants.VSStd2KCmdID.SHOWMEMBERLIST
            // command or the VSConstants.VSStd2KCmdID.COMPLETEWORD command.
            //
            // We trigger signature help when we receive a "(".  We update our current sig when
            // we receive a "," and we close sig help when we receive a ")".

            switch (e.Text)
            {
            case ".":
            case " ":
                //DeleteSelectedSpans();
                TriggerCompletionSession(false);
                break;

            case "(": OpenParenStartSignatureSession(); break;

            case ")":
                if (_sigHelpSession != null)
                {
                    _sigHelpSession.Dismiss();
                    _sigHelpSession = null;
                }
                break;

            case ",":
                if (_sigHelpSession == null)
                {
                    CommaStartSignatureSession();
                }
                else
                {
                    CommaAdvanceParameter();
                }
                break;
            }
        }
Ejemplo n.º 46
0
        private ISignature CreateSignature(ISignatureHelpSession session,
                                           IFunctionInfo functionInfo, ISignatureInfo signatureInfo,
                                           ITrackingSpan span, AstRoot ast, int position)
        {
            SignatureHelp     sig       = new SignatureHelp(session, _textBuffer, functionInfo.Name, string.Empty, signatureInfo);
            List <IParameter> paramList = new List <IParameter>();

            // Locus points in the pretty printed signature (the one displayed in the tooltip)
            var    locusPoints     = new List <int>();
            string signatureString = signatureInfo.GetSignatureString(locusPoints);

            sig.Content          = signatureString;
            sig.ApplicableToSpan = span;

            sig.Documentation = functionInfo.Description?.Wrap(Math.Min(SignatureInfo.MaxSignatureLength, sig.Content.Length));

            Debug.Assert(locusPoints.Count == signatureInfo.Arguments.Count + 1);
            for (int i = 0; i < signatureInfo.Arguments.Count; i++)
            {
                IArgumentInfo p = signatureInfo.Arguments[i];
                if (p != null)
                {
                    int locusStart  = locusPoints[i];
                    int locusLength = locusPoints[i + 1] - locusStart;

                    Debug.Assert(locusLength >= 0);
                    Span locus = new Span(locusStart, locusLength);

                    /// VS may end showing very long tooltip so we need to keep
                    /// description reasonably short: typically about
                    /// same length as the function signature.
                    paramList.Add(
                        new SignatureParameter(
                            p.Description.Wrap(
                                Math.Min(SignatureInfo.MaxSignatureLength, sig.Content.Length)),
                            locus, locus, p.Name, sig));
                }
            }

            sig.Parameters = new ReadOnlyCollection <IParameter>(paramList);
            sig.ComputeCurrentParameter(ast, position);

            return(sig);
        }
Ejemplo n.º 47
0
        public bool AugmentSignatureHelpSession(ISignatureHelpSession session, IList <ISignature> signatures, AstRoot ast, Action <object, string> triggerSession, string packageName)
        {
            ITextSnapshot snapshot = _textBuffer.CurrentSnapshot;
            int           position = session.GetTriggerPoint(_textBuffer).GetPosition(snapshot);

            // Retrieve parameter positions from the current text buffer snapshot
            ParameterInfo parametersInfo = SignatureHelp.GetParametersInfoFromBuffer(ast, snapshot, position);

            if (parametersInfo != null)
            {
                position = Math.Min(parametersInfo.SignatureEnd, position);
                int start = Math.Min(position, snapshot.Length);
                int end   = Math.Min(parametersInfo.SignatureEnd, snapshot.Length);

                ITrackingSpan applicableToSpan = snapshot.CreateTrackingSpan(Span.FromBounds(start, end), SpanTrackingMode.EdgeInclusive);
                IFunctionInfo functionInfo     = null;

                // First try user-defined function
                functionInfo = ast.GetUserFunctionInfo(parametersInfo.FunctionName, position);
                if (functionInfo == null)
                {
                    var functionIndex = _shell.ExportProvider.GetExportedValue <IFunctionIndex>();
                    // Then try package functions
                    packageName  = packageName ?? _packageName;
                    _packageName = null;
                    // Get collection of function signatures from documentation (parsed RD file)
                    functionInfo = functionIndex.GetFunctionInfo(parametersInfo.FunctionName, packageName, triggerSession, session);
                }

                if (functionInfo != null && functionInfo.Signatures != null)
                {
                    foreach (ISignatureInfo signatureInfo in functionInfo.Signatures)
                    {
                        ISignature signature = CreateSignature(session, parametersInfo.FunctionName, functionInfo, signatureInfo, applicableToSpan, ast, position);
                        signatures.Add(signature);
                    }

                    session.Properties["functionInfo"] = functionInfo;
                    return(true);
                }
            }

            return(false);
        }
            public void AugmentSignatureHelpSession(
                ISignatureHelpSession session,
                IList<ISignature> signatures
            )
            {
                AssertIsForeground();
                if (
                    !session.Properties.TryGetProperty<SignatureHelpPresenterSession>(
                        s_augmentSessionKey,
                        out var presenterSession
                    )
                )
                {
                    return;
                }

                session.Properties.RemoveProperty(s_augmentSessionKey);
                presenterSession.AugmentSignatureHelpSession(signatures);
            }
Ejemplo n.º 49
0
        public ISignature GetBestMatch(ISignatureHelpSession session)
        {
            SignatureHelpManager signatureHelpManager;
            if (!session.Properties.TryGetProperty(typeof(SignatureHelpManager), out signatureHelpManager))
                return null;

            Dictionary<SignatureItem, ISignature> signaturesMap;
            if (!session.Properties.TryGetProperty(typeof(Dictionary<SignatureItem, ISignature>), out signaturesMap))
                return null;

            var model = signatureHelpManager.Model;
            if (model == null)
                return null;

            if (model.Signature == null)
                return null;

            return signaturesMap[model.Signature];
        }
Ejemplo n.º 50
0
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, System.Collections.Generic.IList<ISignature> signatures) {
            var span = session.GetApplicableSpan(_textBuffer);

            var sigs = _textBuffer.CurrentSnapshot.GetSignatures(_provider._serviceProvider, span);

            ISignature curSig = sigs.Signatures
                .OrderBy(s => s.Parameters.Count)
                .FirstOrDefault(s => sigs.ParameterIndex < s.Parameters.Count);
            
            foreach (var sig in sigs.Signatures) {
                signatures.Add(sig);
            }

            if (curSig != null) {
                // save the current sig so we don't need to recalculate it (we can't set it until
                // the signatures are added by our caller).
                session.Properties.AddProperty(typeof(PythonSignature), curSig);
            }
        }
        private bool StartSignatureSession()
        {
            if (_signatureSession == null)
            {
                // Move the caret back to the preceding word
                SnapshotPoint caret  = _textView.Caret.Position.BufferPosition - 1;
                TextExtent    extent = _textNavigator.GetExtentOfWord(caret);
                string        word   = extent.Span.GetText();

                _signatureSession = _signatureBroker.TriggerSignatureHelp(_textView);

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

                return(true);
            }

            return(false);
        }
Ejemplo n.º 52
0
        private void TriggerSession()
        {
            if (_session == null || _session.IsDismissed)
            {
                if (_quickInfoBroker.IsQuickInfoActive(_view))
                {
                    _quickInfoBroker.GetSessions(_view)[0].Dismiss();
                }

                Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
                {
                    _session = _signaturehelpBroker.TriggerSignatureHelp(_view);
                    if (_session != null)
                    {
                        _session.Match();
                    }
                }), DispatcherPriority.Normal, null);
            }
        }
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            if (signatures.Count == 0)
                return;

            // Update signature doco
            var sig = signatures.First();
            if (_sigDocoProp == null) _sigDocoProp = sig.GetType().GetProperty("Documentation");
            var newDoco = DocCommentHelper.ProcessParaTags(sig.Documentation);
            _sigDocoProp.SetValue(sig, newDoco, null);

            // Update parameter doco
            if (_paramDocoProp == null && sig.Parameters.Count > 0)
                _paramDocoProp = sig.Parameters.First().GetType().GetProperty("Documentation");
            foreach (var parameter in sig.Parameters)
            {
                newDoco = DocCommentHelper.ProcessParaTags(parameter.Documentation);
                _paramDocoProp.SetValue(parameter, newDoco, null);
            }
        }
Ejemplo n.º 54
0
        private static void Corners(ISignatureHelpSession session, IList<ISignature> signatures, Declaration dec, ITrackingSpan span)
        {
            string value1 = "3px";
            string value2 = "4px";
            string value3 = "5px";
            string value4 = "6px";

            if (dec.Values.Count > 0)
            {
                value1 = dec.Values[0].Text;
                value2 = dec.Values.Count > 1 ? dec.Values[1].Text : value2;
                value3 = dec.Values.Count > 2 ? dec.Values[2].Text : value3;
                value4 = dec.Values.Count > 3 ? dec.Values[3].Text : value4;

            }
            ValueOrderSignature signature1 = new ValueOrderSignature(
                string.Format(CultureInfo.CurrentCulture, "div {{ {0}: {1} {2} {3} {4}; }} ", dec.PropertyName.Text, value1, value2, value3, value4),
                string.Format(CultureInfo.CurrentCulture, "[top-left={0}] [top-right={1}] [bottom-right={2}] [bottom-left={3}]", value1, value2, value3, value4),
                span, session);

            ValueOrderSignature signature2 = new ValueOrderSignature(
                string.Format(CultureInfo.CurrentCulture, "div {{ {0}: {1} {2} {3}; }} ", dec.PropertyName.Text, value1, value2, value3),
                string.Format(CultureInfo.CurrentCulture, "[top-left={0}] [top-right and bottom-left={1}] [bottom-right={2}]", value1, value2, value3),
                span, session);

            ValueOrderSignature signature3 = new ValueOrderSignature(
                string.Format(CultureInfo.CurrentCulture, "div {{ {0}: {1} {2}; }} ", dec.PropertyName.Text, value1, value2),
                string.Format(CultureInfo.CurrentCulture, "[top-left and bottom-right={0}] [top-right and bottom-left={1}]", value1, value2),
                span, session);

            ValueOrderSignature signature4 = new ValueOrderSignature(
                string.Format(CultureInfo.CurrentCulture, "div {{ {0}: {1}; }} ", dec.PropertyName.Text, value1),
                string.Format(CultureInfo.CurrentCulture, "[top-left and top-right and bottom-right and bottom-left={0}]", value1),
                span, session);

            signatures.Add(signature1);
            signatures.Add(signature2);
            signatures.Add(signature3);
            signatures.Add(signature4);
        }
Ejemplo n.º 55
0
        public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures)
        {
            SignatureHelpManager signatureHelpManager;
            if (!session.Properties.TryGetProperty(typeof(SignatureHelpManager), out signatureHelpManager))
                return;

            var model = signatureHelpManager.Model;
            if (model == null)
                return;

            var snapshot = _textBuffer.CurrentSnapshot;
            var span = model.ApplicableSpan;
            var trackingSpan = snapshot.CreateTrackingSpan(span.Start, span.Length, SpanTrackingMode.EdgeExclusive);

            var signaturesMap = ToSignatures(trackingSpan, model.Signatures, model.SelectedParameter);
            var signatureMapKey = typeof(Dictionary<SignatureItem, ISignature>);
            session.Properties.RemoveProperty(signatureMapKey);
            session.Properties.AddProperty(signatureMapKey, signaturesMap);

            foreach (var signature in model.Signatures)
                signatures.Add(signaturesMap[signature]);
        }
Ejemplo n.º 56
0
        public int Exec(ref Guid cmdGroup, uint cmdId, uint cmdExecOpt, IntPtr pvaIn, IntPtr pvaOut)
        {
            char inputCharacter = char.MinValue;

            if (cmdGroup == VSConstants.VSStd2K && cmdId == (uint) VSConstants.VSStd2KCmdID.TYPECHAR)
            {
                inputCharacter = (char) (ushort) Marshal.GetObjectForNativeVariant(pvaIn);
                if (inputCharacter.Equals(' '))
                {
                    SnapshotPoint currentPosition = _textView.Caret.Position.BufferPosition - 1;
                    TextExtent extentOfWord = _navigator.GetExtentOfWord(currentPosition);
                    string tagName = extentOfWord.Span.GetText();
                    _session = _broker.TriggerSignatureHelp(_textView);
                }
                else if (inputCharacter.Equals('>') && _session != null)
                {
                    _session.Dismiss();
                    _session = null;
                }
            }
            return _nextCommand.Exec(cmdGroup, cmdId, cmdExecOpt, pvaIn, pvaOut);
        }
Ejemplo n.º 57
0
        public bool AugmentSignatureHelpSession(ISignatureHelpSession session, IList<ISignature> signatures, AstRoot ast, Action<object, string> triggerSession) {
            ITextSnapshot snapshot = _textBuffer.CurrentSnapshot;
            int position = session.GetTriggerPoint(_textBuffer).GetPosition(snapshot);

            // Retrieve parameter positions from the current text buffer snapshot
            ParameterInfo parametersInfo = SignatureHelp.GetParametersInfoFromBuffer(ast, snapshot, position);
            if (parametersInfo != null) {
                position = Math.Min(parametersInfo.SignatureEnd, position);
                int start = Math.Min(position, snapshot.Length);
                int end = Math.Min(parametersInfo.SignatureEnd, snapshot.Length);

                ITrackingSpan applicableToSpan = snapshot.CreateTrackingSpan(Span.FromBounds(start, end), SpanTrackingMode.EdgeInclusive);
                IFunctionInfo functionInfo = null;

                // First try user-defined function
                functionInfo = ast.GetUserFunctionInfo(parametersInfo.FunctionName, position);
                if (functionInfo == null) {
                    var functionIndex = _shell.ExportProvider.GetExportedValue<IFunctionIndex>();
                    // Then try package functions
                    var packageName = _packageName;
                    _packageName = null;
                    // Get collection of function signatures from documentation (parsed RD file)
                    functionInfo = functionIndex.GetFunctionInfo(parametersInfo.FunctionName, packageName, triggerSession, session);
                }

                if (functionInfo != null && functionInfo.Signatures != null) {
                    foreach (ISignatureInfo signatureInfo in functionInfo.Signatures) {
                        ISignature signature = CreateSignature(session, parametersInfo.FunctionName, functionInfo, signatureInfo, applicableToSpan, ast, position);
                        signatures.Add(signature);
                    }

                    session.Properties["functionInfo"] = functionInfo;
                    return true;
                }
            }

            return false;
        }
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) {
            if (pguidCmdGroup == VSConstants.VSStd2K && nCmdID == (int)VSConstants.VSStd2KCmdID.TYPECHAR) {
                var ch = (char)(ushort)System.Runtime.InteropServices.Marshal.GetObjectForNativeVariant(pvaIn);

                if (_activeSession != null && !_activeSession.IsDismissed) {
                    if (_activeSession.SelectedCompletionSet.SelectionStatus.IsSelected) {
                        var completion = _activeSession.SelectedCompletionSet.SelectionStatus.Completion;

                        string committedBy = String.Empty;
                        if (_activeSession.SelectedCompletionSet.Moniker == CompletionSource.NodejsRequireCompletionSetMoniker) {
                            if (completion.InsertionText.StartsWith("'")) { // require(
                                committedBy = ")";
                            } else if (completion.InsertionText.EndsWith("'")) { // require('
                                committedBy = "'";
                            } else if (completion.InsertionText.EndsWith("\"")) { // require("
                                committedBy = "\"";
                            }
                        } else {
                            committedBy = NodejsPackage.Instance != null ?
                                NodejsPackage.Instance.IntellisenseOptionsPage.CompletionCommittedBy :
                                NodejsConstants.DefaultIntellisenseCompletionCommittedBy;
                        }

                        if (committedBy.IndexOf(ch) != -1) {
                            _activeSession.Commit();
                            if ((completion.InsertionText.EndsWith("'") && ch == '\'') ||
                                (completion.InsertionText.EndsWith("\"") && ch == '"')) {
                                // https://nodejstools.codeplex.com/workitem/960
                                // ' triggers the completion, but we don't want to insert the quote.
                                return VSConstants.S_OK;
                            }
                        }
                    } else if (_activeSession.SelectedCompletionSet.Moniker.Equals(CompletionSource.NodejsRequireCompletionSetMoniker) && !IsRequireIdentifierChar(ch)) {
                        _activeSession.Dismiss();
                    } else if (!_activeSession.SelectedCompletionSet.Moniker.Equals(CompletionSource.NodejsRequireCompletionSetMoniker) && !IsIdentifierChar(ch)) {
                        _activeSession.Dismiss();
                    }
                }

                int res = _oldTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);

                if (_activeSession == null || !_activeSession.SelectedCompletionSet.Moniker.Equals(CompletionSource.NodejsRequireCompletionSetMoniker)) {
                    //Only process the char if we are not in a require completion
                    HandleChar((char)(ushort)System.Runtime.InteropServices.Marshal.GetObjectForNativeVariant(pvaIn));
                }

                if (_activeSession != null && !_activeSession.IsDismissed) {
                    _activeSession.Filter();
                }

                return res;
            }

            if (_activeSession != null) {
                if (pguidCmdGroup == VSConstants.VSStd2K) {
                    switch ((VSConstants.VSStd2KCmdID)nCmdID) {
                        case VSConstants.VSStd2KCmdID.RETURN:
                            if (/*NodejsPackage.Instance.AdvancedEditorOptionsPage.EnterCommitsIntellisense*/ true &&
                                !_activeSession.IsDismissed &&
                                _activeSession.SelectedCompletionSet.SelectionStatus.IsSelected) {

                                // If the user has typed all of the characters as the completion and presses
                                // enter we should dismiss & let the text editor receive the enter.  For example 
                                // when typing "import sys[ENTER]" completion starts after the space.  After typing
                                // sys the user wants a new line and doesn't want to type enter twice.

                                bool enterOnComplete = /*NodejsPackage.Instance.AdvancedEditorOptionsPage.AddNewLineAtEndOfFullyTypedWord*/true &&
                                         EnterOnCompleteText();

                                _activeSession.Commit();

                                if (!enterOnComplete) {
                                    return VSConstants.S_OK;
                                }
                            } else {
                                _activeSession.Dismiss();
                            }
                            break;
                        case VSConstants.VSStd2KCmdID.TAB:
                            if (!_activeSession.IsDismissed) {
                                _activeSession.Commit();
                                return VSConstants.S_OK;
                            }
                            break;
                        case VSConstants.VSStd2KCmdID.BACKSPACE:
                        case VSConstants.VSStd2KCmdID.DELETE:
                        case VSConstants.VSStd2KCmdID.DELETEWORDLEFT:
                        case VSConstants.VSStd2KCmdID.DELETEWORDRIGHT:
                            int res = _oldTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
                            if (_activeSession != null && !_activeSession.IsDismissed) {
                                _activeSession.Filter();
                            }
                            return res;
                    }
                }
            } else if (_sigHelpSession != null) {
                if (pguidCmdGroup == VSConstants.VSStd2K) {
                    switch ((VSConstants.VSStd2KCmdID)nCmdID) {
                        case VSConstants.VSStd2KCmdID.BACKSPACE:
                            bool fDeleted = Backspace();
                            if (fDeleted) {
                                return VSConstants.S_OK;
                            }
                            break;
                        case VSConstants.VSStd2KCmdID.LEFT:
                            _editOps.MoveToPreviousCharacter(false);
                            UpdateCurrentParameter();
                            return VSConstants.S_OK;
                        case VSConstants.VSStd2KCmdID.RIGHT:
                            _editOps.MoveToNextCharacter(false);
                            UpdateCurrentParameter();
                            return VSConstants.S_OK;
                        case VSConstants.VSStd2KCmdID.HOME:
                        case VSConstants.VSStd2KCmdID.BOL:
                        case VSConstants.VSStd2KCmdID.BOL_EXT:
                        case VSConstants.VSStd2KCmdID.EOL:
                        case VSConstants.VSStd2KCmdID.EOL_EXT:
                        case VSConstants.VSStd2KCmdID.END:
                        case VSConstants.VSStd2KCmdID.WORDPREV:
                        case VSConstants.VSStd2KCmdID.WORDPREV_EXT:
                        case VSConstants.VSStd2KCmdID.DELETEWORDLEFT:
                            _sigHelpSession.Dismiss();
                            _sigHelpSession = null;
                            break;
                    }
                }
            }

            if (pguidCmdGroup == VSConstants.VSStd2K) {
                switch ((VSConstants.VSStd2KCmdID)nCmdID) {
                    case VSConstants.VSStd2KCmdID.SHOWMEMBERLIST:
                    case VSConstants.VSStd2KCmdID.COMPLETEWORD:
                        ForceCompletions = true;
                        try {
                            TriggerCompletionSession((VSConstants.VSStd2KCmdID)nCmdID == VSConstants.VSStd2KCmdID.COMPLETEWORD);
                        } finally {
                            ForceCompletions = false;
                        }
                        return VSConstants.S_OK;
                    case VSConstants.VSStd2KCmdID.QUICKINFO:
                        TriggerQuickInfo();
                        return VSConstants.S_OK;
                    case VSConstants.VSStd2KCmdID.PARAMINFO:
                        TriggerSignatureHelp();
                        return VSConstants.S_OK;
                }
            }

            return _oldTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
        }
 private void OnSignatureSessionDismissed(object sender, System.EventArgs e) {
     // We've just been told that our active session was dismissed.  We should remove all references to it.
     _sigHelpSession.Dismissed -= OnSignatureSessionDismissed;
     _sigHelpSession = null;
 }
        internal void TriggerSignatureHelp() {
            if (_sigHelpSession != null) {
                _sigHelpSession.Dismiss();
            }

            _sigHelpSession = SignatureBroker.TriggerSignatureHelp(_textView);

            if (_sigHelpSession != null) {
                _sigHelpSession.Dismissed += OnSignatureSessionDismissed;
                ISignature sig;
                if (_sigHelpSession.Properties.TryGetProperty(typeof(NodejsSignature), out sig)) {
                    _sigHelpSession.SelectedSignature = sig;

                    IParameter param;
                    if (_sigHelpSession.Properties.TryGetProperty(typeof(NodejsParameter), out param)) {
                        ((NodejsSignature)sig).SetCurrentParameter(param);
                    }
                }
            }
        }