Esempio n. 1
0
 public static void AcceptCallsVisitAttributeValueMethodOfSyntaxNodeVisitor()
 {
     var visitor = Substitute.For<SyntaxNodeVisitor>();
     var node = new AttributeValue(0, string.Empty);
     node.Accept(visitor);
     visitor.Received().VisitAttributeValue(node);
 }
 public static void VisitAttributeValueCallsVisitCaptureNodeToAllowProcessingAllCaptureNodesPolymorphically()
 {
     var visitor = Substitute.ForPartsOf<SyntaxNodeVisitor>();
     var attributeValue = new AttributeValue(0, "value");
     visitor.VisitAttributeValue(attributeValue);
     visitor.Received().VisitCaptureNode(attributeValue);
     Assert.Equal(typeof(CaptureNode), typeof(AttributeValue).BaseType);
 }
Esempio n. 3
0
 public static void ChildNodesReturnsNodesSpecifiedInConstructor()
 {
     var name = new AttributeName(0, "language");
     var equals = new Equals(8);
     var quote1 = new DoubleQuote(9);
     var value = new AttributeValue(10, "C#");
     var quote2 = new DoubleQuote(12);
     var attribute = new Attribute(name, equals, quote1, value, quote2);
     Assert.True(new SyntaxNode[] { name, equals, quote1, value, quote2 }.SequenceEqual(attribute.ChildNodes()));
 }
Esempio n. 4
0
        public Attribute(AttributeName name, Equals equals, DoubleQuote quote1, AttributeValue value, DoubleQuote quote2)
        {
            Debug.Assert(name != null, "name");
            Debug.Assert(equals != null, "equals");
            Debug.Assert(quote1 != null, "quote1");
            Debug.Assert(value != null, "value");
            Debug.Assert(quote2 != null, "quote2");

            this.name = name;
            this.equals = equals;
            this.quote1 = quote1;
            this.value = value;
            this.quote2 = quote2;
        }
        protected internal override void VisitAttributeValue(AttributeValue node)
        {
            base.VisitAttributeValue(node);

            if (node.Span.Start <= this.position && this.position <= node.Span.End)
            {
                Debug.Assert(this.currentDirective != null, "currentDirective");
                Debug.Assert(this.currentAttribute != null, "currentAttribute");
                DirectiveDescriptor directiveDescriptor = DirectiveDescriptor.GetDirectiveDescriptor(this.currentDirective.GetType());
                AttributeDescriptor attributeDescriptor;
                if (directiveDescriptor.Attributes.TryGetValue(this.currentAttribute.Name, out attributeDescriptor))
                {
                    this.Completions = new List<Completion>(attributeDescriptor.Values.Values.Select(CreateAttributeValueCompletion));
                    this.Node = node;
                }
            }
        }
 public static void NodeReturnsAttributeValueWhenPositionIsWithinAttributeValue()
 {
     AttributeValue attributeValue;
     var directive = new TemplateDirective(
         new DirectiveBlockStart(0),
         new DirectiveName(4, "template"),
         new[] { new Attribute(new AttributeName(13, "debug"), new Equals(18), new DoubleQuote(19), attributeValue = new AttributeValue(20, string.Empty), new DoubleQuote(20)) },
         new BlockEnd(22));
     var builder = new TemplateCompletionBuilder(20);
     builder.Visit(directive);
     Assert.Same(attributeValue, builder.Node);
 }
Esempio n. 7
0
        public static void KindReturnsAttributeValueSyntaxKind()
        {
            var target = new AttributeValue(0, string.Empty);

            Assert.Equal(SyntaxKind.AttributeValue, target.Kind);
        }
Esempio n. 8
0
 public static void ValidateReturnsTemplateErrorWhenAttributeValueDoesNotMatchKnownValues()
 {
     AttributeValue value;
     var directive = new DirectiveWithKnownAttributeValues(
         new DirectiveBlockStart(0), 
         new DirectiveName(4, "directive"), 
         new[] { new Attribute(new AttributeName(13, "attributeWithKnownValues"), new Equals(37), new DoubleQuote(38), value = new AttributeValue(39, "wrong"), new DoubleQuote(44)) },
         new BlockEnd(46));
     TemplateError error = directive.Validate().Single();
     Assert.Contains("attributeWithKnownValues", error.Message, StringComparison.OrdinalIgnoreCase);
     Assert.Contains("wrong", error.Message, StringComparison.OrdinalIgnoreCase);
     Assert.Equal(value.Span, error.Span);
     Assert.Equal(value.Position, error.Position);
 }
Esempio n. 9
0
 protected internal virtual void VisitAttributeValue(AttributeValue node)
 {
     this.VisitCaptureNode(node);
 }
Esempio n. 10
0
 protected internal virtual void VisitAttributeValue(AttributeValue node)
 {
     this.VisitCaptureNode(node);
 }
Esempio n. 11
0
        public static void ValidateReturnsTemplateErrorWhenAttributeValueDoesNotMatchKnownValues()
        {
            AttributeValue value;
            var            directive = new DirectiveWithKnownAttributeValues(
                new DirectiveBlockStart(0),
                new DirectiveName(4, "directive"),
                new[] { new Attribute(new AttributeName(13, "attributeWithKnownValues"), new Equals(37), new DoubleQuote(38), value = new AttributeValue(39, "wrong"), new DoubleQuote(44)) },
                new BlockEnd(46));
            TemplateError error = directive.Validate().Single();

            Assert.Contains("attributeWithKnownValues", error.Message, StringComparison.OrdinalIgnoreCase);
            Assert.Contains("wrong", error.Message, StringComparison.OrdinalIgnoreCase);
            Assert.Equal(value.Span, error.Span);
            Assert.Equal(value.Position, error.Position);
        }
Esempio n. 12
0
 public static void KindReturnsAttributeValueSyntaxKind()
 {
     var target = new AttributeValue(0, string.Empty);
     Assert.Equal(SyntaxKind.AttributeValue, target.Kind);
 }