Exemple #1
0
 public static void AcceptCallsVisitBlockEndMethodOfSyntaxNodeVisitor()
 {
     var visitor = Substitute.For<SyntaxNodeVisitor>();
     var node = new BlockEnd(0);
     node.Accept(visitor);
     visitor.Received().VisitBlockEnd(node);
 }
Exemple #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 }));
 }
Exemple #3
0
 public CodeBlock(CodeBlockStart start, BlockEnd end)
 {
     Debug.Assert(start != null, "start");
     Debug.Assert(end != null, "end");
     this.start = start;
     this.end = end;
 }
Exemple #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);
        }
Exemple #5
0
 public CodeBlock(CodeBlockStart start, BlockEnd end)
 {
     Debug.Assert(start != null, "start");
     Debug.Assert(end != null, "end");
     this.start = start;
     this.end   = end;
 }
Exemple #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);
 }
Exemple #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 }));
        }
Exemple #8
0
        public static void AcceptCallsVisitBlockEndMethodOfSyntaxNodeVisitor()
        {
            var visitor = Substitute.For <SyntaxNodeVisitor>();
            var node    = new BlockEnd(0);

            node.Accept(visitor);
            visitor.Received().VisitBlockEnd(node);
        }
Exemple #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);
        }
 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);
 }
Exemple #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());
 }
Exemple #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);
        }
Exemple #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());
        }
Exemple #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);
        }
Exemple #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);
 }
Exemple #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 }));
 }
Exemple #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 }));
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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;
        }
Exemple #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;
        }
Exemple #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);
     }
 }
Exemple #23
0
 public CodeBlock(CodeBlockStart start, Code code, BlockEnd end) : this(start, end)
 {
     Debug.Assert(code != null, "code");
     this.code = code;
 }
Exemple #24
0
 public DirectiveWithKnownAttributeValues(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Exemple #25
0
 public DirectiveWithAttributeProperty(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
 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);
 }
Exemple #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);
 }
Exemple #28
0
 public DirectiveWithDescription(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
 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");
 }
 protected internal virtual void VisitBlockEnd(BlockEnd node)
 {
     this.VisitSyntaxToken(node);
 }
Exemple #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));
            }
        }
Exemple #32
0
 public TestableDirective(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Exemple #33
0
 public DirectiveWithKnownAttributeValues(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Exemple #34
0
 public DirectiveWithDescription(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }            
Exemple #35
0
 public DirectiveWithAttributeProperty(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
 protected internal virtual void VisitBlockEnd(BlockEnd node)
 {            
     this.VisitSyntaxToken(node);
 }
Exemple #37
0
 public CodeBlock(CodeBlockStart start, Code code, BlockEnd end) : this(start, end)
 {
     Debug.Assert(code != null, "code");
     this.code = code;
 }
Exemple #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);
 }
 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");
 }
 public TemplateDirective(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }