本文整理汇总了C#中Microsoft.CodeAnalysis.SyntaxTree.WithChangedText方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTree.WithChangedText方法的具体用法?C# SyntaxTree.WithChangedText怎么用?C# SyntaxTree.WithChangedText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.SyntaxTree
的用法示例。
在下文中一共展示了SyntaxTree.WithChangedText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateSyntaxTree
/// <summary>
/// Updates the syntax tree.
/// </summary>
/// <param name="tree">SyntaxTree</param>
/// <param name="text">Text</param>
/// <returns>SyntaxTree</returns>
protected SyntaxTree UpdateSyntaxTree(SyntaxTree tree, string text)
{
var source = SourceText.From(text);
return tree.WithChangedText(source);
}
示例2: ReplaceSyntaxTree
/// <summary>
/// Replaces the syntax tree with the specified text in the project.
/// </summary>
/// <param name="tree">SyntaxTree</param>
/// <param name="text">Text</param>
/// <param name="project">Project</param>
/// <returns>SyntaxTree</returns>
public SyntaxTree ReplaceSyntaxTree(SyntaxTree tree, string text, Project project)
{
if (!this.HasInitialized)
{
throw new PSharpException("ProgramInfo has not been initialized.");
}
var doc = project.Documents.First(val => val.FilePath.Equals(tree.FilePath));
var source = SourceText.From(text);
tree = tree.WithChangedText(source);
doc = doc.WithSyntaxRoot(tree.GetRoot());
project = doc.Project;
this.Solution = project.Solution;
return doc.GetSyntaxTreeAsync().Result;
}