public ComponentAccessibilityCodeActionProvider(
     TagHelperFactsService tagHelperFactsService,
     FilePathNormalizer filePathNormalizer)
 {
     _tagHelperFactsService = tagHelperFactsService ?? throw new ArgumentNullException(nameof(tagHelperFactsService));
     _filePathNormalizer    = filePathNormalizer ?? throw new ArgumentNullException(nameof(filePathNormalizer));
 }
        public void StringifyAttributes_MinimizedTagHelperAttribute()
        {
            // Arrange
            var tagHelper = TagHelperDescriptorBuilder.Create("WithBoundAttribute", "TestAssembly");

            tagHelper.TagMatchingRule(rule => rule.TagName = "test");
            tagHelper.BindAttribute(attribute =>
            {
                attribute.Name = "bound";
                attribute.SetPropertyName("Bound");
                attribute.TypeName = typeof(bool).FullName;
            });
            tagHelper.SetTypeName("WithBoundAttribute");
            var codeDocument         = CreateCodeDocument($"@addTagHelper *, TestAssembly{Environment.NewLine}<test bound />", isRazorFile: false, tagHelper.Build());
            var syntaxTree           = codeDocument.GetSyntaxTree();
            var sourceSpan           = new SourceSpan(30 + Environment.NewLine.Length, 0);
            var sourceChangeLocation = new SourceChange(sourceSpan, string.Empty);
            var startTag             = (MarkupTagHelperStartTagSyntax)syntaxTree.Root.LocateOwner(sourceChangeLocation).Parent;

            // Act
            var attributes = TagHelperFactsService.StringifyAttributes(startTag.Attributes);

            // Assert
            Assert.Collection(
                attributes,
                attribute =>
            {
                Assert.Equal("bound", attribute.Key);
                Assert.Equal(string.Empty, attribute.Value);
            });
        }
Exemple #3
0
        public DefaultRazorHoverInfoService(
            TagHelperFactsService tagHelperFactsService,
            LSPTagHelperTooltipFactory lspTagHelperTooltipFactory,
            VSLSPTagHelperTooltipFactory vsLspTagHelperTooltipFactory,
            HtmlFactsService htmlFactsService)
        {
            if (tagHelperFactsService is null)
            {
                throw new ArgumentNullException(nameof(tagHelperFactsService));
            }

            if (lspTagHelperTooltipFactory is null)
            {
                throw new ArgumentNullException(nameof(lspTagHelperTooltipFactory));
            }

            if (vsLspTagHelperTooltipFactory is null)
            {
                throw new ArgumentNullException(nameof(vsLspTagHelperTooltipFactory));
            }

            if (htmlFactsService is null)
            {
                throw new ArgumentNullException(nameof(htmlFactsService));
            }

            _tagHelperFactsService        = tagHelperFactsService;
            _lspTagHelperTooltipFactory   = lspTagHelperTooltipFactory;
            _vsLspTagHelperTooltipFactory = vsLspTagHelperTooltipFactory;
            _htmlFactsService             = htmlFactsService;
        }
Exemple #4
0
        public DefaultTagHelperCompletionService(
            RazorTagHelperCompletionService razorCompletionService,
            HtmlFactsService htmlFactsService,
            TagHelperFactsService tagHelperFactsService,
            ILanguageServer languageServer)
        {
            if (razorCompletionService is null)
            {
                throw new ArgumentNullException(nameof(razorCompletionService));
            }

            if (htmlFactsService is null)
            {
                throw new ArgumentNullException(nameof(htmlFactsService));
            }

            if (tagHelperFactsService is null)
            {
                throw new ArgumentNullException(nameof(tagHelperFactsService));
            }

            if (languageServer is null)
            {
                throw new ArgumentNullException(nameof(languageServer));
            }

            _razorTagHelperCompletionService = razorCompletionService;
            _htmlFactsService      = htmlFactsService;
            _tagHelperFactsService = tagHelperFactsService;
            LanguageServer         = languageServer;
        }
Exemple #5
0
        public DirectiveAttributeCompletionItemProvider(TagHelperFactsService tagHelperFactsService)
        {
            if (tagHelperFactsService is null)
            {
                throw new ArgumentNullException(nameof(tagHelperFactsService));
            }

            _tagHelperFactsService = tagHelperFactsService;
        }
