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);
            }
        }
        /// <summary>
        /// Check if the property name in the text buffer has changed.
        /// If so, then dismiss the syntax help tip.
        /// </summary>
        private void OnTextBufferChanged(object sender, TextContentChangedEventArgs eventArgs)
        {
            if (_trackingSpan != null && _session != null)
            {
                ITextSnapshot snapshot               = _trackingSpan.TextBuffer.CurrentSnapshot;
                SnapshotPoint startPoint             = _trackingSpan.GetStartPoint(snapshot);
                bool          propertyNameStillValid = false;

                if (startPoint.Position + _propertyName.Length <= snapshot.Length)
                {
                    string text = _trackingSpan.GetText(snapshot);

                    if (text.StartsWith("[", StringComparison.Ordinal))
                    {
                        // The correct property name is still in the code
                        propertyNameStillValid = true;
                        _session.Match();
                    }
                }

                if (!propertyNameStillValid)
                {
                    _session.Dismiss();
                }
            }
        }
Ejemplo n.º 3
0
        private void UpdateSession()
        {
            if (_session == null)
            {
                return;
            }

            UpdateModel();
            _session.Recalculate();
            _session.Match();
        }
Ejemplo n.º 4
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.º 5
0
        private void UpdateSession()
        {
            if (_session == null)
            {
                return;
            }

            UpdateModel().ContinueWith(t =>
            {
                if (_session == null)
                {
                    return;
                }
                _session.Recalculate();
                _session.Match();
            }, CancellationToken.None,
                                       TaskContinuationOptions.OnlyOnRanToCompletion,
                                       TaskScheduler.FromCurrentSynchronizationContext());
        }
Ejemplo n.º 6
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);
            }
        }
        private void TriggerSession()
        {
            if (_session == null || _session.IsDismissed)
            {
                if (_quickInfoBroker.IsQuickInfoActive(_view))
                {
                    _quickInfoBroker.GetSessions(_view)[0].Dismiss();
                }

                ThreadHelper.JoinableTaskFactory.StartOnIdle(
                    () =>
                {
                    _session = _signaturehelpBroker.TriggerSignatureHelp(_view);
                    if (_session != null)
                    {
                        _session.Match();
                    }

                    return(Task.CompletedTask);
                },
                    VsTaskRunContext.UIThreadNormalPriority);
            }
        }