public ScriptCompletionReplacementSource(ITextBuffer textBuffer)
        {
            _textBuffer = textBuffer;

            if (textBuffer.ContentType.TypeName.Equals("HTML", StringComparison.OrdinalIgnoreCase))
                _lbm = VsServiceManager.GetLanguageBlockManager(textBuffer);
        }
        public ScriptCompletionReplacementSource(ITextBuffer textBuffer)
        {
            _textBuffer = textBuffer;

            if (textBuffer.ContentType.TypeName.Equals("HTML", StringComparison.OrdinalIgnoreCase))
            {
                _lbm = VsServiceManager.GetLanguageBlockManager(textBuffer);
            }
        }
        public ScriptCompletionWatcher(IWpfTextView view, ICompletionBroker broker)
        {
            _textView = view;
            _broker = broker;

            var htmlBuffers = view.BufferGraph.GetTextBuffers(tb => tb.ContentType.TypeName.Equals("HTML", StringComparison.OrdinalIgnoreCase));

            if (htmlBuffers.Any())
                _lbm = VsServiceManager.GetLanguageBlockManager(htmlBuffers.First());
        }
Beispiel #4
0
        public ScriptCompletionWatcher(IWpfTextView view, ICompletionBroker broker)
        {
            _textView = view;
            _broker   = broker;

            var htmlBuffers = view.BufferGraph.GetTextBuffers(tb => tb.ContentType.TypeName.Equals("HTML", StringComparison.OrdinalIgnoreCase));

            if (htmlBuffers.Any())
            {
                _lbm = VsServiceManager.GetLanguageBlockManager(htmlBuffers.First());
            }
        }
        internal static bool FindMatchingBrace(ILanguageBlockManager lbm, IClassifier classifier, SnapshotPoint startPoint, bool findClosing, char open, char close, int maxLines, ref bool maxLinesReached, out SnapshotSpan pairSpan)
        {
            // Get script block we're working in
            // lbm will be null if this is not in an HTML file
            var scriptBlock = lbm != null
                ? JScriptEditorUtil.GetJavaScriptBlockSpans(lbm)
                    .Single(b => b.Start <= startPoint.Position && b.End >= startPoint.Position)
                : new BlockSpan(0, startPoint.Snapshot.TextBuffer.CurrentSnapshot.Length, true);

            return findClosing
                ? FindMatchingCloseChar(scriptBlock, classifier, startPoint, open, close, maxLines, ref maxLinesReached, out pairSpan)
                : FindMatchingOpenChar(scriptBlock, classifier, startPoint, close, open, maxLines, ref maxLinesReached, out pairSpan);
        }
Beispiel #6
0
        internal static bool FindMatchingBrace(ILanguageBlockManager lbm, IClassifier classifier, SnapshotPoint startPoint, bool findClosing, char open, char close, int maxLines, ref bool maxLinesReached, out SnapshotSpan pairSpan)
        {
            // Get script block we're working in
            // lbm will be null if this is not in an HTML file
            var scriptBlock = lbm != null
                ? JScriptEditorUtil.GetJavaScriptBlockSpans(lbm)
                              .Single(b => b.Start <= startPoint.Position && b.End >= startPoint.Position)
                : new BlockSpan(0, startPoint.Snapshot.TextBuffer.CurrentSnapshot.Length, true);

            return(findClosing
                ? FindMatchingCloseChar(scriptBlock, classifier, startPoint, open, close, maxLines, ref maxLinesReached, out pairSpan)
                : FindMatchingOpenChar(scriptBlock, classifier, startPoint, close, open, maxLines, ref maxLinesReached, out pairSpan));
        }
