Beispiel #1
0
        public HtmlFindAllReferences(IVsTextView adapter, IWpfTextView textView)
            : base(adapter, textView, VSConstants.VSStd97CmdID.FindReferences)
        {
            HtmlEditorDocument document = HtmlEditorDocument.TryFromTextView(textView);

            _tree = document == null ? null : document.HtmlEditorTree;
        }
Beispiel #2
0
        public HtmlGoToDefinition(IVsTextView adapter, IWpfTextView textView)
            : base(adapter, textView, VSConstants.VSStd97CmdID.GotoDefn)
        {
            HtmlEditorDocument document = HtmlEditorDocument.TryFromTextView(textView);

            _tree = document == null ? null : document.HtmlEditorTree;
        }
 public EnterFormat(IVsTextView adapter, IWpfTextView textView, IEditorFormatterProvider formatterProvider, ICompletionBroker broker)
     : base(adapter, textView, VSConstants.VSStd2KCmdID.RETURN)
 {
     _tree      = HtmlEditorDocument.FromTextView(textView).HtmlEditorTree;
     _formatter = formatterProvider.CreateRangeFormatter();
     _broker    = broker;
 }
 public EnterFormat(IVsTextView adapter, IWpfTextView textView, IEditorFormatterProvider formatterProvider, ICompletionBroker broker)
     : base(adapter, textView, typeof(Microsoft.VisualStudio.VSConstants.VSStd2KCmdID).GUID, 3)
 {
     _tree = HtmlEditorDocument.FromTextView(textView).HtmlEditorTree;
     _formatter = formatterProvider.CreateRangeFormatter();
     _broker = broker;
 }
Beispiel #5
0
        public DirectiveGoToDefinition(IVsTextView adapter, IWpfTextView textView, DTE dte, INgHierarchyProvider ngHierarchyProvider)
            : base(adapter, textView, VSConstants.VSStd97CmdID.GotoDefn)
        {
            HtmlEditorDocument document = HtmlEditorDocument.TryFromTextView(textView);

            this.tree = document == null ? null : document.HtmlEditorTree;
            this.dte  = dte;
            this.ngHierarchyProvider = ngHierarchyProvider;
        }
        private void SelectCaretNode(HtmlEditorTree tree, ElementNode tag)
        {
            var current = NodeAtCaret(tree);
            var child = ChildNode(current, tag);

            if (tag.Children.Contains(child))
                Select(child.Start, child.OuterRange.Length);
            else
                Select(tag.Children[0].Start, tag.Children[0].End - tag.Children[0].Start);
        }
        private ElementNode NodeAtCaret(HtmlEditorTree tree)
        {
            int start = _view.Caret.Position.BufferPosition.Position;

            ElementNode tag = null;
            AttributeNode attr = null;

            tree.GetPositionElement(start, out tag, out attr);

            return tag;
        }
Beispiel #8
0
        private ElementNode NodeAtCaret(HtmlEditorTree tree)
        {
            int start = _view.Caret.Position.BufferPosition.Position;

            ElementNode   tag  = null;
            AttributeNode attr = null;

            tree.GetPositionElement(start, out tag, out attr);

            return(tag);
        }
Beispiel #9
0
        private void SelectCaretNode(HtmlEditorTree tree, ElementNode tag)
        {
            var current = NodeAtCaret(tree);
            var child   = ChildNode(current, tag);

            if (tag.Children.Contains(child))
            {
                Select(child.Start, child.OuterRange.Length);
            }
            else
            {
                Select(tag.Children[0].Start, tag.Children[0].End - tag.Children[0].Start);
            }
        }
