public static void AcceptCallsVisitDirectiveNameMethodOfSyntaxNodeVisitor() { var visitor = Substitute.For<SyntaxNodeVisitor>(); var node = new DirectiveName(0, string.Empty); node.Accept(visitor); visitor.Received().VisitDirectiveName(node); }
public static void AcceptCallsVisitDirectiveNameMethodOfSyntaxNodeVisitor() { var visitor = Substitute.For <SyntaxNodeVisitor>(); var node = new DirectiveName(0, string.Empty); node.Accept(visitor); visitor.Received().VisitDirectiveName(node); }
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); }
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 })); }
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); }
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; }
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; }
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); } }
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)); } }
public DirectiveWithKnownAttributeValues(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end) : base(start, name, attributes, end) { }
public DirectiveWithAttributeProperty(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end) : base(start, name, attributes, end) { }
public DirectiveWithAttributeProperty(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end) : base(start, name, attributes, end) { }
public static void KindReturnsDirectiveNameSyntaxKind() { var target = new DirectiveName(0, string.Empty); Assert.Equal(SyntaxKind.DirectiveName, target.Kind); }
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); }
protected internal virtual void VisitDirectiveName(DirectiveName node) { this.VisitCaptureNode(node); }
public DirectiveWithKnownAttributeValues(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end) : base(start, name, attributes, end) { }
public TemplateDirective(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"); }
public static void NodeReturnsDirectiveNameWhenPositionIsWithinDirectiveName() { var node = new DirectiveName(42, string.Empty); var builder = new TemplateCompletionBuilder(42); builder.Visit(node); Assert.Same(node, builder.Node); }
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); }
public DirectiveWithDescription(DirectiveBlockStart start, DirectiveName name, IEnumerable <Attribute> attributes, BlockEnd end) : base(start, name, attributes, 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 TestableDirective(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end) : base(start, name, attributes, end) { }
public DirectiveWithDescription(DirectiveBlockStart start, DirectiveName name, IEnumerable<Attribute> attributes, BlockEnd end) : base(start, name, attributes, end) { }
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; } }