Beispiel #7
0
        internal JScriptBraceMatchingTagger(ITextView view, ITextBuffer sourceBuffer, IClassifier classifier)
        {
            _view             = view;
            _sourceBuffer     = sourceBuffer;
            _currentCharPoint = null;
            _classifier       = classifier;

            _view.TextBuffer.Changed    += TextBuffer_Changed;
            _view.Caret.PositionChanged += Caret_PositionChanged;

            if (sourceBuffer.ContentType.TypeName.Equals("HTML", StringComparison.OrdinalIgnoreCase))
            {
                _lbm = VsServiceManager.GetLanguageBlockManager(_sourceBuffer);
            }
        }
        public static bool IsInJScriptLanguageBlock(ILanguageBlockManager lbm, SnapshotPoint point)
        {
            var lbColl = lbm.GetLanguageBlockCollection();
            var lbCount = lbColl.GetCount();
            for (var i = 0; i < lbCount; i++)
            {
                var lb = lbColl.GetAtIndex(i);
                int start, length;
                bool isEndInclusive;
                lb.GetExtent(out start, out length, out isEndInclusive);
                int end = isEndInclusive ? start + length : start + length - 1;

                if (point >= start && point <= end)
                {
                    // Current point is in this language block
                    return (lb.GetContainedLanguage().GetLanguageServiceGuid() == _jsLangServiceGuid);
                }
            }
            // Looped through all blocks and point was not in any of them
            return false;
        }
        public static List<BlockSpan> GetJavaScriptBlockSpans(ILanguageBlockManager languageBlockManager)
        {
            var javaScriptBlockSpans = new List<BlockSpan>();

            var languageBlockCollection = languageBlockManager.GetLanguageBlockCollection();
            int languageBlockCount = languageBlockCollection.GetCount();
            for (int i = 0; i < languageBlockCount; i++)
            {
                var languageBlock = languageBlockCollection.GetAtIndex(i);
                if (languageBlock.GetContainedLanguage().GetLanguageServiceGuid() == _jsLangServiceGuid)
                {
                    int start, length;
                    bool isEndInclusive;

                    languageBlock.GetExtent(out start, out length, out isEndInclusive);
                    javaScriptBlockSpans.Add(new BlockSpan(start, length, isEndInclusive));
                }
            }

            // Looped through all blocks and point was not in any of them
            return javaScriptBlockSpans;
        }
        public static bool IsInJScriptLanguageBlock(ILanguageBlockManager lbm, SnapshotPoint point)
        {
            var lbColl  = lbm.GetLanguageBlockCollection();
            var lbCount = lbColl.GetCount();

            for (var i = 0; i < lbCount; i++)
            {
                var  lb = lbColl.GetAtIndex(i);
                int  start, length;
                bool isEndInclusive;
                lb.GetExtent(out start, out length, out isEndInclusive);
                int end = isEndInclusive ? start + length : start + length - 1;

                if (point >= start && point <= end)
                {
                    // Current point is in this language block
                    return(lb.GetContainedLanguage().GetLanguageServiceGuid() == _jsLangServiceGuid);
                }
            }
            // Looped through all blocks and point was not in any of them
            return(false);
        }
        public static List <BlockSpan> GetJavaScriptBlockSpans(ILanguageBlockManager languageBlockManager)
        {
            var javaScriptBlockSpans = new List <BlockSpan>();

            var languageBlockCollection = languageBlockManager.GetLanguageBlockCollection();
            int languageBlockCount      = languageBlockCollection.GetCount();

            for (int i = 0; i < languageBlockCount; i++)
            {
                var languageBlock = languageBlockCollection.GetAtIndex(i);
                if (languageBlock.GetContainedLanguage().GetLanguageServiceGuid() == _jsLangServiceGuid)
                {
                    int  start, length;
                    bool isEndInclusive;

                    languageBlock.GetExtent(out start, out length, out isEndInclusive);
                    javaScriptBlockSpans.Add(new BlockSpan(start, length, isEndInclusive));
                }
            }

            // Looped through all blocks and point was not in any of them
            return(javaScriptBlockSpans);
        }
Beispiel #12
0
        public OutliningTagger(ITextBuffer buffer, IClassifier classifier)
        {
            _buffer     = buffer;
            _classifier = classifier;
            _sections   = new List <ITrackingSpan>();

            if (buffer.ContentType.TypeName.Equals("HTML", StringComparison.OrdinalIgnoreCase))
            {
                _lbm = VsServiceManager.GetLanguageBlockManager(buffer);
            }

            _timer          = new DispatcherTimer(DispatcherPriority.ApplicationIdle);
            _timer.Interval = TimeSpan.FromMilliseconds(3000); // We'll force a reparse after 3 secs of no buffer changes
            _timer.Tick    += (sender, args) =>
            {
                Debug.WriteLine("OutliningTagger: _timer.Tick fired");
                _timer.Stop();
                ReparseFile();
            };
            buffer.Changed += BufferChanged;
            ReparseFile(); // Force an initial full parse
            _timer.Start();
        }