Beispiel #10
0
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> qiContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;

            SnapshotPoint?point = session.GetTriggerPoint(session.TextView.TextBuffer.CurrentSnapshot);

            if (!point.HasValue)
            {
                return;
            }

            HtmlEditorTree tree = HtmlEditorDocument.TryFromTextView(session.TextView).HtmlEditorTree;

            if (tree == null)
            {
                return;
            }

            ElementNode   node = null;
            AttributeNode attr = null;

            tree.GetPositionElement(point.Value.Position, out node, out attr);

            if (node == null || (!node.Name.Equals("img", StringComparison.OrdinalIgnoreCase) && !node.Name.Equals("source", StringComparison.OrdinalIgnoreCase)))
            {
                return;
            }
            if (attr == null || !attr.Name.Equals("src", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            string url = ImageQuickInfo.GetFullUrl(attr.Value, session.TextView.TextBuffer);

            if (string.IsNullOrEmpty(url))
            {
                return;
            }

            applicableToSpan = session.TextView.TextBuffer.CurrentSnapshot.CreateTrackingSpan(point.Value.Position, 1, SpanTrackingMode.EdgeNegative);

            ImageQuickInfo.AddImageContent(qiContent, url);
        }
Beispiel #11
0
        /// <summary>
        /// Finds a single property value at a given position in the tree.
        /// </summary>
        /// <param name="buffer">Any HTML editor tree</param>
        /// <param name="position">The position in the buffer</param>
        /// <param name="attributeNames">One or more HTML attribute names, such as 'class', 'id', 'src' etc.</param>
        /// <returns>A single value matching the position in the tree</returns>
        public static string GetSinglePropertyValue(HtmlEditorTree tree, int position, params string[] attributeNames)
        {
            ElementNode element = null;
            AttributeNode attr = null;

            tree.GetPositionElement(position, out element, out attr);

            if (attr == null || !attributeNames.Contains(attr.Name, StringComparer.OrdinalIgnoreCase))
                return null;

            int beginning = position - attr.ValueRangeUnquoted.Start;
            int start = attr.Value.LastIndexOf(' ', beginning) + 1;
            int length = attr.Value.IndexOf(' ', start) - start;

            if (length < 0)
                length = attr.ValueRangeUnquoted.Length - start;

            return attr.Value.Substring(start, length);
        }
Beispiel #12
0
        /// <summary>
        /// Finds a single property value at a given position in the tree.
        /// </summary>
        /// <param name="buffer">Any HTML editor tree</param>
        /// <param name="position">The position in the buffer</param>
        /// <param name="attributeNames">One or more HTML attribute names, such as 'class', 'id', 'src' etc.</param>
        /// <returns>A single value matching the position in the tree</returns>
        public static string GetSinglePropertyValue(HtmlEditorTree tree, int position, params string[] attributeNames)
        {
            tree.GetPositionElement(position, out ElementNode element, out AttributeNode attr);

            if (attr == null || !attributeNames.Contains(attr.Name, StringComparer.OrdinalIgnoreCase))
            {
                return(null);
            }

            int beginning = position - attr.ValueRangeUnquoted.Start;
            int start     = attr.Value.LastIndexOf(' ', beginning) + 1;
            int length    = attr.Value.IndexOf(' ', start) - start;

            if (length < 0)
            {
                length = attr.ValueRangeUnquoted.Length - start;
            }

            return(attr.Value.Substring(start, length));
        }
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> qiContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;

            SnapshotPoint?point = session.GetTriggerPoint(session.TextView.TextBuffer.CurrentSnapshot);

            if (!point.HasValue)
            {
                return;
            }

            HtmlEditorTree tree = HtmlEditorDocument.FromTextView(session.TextView).HtmlEditorTree;

            ElementNode   node = null;
            AttributeNode attr = null;

            tree.GetPositionElement(point.Value.Position, out node, out attr);

            if (attr == null || (attr.Name != "href" && attr.Name != "src"))
            {
                return;
            }

            string url = GetFileName(attr.Value.Trim('\'', '"').TrimStart('~'));

            if (!string.IsNullOrEmpty(url))
            {
                applicableToSpan = session.TextView.TextBuffer.CurrentSnapshot.CreateTrackingSpan(point.Value.Position, 1, SpanTrackingMode.EdgeNegative);
                var image = CreateImage(url);
                if (image != null && image.Source != null)
                {
                    qiContent.Add(image);
                    qiContent.Add(Math.Round(image.Source.Width) + "x" + Math.Round(image.Source.Height));
                }
            }
        }
 public TemplateBufferGenerator(HtmlEditorTree editorTree, LanguageBlockCollection languageBlocks)
     : base(editorTree, languageBlocks, ContentTypeManager.GetContentType(TemplateTagContentType.ContentTypeName))
 {
 }
