示例#1
0
        /// <summary>
        /// Gets if this syntax is a terminal symbol, i.e. if it has no child nodes and its <see cref="Length"/> is greater than zero.
        /// </summary>
        /// <param name="terminalSymbol">
        /// The terminal symbol if this syntax is a terminal symbol, otherwise a default value.
        /// </param>
        /// <returns>
        /// Whether or not this syntax is a terminal symbol, i.e. if it has no child nodes and its <see cref="Length"/> is greater than zero.
        /// </returns>
        public bool IsTerminalSymbol(out IJsonSymbol terminalSymbol)
        {
            if (ChildCount == 0 && Length > 0)
            {
                // Contract is that all subclasses with ChildCount == 0 and Length > 0 must implement IJsonSymbol.
                Debug.Assert(this is IJsonSymbol);
                terminalSymbol = (IJsonSymbol)this;
                return(true);
            }

            terminalSymbol = default;
            return(false);
        }
示例#2
0
 public virtual TResult Visit(IJsonSymbol node, T arg) => node == null ? default : node.Accept(this, arg);
示例#3
0
 public virtual TResult DefaultVisit(IJsonSymbol node, T arg) => default;
示例#4
0
 /// <summary>
 /// Converts this <see cref="IJsonSymbol"/> to a <see cref="JsonSyntax"/> node.
 /// </summary>
 /// <param name="symbol">
 /// The <see cref="IJsonSymbol"/> to convert.
 /// </param>
 /// <returns>
 /// The converted <see cref="JsonSyntax"/> node.
 /// </returns>
 public static JsonSyntax ToSyntax(this IJsonSymbol symbol) => ToJsonSyntaxConverter.Instance.Visit(symbol);
 public override Style DefaultVisit(IJsonSymbol node, SyntaxEditor <TSyntaxTree, IJsonSymbol, JsonErrorInfo> syntaxEditor)
 => syntaxEditor.DefaultStyle;