/// <summary>
        /// Basic cleverness for cutting down the verbosity of expected token baselines
        /// (i.e. don't output a parameter if the default is correct).
        /// </summary>
        private static string ToExpectedTokenString(InternalSyntax.SyntaxToken token)
        {
            var canonicalText = SyntaxFacts.GetText(token.Kind);

            var builder = new StringBuilder();
            
            builder.AppendFormat("Token(SyntaxKind.{0}", token.Kind);

            if (token.Text != canonicalText)
            {
                builder.AppendFormat(", \"{0}\"", token.Text);

                if (token.ValueText != token.Text)
                {
                    builder.AppendFormat(", \"{0}\"", token.ValueText);

                    if (token.ContextualKind != token.Kind)
                    {
                        builder.AppendFormat(", SyntaxKind.{0}", token.ContextualKind);
                    }
                }
            }

            builder.Append(")");

            return builder.ToString();
        }
Exemplo n.º 2
0
        private static void AttachAndCheckDiagnostics(InternalSyntax.CSharpSyntaxNode node)
        {
            var nodeWithDiags = node.SetDiagnostics(new DiagnosticInfo[] { new CSDiagnosticInfo(ErrorCode.ERR_AbstractAndExtern) });
            var diags = nodeWithDiags.GetDiagnostics();

            Assert.NotEqual(node, nodeWithDiags);
            Assert.Equal(1, diags.Length);
            Assert.Equal(ErrorCode.ERR_AbstractAndExtern, (ErrorCode)diags[0].Code);
        }
Exemplo n.º 3
0
 public override InternalSyntax.CSharpSyntaxNode VisitToken(InternalSyntax.SyntaxToken token)
 {
     var visited = (InternalSyntax.SyntaxToken)base.VisitToken(token);
     return _rewriteToken == null ? visited : _rewriteToken(visited);
 }
Exemplo n.º 4
0
 public override InternalSyntax.CSharpSyntaxNode Visit(InternalSyntax.CSharpSyntaxNode node)
 {
     var visited = base.Visit(node);
     return _rewriteNode == null ? visited : _rewriteNode(visited);
 }
Exemplo n.º 5
0
 protected override InternalSyntax.CSharpSyntaxNode DefaultVisit(InternalSyntax.CSharpSyntaxNode node)
 {
     return node;
 }
Exemplo n.º 6
0
 public override InternalSyntax.CSharpSyntaxNode VisitToken(InternalSyntax.SyntaxToken token)
 {
     return InternalSyntax.SyntaxFactory.MissingToken(token.Kind);
 }