Пример #1
0
        /// <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));
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
 /// <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
     );
Пример #4
0
        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));
        }
Пример #5
0
        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);
        }
Пример #6
0
 /// <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);