コード例 #1
0
        /// <summary>
        /// Selects the current member.
        /// </summary>
        /// <param name="caret">The caret.</param>
        /// <param name="textDocument">The text document.</param>
        /// <returns></returns>
        public static bool SelectCurrentMember(CaretServices caret, TextDocument textDocument)
        {
            bool result = false;

            if (caret == null || textDocument == null)
            {
                return(result);
            }

            if (caret.InsideCode == true)
            {
                SourcePoint     sourcePoint = caret.SourcePoint;
                LanguageElement element     = textDocument.GetNodeAt(sourcePoint);

                if (element.CanBeDocumented == false ||
                    element.ElementType == LanguageElementType.EnumElement)
                {
                    element = element.GetParentElementThatCanBeDocumented();
                }

                SourceRange range = element.GetFullBlockRange(BlockElements.AllSupportElements);
                CodeRush.Selection.SelectRange(range);

                result = true;
            }

            return(result);
        }