コード例 #1
0
 /// <summary>
 /// Gets value indicating the context is in a function header (either function, method, lambda).
 /// </summary>
 ///
 public static bool IsInFunctionDeclHeader(this ITreeContext context, out Span span) =>
 IsInDeclHeader <DummyFunctionDeclHeader>(context, out span);
コード例 #2
0
 /// <summary>
 /// Determines if the context is in given scopes.
 /// </summary>
 public static bool IsIn <T>(this ITreeContext context) where T : AstNode => Get <T>(context) != null;
コード例 #3
0
 /// <summary>
 /// Determines if the context is in given scopes.
 /// </summary>
 public static bool IsIn <T>(this ITreeContext context, Func <T, bool> predicate) where T : AstNode => Get <T>(context, predicate) != null;
コード例 #4
0
 /// <summary>
 /// Gets the first scope of type <typeparamref name="T"/> and matching given predicate.
 /// </summary>
 /// <typeparam name="T">Node type. Of type <see cref="AstNode"/>.</typeparam>
 /// <param name="context">Visitor context.</param>
 /// <param name="predicate">Additional predicate to filter scopes.</param>
 /// <returns>Node of type <typeparamref name="T"/> or <c>null</c> if the context does not have such scopes.</returns>
 public static T Get <T>(this ITreeContext context, Func <T, bool> predicate) where T : AstNode => context.Scope.OfType <T>().FirstOrDefault(predicate);
コード例 #5
0
 /// <summary>
 /// Gets the first scope of type <typeparamref name="T"/>.
 /// </summary>
 /// <typeparam name="T">Node type. Of type <see cref="AstNode"/>.</typeparam>
 /// <param name="context">Visitor context.</param>
 /// <returns>Node of type <typeparamref name="T"/> or <c>null</c> if the context does not have such node.</returns>
 public static T Get <T>(this ITreeContext context) where T : AstNode => context.Scope.OfType <T>().FirstOrDefault();
コード例 #6
0
 /// <summary>
 /// Counts scopes that causes an indentation by default.
 /// Gets raugh level of indentation at current context state (blocks, type declaration).
 /// </summary>
 public static int CountIndent(this ITreeContext context) => Count(context, s_indentnodes);
コード例 #7
0
 /// <summary>
 /// Counts scopes matching given predicate.
 /// </summary>
 public static int Count(this ITreeContext context, Func <AstNode, bool> predicate) => context.Scope.Count(predicate);
コード例 #8
0
 /// <summary>
 /// Gets value indicating the context is in a method header (either function, method, lambda).
 /// </summary>
 ///
 public static bool IsInMethodDeclHeader(this ITreeContext context, out Span span) =>
 IsInDeclHeader <DummyMethodDeclHeader>(context, out span);