コード例 #1
0
ファイル: PSharpRewriter.cs プロジェクト: jerickmsft/PSharp
 /// <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
0
        /// <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;
        }