Esempio n. 1
0
 public static void AcceptCallsVisitBlockEndMethodOfSyntaxNodeVisitor()
 {
     var visitor = Substitute.For<SyntaxNodeVisitor>();
     var node = new BlockEnd(0);
     node.Accept(visitor);
     visitor.Received().VisitBlockEnd(node);
 }
Esempio n. 2
0
 public static void ChildNodesReturnsBlockStartAndBlockEnd()
 {
     var start = new StatementBlockStart(default(int));
     var end = new BlockEnd(default(int));
     var codeBlock = new CodeBlock(start, end);
     Assert.True(codeBlock.ChildNodes().SequenceEqual(new SyntaxNode[] { start, end }));
 }
Esempio n. 3
0
 public CodeBlock(CodeBlockStart start, BlockEnd end)
 {
     Debug.Assert(start != null, "start");
     Debug.Assert(end != null, "end");
     this.start = start;
     this.end = end;
 }
Esempio n. 4
0
        public static void SpanEndsAtBlockEnd()
        {
            BlockEnd end;
            var      codeBlock = new CodeBlock(new StatementBlockStart(0), end = new BlockEnd(40));

            Assert.Equal(end.Span.End, codeBlock.Span.End);
        }
Esempio n. 5
0
 public CodeBlock(CodeBlockStart start, BlockEnd end)
 {
     Debug.Assert(start != null, "start");
     Debug.Assert(end != null, "end");
     this.start = start;
     this.end   = end;
 }
Esempio n. 6
0
 public static void SpanEndReturnsMaxEndOfChildNodes()
 {
     var end = new BlockEnd(40);
     var start = new StatementBlockStart(4);
     var target = new Template(end, start); // intentionally reversed
     Assert.Equal(end.Span.End, target.Span.End);
 }
Esempio n. 7
0
        public static void ChildNodesReturnsBlockStartAndBlockEnd()
        {
            var start     = new StatementBlockStart(default(int));
            var end       = new BlockEnd(default(int));
            var codeBlock = new CodeBlock(start, end);

            Assert.True(codeBlock.ChildNodes().SequenceEqual(new SyntaxNode[] { start, end }));
        }
Esempio n. 8
0
        public static void AcceptCallsVisitBlockEndMethodOfSyntaxNodeVisitor()
        {
            var visitor = Substitute.For <SyntaxNodeVisitor>();
            var node    = new BlockEnd(0);

            node.Accept(visitor);
            visitor.Received().VisitBlockEnd(node);
        }
Esempio n. 9
0
        public static void SpanEndReturnsMaxEndOfChildNodes()
        {
            var end    = new BlockEnd(40);
            var start  = new StatementBlockStart(4);
            var target = new Template(end, start); // intentionally reversed

            Assert.Equal(end.Span.End, target.Span.End);
        }
Esempio n. 10
0
 public static void VisitBlockEndCallsVisitSyntaxTokenToAllowProcessingAllSyntaxTokensPolymorphically()
 {
     var visitor = Substitute.ForPartsOf<SyntaxNodeVisitor>();
     var blockEnd = new BlockEnd(0);
     visitor.VisitBlockEnd(blockEnd);
     visitor.Received().VisitSyntaxToken(blockEnd);
     Assert.Equal(typeof(SyntaxToken), typeof(BlockEnd).BaseType);
 }
Esempio n. 11
0
 public static void ChildNodesReturnsNodesSpecifiedInConstructor()
 {
     var start = new StatementBlockStart(0);
     var end = new BlockEnd(2);
     var node = new Template(start, end);
     Assert.Same(start, node.ChildNodes().First());
     Assert.Same(end, node.ChildNodes().Last());
 }
Esempio n. 12
0
        public static void VisitBlockEndCallsVisitSyntaxTokenToAllowProcessingAllSyntaxTokensPolymorphically()
        {
            var visitor  = Substitute.ForPartsOf <SyntaxNodeVisitor>();
            var blockEnd = new BlockEnd(0);

            visitor.VisitBlockEnd(blockEnd);
            visitor.Received().VisitSyntaxToken(blockEnd);
            Assert.Equal(typeof(SyntaxToken), typeof(BlockEnd).BaseType);
        }
Esempio n. 13
0
        public static void ChildNodesReturnsNodesSpecifiedInConstructor()
        {
            var start = new StatementBlockStart(0);
            var end   = new BlockEnd(2);
            var node  = new Template(start, end);

            Assert.Same(start, node.ChildNodes().First());
            Assert.Same(end, node.ChildNodes().Last());
        }
