Esempio n. 1
0
        private void ProcessAttributeValue([NotNull] T4Token valueNode)
        {
            if (!(valueNode.Parent is IT4DirectiveAttribute attribute))
            {
                return;
            }

            if (attribute.ValueError != null)
            {
                AddHighlighting(valueNode.GetHighlightingRange(), new InvalidAttributeValueHighlighting(valueNode, null, attribute.ValueError));
                return;
            }

            if (!(attribute.Parent is IT4Directive directive))
            {
                return;
            }

            DirectiveAttributeInfo attributeInfo = _directiveInfoManager.GetDirectiveByName(directive.GetName())?.GetAttributeByName(attribute.GetName());

            if (attributeInfo == null || attributeInfo.IsValid(valueNode.GetText()))
            {
                return;
            }

            AddHighlighting(valueNode.GetHighlightingRange(), new InvalidAttributeValueHighlighting(valueNode, attributeInfo, "Invalid attribute value"));
        }
Esempio n. 2
0
        private void ProcessAttributeValue([NotNull] T4Token valueNode)
        {
            var attribute = valueNode.Parent as IT4DirectiveAttribute;

            if (attribute == null)
            {
                return;
            }

            if (attribute.ValueError != null)
            {
                AddHighlighting(new HighlightingInfo(valueNode.GetHighlightingRange(),
                                                     new InvalidAttributeValueHighlighting(valueNode, null, attribute.ValueError)));
                return;
            }

            var directive = attribute.Parent as IT4Directive;

            if (directive == null)
            {
                return;
            }

            DirectiveInfo directiveInfo = _directiveInfoManager.GetDirectiveByName(directive.GetName());

            if (directiveInfo == null)
            {
                return;
            }

            DirectiveAttributeInfo attributeInfo = directiveInfo.GetAttributeByName(attribute.GetName());

            if (attributeInfo == null)
            {
                return;
            }

            if (attributeInfo.IsValid(valueNode.GetText()))
            {
                return;
            }

            AddHighlighting(new HighlightingInfo(valueNode.GetHighlightingRange(),
                                                 new InvalidAttributeValueHighlighting(valueNode, attributeInfo, "Invalid attribute value")));
        }