Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
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 }));
 }
Ejemplo n.º 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 }));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 7
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;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 9
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);
     }
 }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 11
0
 public DirectiveWithKnownAttributeValues(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Ejemplo n.º 12
0
 public DirectiveWithAttributeProperty(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Ejemplo n.º 13
0
 public DirectiveWithAttributeProperty(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Ejemplo n.º 14
0
 public static void KindReturnsDirectiveNameSyntaxKind()
 {
     var target = new DirectiveName(0, string.Empty);
     Assert.Equal(SyntaxKind.DirectiveName, target.Kind);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 16
0
 protected internal virtual void VisitDirectiveName(DirectiveName node)
 {
     this.VisitCaptureNode(node);
 }
Ejemplo n.º 17
0
 protected internal virtual void VisitDirectiveName(DirectiveName node)
 {
     this.VisitCaptureNode(node);
 }
Ejemplo n.º 18
0
 public DirectiveWithKnownAttributeValues(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Ejemplo n.º 19
0
 public TemplateDirective(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Ejemplo n.º 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");
 }
 public static void NodeReturnsDirectiveNameWhenPositionIsWithinDirectiveName()
 {
     var node = new DirectiveName(42, string.Empty);
     var builder = new TemplateCompletionBuilder(42);
     builder.Visit(node);
     Assert.Same(node, builder.Node);
 }
Ejemplo n.º 22
0
        public static void KindReturnsDirectiveNameSyntaxKind()
        {
            var target = new DirectiveName(0, string.Empty);

            Assert.Equal(SyntaxKind.DirectiveName, target.Kind);
        }
Ejemplo n.º 23
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);
 }
Ejemplo n.º 24
0
 public DirectiveWithDescription(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Ejemplo n.º 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");
 }
Ejemplo n.º 26
0
 public TestableDirective(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }
Ejemplo n.º 27
0
 public DirectiveWithDescription(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end)
     : base(start, name, attributes, end)
 {
 }            
Ejemplo n.º 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;
            }
        }