Beispiel #15
0
 public TemplateBlockHandler(HtmlEditorTree editorTree)
     : base(editorTree, ContentTypeManager.GetContentType(TemplateHtmlContentType.ContentTypeName))
 {
 }
 public override void Init(HtmlEditorTree editorTree) {
     base.Init(editorTree);
     ContainedLanguageBlockHandler = new TemplateBlockHandler(editorTree);
 }
Beispiel #17
0
 public HtmlGoToDefinition(IVsTextView adapter, IWpfTextView textView)
     : base(adapter, textView, VSConstants.VSStd97CmdID.GotoDefn)
 {
     _tree = HtmlEditorDocument.FromTextView(textView).HtmlEditorTree;
 }
 public HtmlGoToDefinition(IVsTextView adapter, IWpfTextView textView)
     : base(adapter, textView, typeof(Microsoft.VisualStudio.VSConstants.VSStd97CmdID).GUID, (uint)Microsoft.VisualStudio.VSConstants.VSStd97CmdID.GotoDefn)
 {
     _tree = HtmlEditorDocument.FromTextView(textView).HtmlEditorTree;
 }
Beispiel #19
0
 public HtmlFindAllReferences(IVsTextView adapter, IWpfTextView textView)
     : base(adapter, textView, VSConstants.VSStd97CmdID.FindReferences)
 {
     _tree = HtmlEditorDocument.FromTextView(textView).HtmlEditorTree;
 }
Beispiel #20
0
 public TemplateBufferGenerator(HtmlEditorTree editorTree, LanguageBlockCollection languageBlocks)
     : base(editorTree, languageBlocks, ContentTypeManager.GetContentType(TemplateTagContentType.ContentTypeName)) {
 }
Beispiel #21
0
 public CodeBlockBlockHandler(HtmlEditorTree tree, IContentTypeRegistryService contentTypeRegistry)
     : base(tree, contentTypeRegistry.GetContentType("code"))
 {
     this.contentTypeRegistry = contentTypeRegistry;
 }
 public override void Init(HtmlEditorTree editorTree)
 {
     base.Init(editorTree);
     ContainedLanguageBlockHandler = new TemplateBlockHandler(editorTree);
 }
 public MarkdownBufferGenerator(HtmlEditorTree editorTree, LanguageBlockCollection languageBlocks, IContentTypeRegistryService contentTypeRegistry)
     : base(editorTree, languageBlocks)
 {
     this.contentTypeRegistry = contentTypeRegistry;
 }
Beispiel #24
0
 public EnterFormat(IVsTextView adapter, IWpfTextView textView, IEditorFormatterProvider formatterProvider)
     : base(adapter, textView, typeof(Microsoft.VisualStudio.VSConstants.VSStd2KCmdID).GUID, 3)
 {
     _tree      = HtmlEditorDocument.FromTextView(textView).HtmlEditorTree;
     _formatter = formatterProvider.CreateRangeFormatter();
 }
 public CodeBlockBlockHandler(HtmlEditorTree tree, IContentTypeRegistryService contentTypeRegistry)
     : base(tree, contentTypeRegistry.GetContentType("code"))
 {
     this.contentTypeRegistry = contentTypeRegistry;
 }
Beispiel #26
0
 public TemplateBlockHandler(HtmlEditorTree editorTree)
     : base(editorTree, ContentTypeManager.GetContentType(TemplateHtmlContentType.ContentTypeName)) {
 }
 public HtmlFindAllReferences(IVsTextView adapter, IWpfTextView textView)
     : base(adapter, textView, typeof(Microsoft.VisualStudio.VSConstants.VSStd97CmdID).GUID, (uint)Microsoft.VisualStudio.VSConstants.VSStd97CmdID.FindReferences)
 {
     _tree = HtmlEditorDocument.FromTextView(textView).HtmlEditorTree;
 }
 public MarkdownBufferGenerator(HtmlEditorTree editorTree, LanguageBlockCollection languageBlocks, IContentTypeRegistryService contentTypeRegistry)
     : base(editorTree, languageBlocks)
 {
     this.contentTypeRegistry = contentTypeRegistry;
 }