Exemple #6
0
        public AttributeSnippetOnAutoInsertProvider(TagHelperFactsService tagHelperFactsService)
        {
            if (tagHelperFactsService is null)
            {
                throw new ArgumentNullException(nameof(tagHelperFactsService));
            }

            _tagHelperFactsService = tagHelperFactsService;
        }
        public void StringifyAttributes_MinimizedDirectiveAttributeWithParameter()
        {
            // Arrange
            var codeDocument         = CreateComponentDocument($"<TestElement @minimized:something />", DefaultTagHelpers);
            var syntaxTree           = codeDocument.GetSyntaxTree();
            var sourceSpan           = new SourceSpan(3, 0);
            var sourceChangeLocation = new SourceChange(sourceSpan, string.Empty);
            var startTag             = (MarkupTagHelperStartTagSyntax)syntaxTree.Root.LocateOwner(sourceChangeLocation).Parent;

            // Act
            var attributes = TagHelperFactsService.StringifyAttributes(startTag.Attributes);

            // Assert
            Assert.Collection(
                attributes,
                attribute =>
            {
                Assert.Equal("@minimized:something", attribute.Key);
                Assert.Equal(string.Empty, attribute.Value);
            });
        }
        public void StringifyAttributes_IgnoresMiscContent()
        {
            // Arrange
            var codeDocument         = CreateCodeDocument($"@addTagHelper *, TestAssembly{Environment.NewLine}<input unbound @DateTime.Now />", isRazorFile: false, DefaultTagHelpers);
            var syntaxTree           = codeDocument.GetSyntaxTree();
            var sourceSpan           = new SourceSpan(30 + Environment.NewLine.Length, 0);
            var sourceChangeLocation = new SourceChange(sourceSpan, string.Empty);
            var startTag             = (MarkupStartTagSyntax)syntaxTree.Root.LocateOwner(sourceChangeLocation).Parent;

            // Act
            var attributes = TagHelperFactsService.StringifyAttributes(startTag.Attributes);

            // Assert
            Assert.Collection(
                attributes,
                attribute =>
            {
                Assert.Equal("unbound", attribute.Key);
                Assert.Equal(string.Empty, attribute.Value);
            });
        }
Exemple #9
0
        public void StringifyAttributes_UnboundAttribute()
        {
            // Arrange
            var codeDocument         = DefaultTagHelperCompletionServiceTest.CreateCodeDocument($"@addTagHelper *, TestAssembly{Environment.NewLine}<input unbound='hello world' />", DefaultTagHelpers);
            var syntaxTree           = codeDocument.GetSyntaxTree();
            var sourceSpan           = new SourceSpan(30 + Environment.NewLine.Length, 0);
            var sourceChangeLocation = new SourceChange(sourceSpan, string.Empty);
            var startTag             = (MarkupStartTagSyntax)syntaxTree.Root.LocateOwner(sourceChangeLocation).Parent;

            // Act
            var attributes = TagHelperFactsService.StringifyAttributes(startTag.Attributes);

            // Assert
            Assert.Collection(
                attributes,
                attribute =>
            {
                Assert.Equal("unbound", attribute.Key);
                Assert.Equal("hello world", attribute.Value);
            });
        }
        public TagHelperCompletionProvider(
            TagHelperCompletionService tagHelperCompletionService,
            HtmlFactsService htmlFactsService,
            TagHelperFactsService tagHelperFactsService)
        {
            if (tagHelperCompletionService is null)
            {
                throw new ArgumentNullException(nameof(tagHelperCompletionService));
            }

            if (htmlFactsService is null)
            {
                throw new ArgumentNullException(nameof(htmlFactsService));
            }

            if (tagHelperFactsService is null)
            {
                throw new ArgumentNullException(nameof(tagHelperFactsService));
            }

            _tagHelperCompletionService = tagHelperCompletionService;
            _htmlFactsService           = htmlFactsService;
            _tagHelperFactsService      = tagHelperFactsService;
        }
Exemple #11
0
        public DefaultRazorHoverInfoService(
            TagHelperFactsService tagHelperFactsService,
            TagHelperDescriptionFactory tagHelperDescriptionFactory,
            HtmlFactsService htmlFactsService)
        {
            if (tagHelperFactsService is null)
            {
                throw new ArgumentNullException(nameof(tagHelperFactsService));
            }

            if (tagHelperDescriptionFactory is null)
            {
                throw new ArgumentNullException(nameof(tagHelperDescriptionFactory));
            }

            if (htmlFactsService is null)
            {
                throw new ArgumentNullException(nameof(htmlFactsService));
            }

            _tagHelperFactsService       = tagHelperFactsService;
            _tagHelperDescriptionFactory = tagHelperDescriptionFactory;
            _htmlFactsService            = htmlFactsService;
        }