コード例 #1
0
 public static void AcceptCallsVisitDirectiveNameMethodOfSyntaxNodeVisitor()
 {
     var visitor = Substitute.For<SyntaxNodeVisitor>();
     var node = new DirectiveName(0, string.Empty);
     node.Accept(visitor);
     visitor.Received().VisitDirectiveName(node);
 }
コード例 #2
0
        public static void AcceptCallsVisitDirectiveNameMethodOfSyntaxNodeVisitor()
        {
            var visitor = Substitute.For <SyntaxNodeVisitor>();
            var node    = new DirectiveName(0, string.Empty);

            node.Accept(visitor);
            visitor.Received().VisitDirectiveName(node);
        }
コード例 #3
0
        public static void VisitDirectiveNameCallsVisitCaptureNodeToAllowProcessingAllCaptureNodesPolymorphically()
        {
            var visitor       = Substitute.ForPartsOf <SyntaxNodeVisitor>();
            var directiveName = new DirectiveName(0, "directive");

            visitor.VisitDirectiveName(directiveName);
            visitor.Received().VisitCaptureNode(directiveName);
            Assert.Equal(typeof(CaptureNode), typeof(DirectiveName).BaseType);
        }
コード例 #4
0
ファイル: DirectiveTest.cs プロジェクト: icool123/T4Toolbox
 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 }));
 }
コード例 #5
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 }));
        }
コード例 #6
0
        public static void GetDescriptionReturnsDescriptionOfDirectiveAndSpanOfDirectiveNameGivenPositionWithinDirectiveName()
        {
            var directiveName = new DirectiveName(4, "directive");
            var directive     = new DirectiveWithDescription(new DirectiveBlockStart(0), directiveName, new Attribute[0], new BlockEnd(14));
            DescriptionAttribute descriptionAttribute = directive.GetType().GetCustomAttributes(false).OfType <DescriptionAttribute>().Single();
            string description;
            Span   applicableTo;

            Assert.True(directive.TryGetDescription(4, out description, out applicableTo));
            Assert.Equal(descriptionAttribute.Description, description);
            Assert.Equal(directiveName.Span, applicableTo);
        }
コード例 #7
0
ファイル: Directive.cs プロジェクト: icool123/T4Toolbox
        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;
        }
コード例 #8
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;
        }
コード例 #9
0
ファイル: Directive.cs プロジェクト: icool123/T4Toolbox
 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);
     }
 }
コード例 #10
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));
            }
        }
コード例 #11
0
ファイル: DirectiveTest.cs プロジェクト: icool123/T4Toolbox
 public DirectiveWithKnownAttributeValues(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
コード例 #12
0
ファイル: DirectiveTest.cs プロジェクト: icool123/T4Toolbox
 public DirectiveWithAttributeProperty(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
コード例 #13
0
 public DirectiveWithAttributeProperty(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
コード例 #14
0
 public static void KindReturnsDirectiveNameSyntaxKind()
 {
     var target = new DirectiveName(0, string.Empty);
     Assert.Equal(SyntaxKind.DirectiveName, target.Kind);
 }
コード例 #15
0
 public static void VisitDirectiveNameCallsVisitCaptureNodeToAllowProcessingAllCaptureNodesPolymorphically()
 {
     var visitor = Substitute.ForPartsOf<SyntaxNodeVisitor>();
     var directiveName = new DirectiveName(0, "directive");
     visitor.VisitDirectiveName(directiveName);
     visitor.Received().VisitCaptureNode(directiveName);
     Assert.Equal(typeof(CaptureNode), typeof(DirectiveName).BaseType);
 }
コード例 #16
0
 protected internal virtual void VisitDirectiveName(DirectiveName node)
 {
     this.VisitCaptureNode(node);
 }
コード例 #17
0
 protected internal virtual void VisitDirectiveName(DirectiveName node)
 {
     this.VisitCaptureNode(node);
 }
コード例 #18
0
 public DirectiveWithKnownAttributeValues(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
コード例 #19
0
 public TemplateDirective(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
コード例 #20
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");
 }
コード例 #21
0
 public static void NodeReturnsDirectiveNameWhenPositionIsWithinDirectiveName()
 {
     var node = new DirectiveName(42, string.Empty);
     var builder = new TemplateCompletionBuilder(42);
     builder.Visit(node);
     Assert.Same(node, builder.Node);
 }
コード例 #22
0
        public static void KindReturnsDirectiveNameSyntaxKind()
        {
            var target = new DirectiveName(0, string.Empty);

            Assert.Equal(SyntaxKind.DirectiveName, target.Kind);
        }
コード例 #23
0
ファイル: DirectiveTest.cs プロジェクト: icool123/T4Toolbox
 public static void GetDescriptionReturnsDescriptionOfDirectiveAndSpanOfDirectiveNameGivenPositionWithinDirectiveName()
 {
     var directiveName = new DirectiveName(4, "directive");
     var directive = new DirectiveWithDescription(new DirectiveBlockStart(0), directiveName, new Attribute[0], new BlockEnd(14));
     DescriptionAttribute descriptionAttribute = directive.GetType().GetCustomAttributes(false).OfType<DescriptionAttribute>().Single();
     string description;
     Span applicableTo;
     Assert.True(directive.TryGetDescription(4, out description, out applicableTo));
     Assert.Equal(descriptionAttribute.Description, description);
     Assert.Equal(directiveName.Span, applicableTo);
 }
コード例 #24
0
 public DirectiveWithDescription(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
コード例 #25
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");
 }
コード例 #26
0
ファイル: DirectiveTest.cs プロジェクト: icool123/T4Toolbox
 public TestableDirective(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
コード例 #27
0
ファイル: DirectiveTest.cs プロジェクト: icool123/T4Toolbox
 public DirectiveWithDescription(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }            
コード例 #28
0
        protected internal override void VisitDirectiveName(DirectiveName node)
        {
            base.VisitDirectiveName(node);

            if (node.Span.Start <= this.position && this.position <= node.Span.End)
            {
                this.Completions = DirectiveDescriptor.GetBuiltInDirectives()
                    .Where(descriptor => !string.IsNullOrEmpty(descriptor.DisplayName)) // Skip custom directives
                    .Select(CreateDirectiveCompletion)
                    .ToList();
                this.Node = node;
            }
        }