public DebuggerSyntaxTree(SoalSyntaxNode root, SourceText text) : base( text, text.Encoding, text.ChecksumAlgorithm, path: "", options: SoalParseOptions.Default, root: root, directives: DirectiveStack.Empty) { }
/// <summary> /// <para> /// Internal helper for <see cref="SoalSyntaxNode"/> class to create a new syntax tree rooted at the given root node. /// This method does not create a clone of the given root, but instead preserves it's reference identity. /// </para> /// <para>NOTE: This method is only intended to be used from <see cref="SoalSyntaxNode.SyntaxTree"/> property.</para> /// <para>NOTE: Do not use this method elsewhere, instead use <see cref="Create(SoalSyntaxNode, SoalParseOptions, string, Encoding)"/> method for creating a syntax tree.</para> /// </summary> internal static SoalSyntaxTree CreateWithoutClone(SoalSyntaxNode root) { Debug.Assert(root != null); return(new ParsedSyntaxTree( textOpt: null, encodingOpt: null, checksumAlgorithm: SourceHashAlgorithm.Sha1, path: "", options: SoalParseOptions.Default, root: root, directives: DirectiveStack.Empty, cloneRoot: false)); }
internal ParsedSyntaxTree(SourceText textOpt, Encoding encodingOpt, SourceHashAlgorithm checksumAlgorithm, string path, SoalParseOptions options, SoalSyntaxNode root, DirectiveStack directives, bool cloneRoot = true) { Debug.Assert(root != null); Debug.Assert(options != null); Debug.Assert(path != null); Debug.Assert(textOpt == null || textOpt.Encoding == encodingOpt && textOpt.ChecksumAlgorithm == checksumAlgorithm); _lazyText = textOpt; _encodingOpt = encodingOpt ?? textOpt?.Encoding; _checksumAlgorithm = checksumAlgorithm; _options = options; _path = path; _root = cloneRoot ? new MainSyntax((InternalSyntaxNode)root.Green, this, 0) : root; _hasCompilationUnitRoot = root.Kind == SoalSyntaxKind.Main; this.SetDirectiveStack(directives); }
/// <summary> /// Creates a new syntax tree from a syntax node. /// </summary> public static SoalSyntaxTree Create(SoalSyntaxNode root, SoalParseOptions options = null, string path = "", Encoding encoding = null) { if (root == null) { throw new ArgumentNullException(nameof(root)); } var directives = DirectiveStack.Empty; return(new ParsedSyntaxTree( textOpt: null, encodingOpt: encoding, checksumAlgorithm: SourceHashAlgorithm.Sha1, path: path, options: options ?? SoalParseOptions.Default, root: root, directives: directives)); }
public override bool TryGetRoot(out SoalSyntaxNode root) { root = _root; return(true); }
/// <summary> /// Gets the root node of the syntax tree if it is already available. /// </summary> public abstract bool TryGetRoot(out SoalSyntaxNode root);
/// <summary> /// Creates a new syntax tree from a syntax node with text that should correspond to the syntax node. /// </summary> /// <remarks>This is used by the ExpressionEvaluator.</remarks> internal static SoalSyntaxTree CreateForDebugger(SoalSyntaxNode root, SourceText text) { Debug.Assert(root != null); return(new DebuggerSyntaxTree(root, text)); }