Ejemplo n.º 1
0
 public DebuggerSyntaxTree(SoalSyntaxNode root, SourceText text)
     : base(
         text,
         text.Encoding,
         text.ChecksumAlgorithm,
         path: "",
         options: SoalParseOptions.Default,
         root: root,
         directives: DirectiveStack.Empty)
 {
 }
Ejemplo n.º 2
0
 /// <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));
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
        /// <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));
        }
Ejemplo n.º 5
0
 public override bool TryGetRoot(out SoalSyntaxNode root)
 {
     root = _root;
     return(true);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Gets the root node of the syntax tree if it is already available.
 /// </summary>
 public abstract bool TryGetRoot(out SoalSyntaxNode root);
Ejemplo n.º 7
0
 /// <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));
 }