Esempio n. 14
0
        public static void VisitTerminalNodeCallsVisitSyntaxNodeToAllowProcessingAllSyntaxNodesPolymorphically()
        {
            var visitor      = Substitute.ForPartsOf <SyntaxNodeVisitor>();
            var terminalNode = new BlockEnd(0);

            visitor.VisitTerminalNode(terminalNode);
            Assert.Equal(1, visitor.ReceivedCalls().Count(call => call.GetMethodInfo().Name == "VisitSyntaxNode"));
            Assert.Equal(typeof(SyntaxNode), typeof(TerminalNode).BaseType);
        }
Esempio n. 15
0
 public static void GetDescriptionReturnsDescriptionOfDirectiveBlockStart()
 {
     var target = new BlockEnd(0);
     string description;
     Span applicableTo;
     Assert.True(target.TryGetDescription(0, out description, out applicableTo));
     Assert.Contains("control block", description, StringComparison.OrdinalIgnoreCase);
     Assert.Contains("directive", description, StringComparison.OrdinalIgnoreCase);
     Assert.Equal(target.Span, applicableTo);
 }
Esempio n. 16
0
 public static void ChildNodesReturnsNodesSpecifiedInConstructor()
 {
     var start = new DirectiveBlockStart(0);
     var name = new DirectiveName(4, "template");
     var a1 = new Attribute(new AttributeName(13, "language"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "C#"), new DoubleQuote(25));
     var a2 = new Attribute(new AttributeName(27, "debug"), new Equals(32), new DoubleQuote(33), new AttributeValue(34, "True"), new DoubleQuote(38));
     var end = new BlockEnd(27);
     var directive = new TestableDirective(start, name, new[] { a1, a2 }, end);
     Assert.True(directive.ChildNodes().SequenceEqual(new SyntaxNode[] { start, name, a1, a2, end }));
 }
Esempio n. 17
0
        public static void ChildNodesReturnsNodesSpecifiedInConstructor()
        {
            var start     = new DirectiveBlockStart(0);
            var name      = new DirectiveName(4, "template");
            var a1        = new Attribute(new AttributeName(13, "language"), new Equals(21), new DoubleQuote(22), new AttributeValue(23, "C#"), new DoubleQuote(25));
            var a2        = new Attribute(new AttributeName(27, "debug"), new Equals(32), new DoubleQuote(33), new AttributeValue(34, "True"), new DoubleQuote(38));
            var end       = new BlockEnd(27);
            var directive = new TestableDirective(start, name, new[] { a1, a2 }, end);

            Assert.True(directive.ChildNodes().SequenceEqual(new SyntaxNode[] { start, name, a1, a2, end }));
        }
Esempio n. 18
0
        public static void SpanEndsAtBlockEnd()
        {
            BlockEnd end;
            var      directive = new TestableDirective(
                new DirectiveBlockStart(10),
                new DirectiveName(14, "template"),
                new Attribute[0],
                end = new BlockEnd(23));

            Assert.Equal(end.Span.End, directive.Span.End);
        }
Esempio n. 19
0
        public static void GetDescriptionReturnsDescriptionOfDirectiveBlockStart()
        {
            var    target = new BlockEnd(0);
            string description;
            Span   applicableTo;

            Assert.True(target.TryGetDescription(0, out description, out applicableTo));
            Assert.Contains("control block", description, StringComparison.OrdinalIgnoreCase);
            Assert.Contains("directive", description, StringComparison.OrdinalIgnoreCase);
            Assert.Equal(target.Span, applicableTo);
        }
