我在现有_df = df.pivot_table(index=['group','sample','total'],columns=['base'],values='count').fillna(0)
中添加语句时遇到问题。
Basicaly我只想在访问SyntaxList<StatementSyntax>
时添加一条声明,这是我当前对MultiLineIfBlock
的实现:
VisualBasicSyntaxRewriter
输出:
public override SyntaxNode VisitMultiLineIfBlock(MultiLineIfBlockSyntax node)
{
var result = (MultiLineIfBlockSyntax)base.VisitMultiLineIfBlock(node);
var statements = result.Statements.Insert(0, this._newStatement);
return result.WithStatements(statements);
}
就像你可以看到结果不是有效的树...... 任何帮助将不胜感激!
更新
我添加了EndOfLine TrailingTrivia,这是输出:
BEFORE
If (True) Then
Console.Write("FirstLine")
Console.Write("SecondLine")
Console.Write("ThirdLine")
End If
-------------------------------------------------------------------------------------------
AFTER
If (True) Then
Console.Write("AddedStatement") Console.Write("FirstLine")
Console.Write("SecondLine")
Console.Write("ThirdLine")
End If
缩进是怎么回事?我必须做错事......