/// <summary> /// A position is inside a body if it is inside the block or expression /// body. /// /// A position is considered to be inside a block if it is on or after /// the open brace and strictly before the close brace. A position is /// considered to be inside an expression body if it is on or after /// the '=>' and strictly before the semicolon. /// </summary> internal static bool IsInBody(int position, BaseMethodDeclarationSyntax method) { var exprOpt = method.GetExpressionBodySyntax(); return(IsInExpressionBody(position, exprOpt, method.SemicolonToken) || IsInBlock(position, method.Body)); }
/// <summary> /// A position is inside a body if it is inside the block or expression /// body. /// /// A position is considered to be inside a block if it is on or after /// the open brace and strictly before the close brace. A position is /// considered to be inside an expression body if it is on or after /// the '=>' and strictly before the semicolon. /// </summary> internal static bool IsInBody(int position, BaseMethodDeclarationSyntax method) { var exprOpt = method.GetExpressionBodySyntax(); return IsInExpressionBody(position, exprOpt, method.SemicolonToken) || IsInBlock(position, method.Body); }
/// <summary> /// A position is inside a body if it is inside the block or expression /// body. /// /// A position is considered to be inside a block if it is on or after /// the open brace and strictly before the close brace. A position is /// considered to be inside an expression body if it is on or after /// the '=>' and strictly before the semicolon. /// </summary> internal static bool IsInBody(int position, BaseMethodDeclarationSyntax method) => IsInBody( position, method.Body, method.GetExpressionBodySyntax(), method.SemicolonToken );
internal static bool IsInMethodDeclaration(int position, BaseMethodDeclarationSyntax methodDecl) { Debug.Assert(methodDecl != null); var body = methodDecl.Body; if (body == null) { return(IsBeforeToken(position, methodDecl, methodDecl.SemicolonToken)); } return(IsBeforeToken(position, methodDecl, body.CloseBraceToken) || IsInExpressionBody(position, methodDecl.GetExpressionBodySyntax(), methodDecl.SemicolonToken)); }
internal static bool IsInMethodDeclaration(int position, BaseMethodDeclarationSyntax methodDecl) { Debug.Assert(methodDecl != null); var body = methodDecl.Body; if (body == null) { return IsBeforeToken(position, methodDecl, methodDecl.SemicolonToken); } return IsBeforeToken(position, methodDecl, body.CloseBraceToken) || IsInExpressionBody(position, methodDecl.GetExpressionBodySyntax(), methodDecl.SemicolonToken); }
/// <summary> /// A position is inside a body if it is inside the block or expression /// body. /// /// A position is considered to be inside a block if it is on or after /// the open brace and strictly before the close brace. A position is /// considered to be inside an expression body if it is on or after /// the '=>' and strictly before the semicolon. /// </summary> internal static bool IsInBody(int position, BaseMethodDeclarationSyntax method) => IsInBody(position, method.Body, method.GetExpressionBodySyntax(), method.SemicolonToken);