Esempio n. 20
0
        protected Directive(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
        {
            Debug.Assert(start != null, "start");
            Debug.Assert(name != null, "name");
            Debug.Assert(attributes != null, "attributes");
            Debug.Assert(end != null, "end");

            this.start = start;
            this.name = name;
            this.attributes = attributes.ToDictionary(a => a.Name, a => a, StringComparer.OrdinalIgnoreCase);
            this.end = end;
        }
Esempio n. 21
0
        protected Directive(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
        {
            Debug.Assert(start != null, "start");
            Debug.Assert(name != null, "name");
            Debug.Assert(attributes != null, "attributes");
            Debug.Assert(end != null, "end");

            this.start      = start;
            this.name       = name;
            this.attributes = attributes.ToDictionary(a => a.Name, a => a, StringComparer.OrdinalIgnoreCase);
            this.end        = end;
        }
Esempio n. 22
0
 public static Directive Create(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
 {
     switch (name.Text.ToUpperInvariant())
     {
         case "ASSEMBLY": return new AssemblyDirective(start, name, attributes, end);
         case "IMPORT": return new ImportDirective(start, name, attributes, end);
         case "INCLUDE": return new IncludeDirective(start, name, attributes, end);                
         case "OUTPUT": return new OutputDirective(start, name, attributes, end);
         case "PARAMETER": return new ParameterDirective(start, name, attributes, end);
         case "TEMPLATE": return new TemplateDirective(start, name, attributes, end);
         default: return new CustomDirective(start, name, attributes, end);
     }
 }
Esempio n. 23
0
 public CodeBlock(CodeBlockStart start, Code code, BlockEnd end) : this(start, end)
 {
     Debug.Assert(code != null, "code");
     this.code = code;
 }
Esempio n. 24
0
 public DirectiveWithKnownAttributeValues(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Esempio n. 25
0
 public DirectiveWithAttributeProperty(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Esempio n. 26
0
 public static void VisitTerminalNodeCallsVisitSyntaxNodeToAllowProcessingAllSyntaxNodesPolymorphically()
 {
     var visitor = Substitute.ForPartsOf<SyntaxNodeVisitor>();
     var terminalNode = new BlockEnd(0);
     visitor.VisitTerminalNode(terminalNode);
     Assert.Equal(1, visitor.ReceivedCalls().Count(call => call.GetMethodInfo().Name == "VisitSyntaxNode"));
     Assert.Equal(typeof(SyntaxNode), typeof(TerminalNode).BaseType);
 }
Esempio n. 27
0
 public static void SpanEndsAtBlockEnd()
 {
     BlockEnd end;
     var directive = new TestableDirective(
         new DirectiveBlockStart(10),
         new DirectiveName(14, "template"),
         new Attribute[0],
         end = new BlockEnd(23));
     Assert.Equal(end.Span.End, directive.Span.End);
 }
Esempio n. 28
0
 public DirectiveWithDescription(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Esempio n. 29
0
 public ParameterDirective(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
     Debug.Assert(name.Text.Equals("parameter", StringComparison.OrdinalIgnoreCase), "name");
 }
Esempio n. 30
0
 protected internal virtual void VisitBlockEnd(BlockEnd node)
 {
     this.VisitSyntaxToken(node);
 }
Esempio n. 31
0
        public static Directive Create(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
        {
            switch (name.Text.ToUpperInvariant())
            {
            case "ASSEMBLY": return(new AssemblyDirective(start, name, attributes, end));

            case "IMPORT": return(new ImportDirective(start, name, attributes, end));

            case "INCLUDE": return(new IncludeDirective(start, name, attributes, end));

            case "OUTPUT": return(new OutputDirective(start, name, attributes, end));

            case "PARAMETER": return(new ParameterDirective(start, name, attributes, end));

            case "TEMPLATE": return(new TemplateDirective(start, name, attributes, end));

            default: return(new CustomDirective(start, name, attributes, end));
            }
        }
Esempio n. 32
0
 public TestableDirective(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Esempio n. 33
0
 public DirectiveWithKnownAttributeValues(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Esempio n. 34
0
 public DirectiveWithDescription(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }            
Esempio n. 35
0
 public DirectiveWithAttributeProperty(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Esempio n. 36
0
 protected internal virtual void VisitBlockEnd(BlockEnd node)
 {            
     this.VisitSyntaxToken(node);
 }
Esempio n. 37
0
 public CodeBlock(CodeBlockStart start, Code code, BlockEnd end) : this(start, end)
 {
     Debug.Assert(code != null, "code");
     this.code = code;
 }
Esempio n. 38
0
 public static void SpanEndsAtBlockEnd()
 {
     BlockEnd end;
     var codeBlock = new CodeBlock(new StatementBlockStart(0), end = new BlockEnd(40));
     Assert.Equal(end.Span.End, codeBlock.Span.End);
 }
Esempio n. 39
0
 public IncludeDirective(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
     Debug.Assert(name.Text.Equals("include", StringComparison.OrdinalIgnoreCase), "name");
 }
Esempio n. 40
0
 public TemplateDirective(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }