Пример #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);
        }
Пример #2
0
        /// <summary>
        /// Saves the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public virtual bool Save(LanguageElement element)
        {
            bool saved = false;

            SourceRange fullRange =
                element.GetFullBlockRange(BlockElements.AllSupportElements);

            if (fullRange != SourceRange.Empty)
            {
                string fullMethodName = GetMethodKey(element);
                string fullBlock      = Utilities.GetRangeString(element, fullRange);
                codeBlocks.Add(fullMethodName, fullBlock);

                saved = true;
            }

            return(saved);
        }
        private void ReadCodeElements(Class currentClass)
        {
            foreach (object node in currentClass.Nodes)
            {
                LanguageElement element = node as LanguageElement;
                if (element != null &&
                    IsComment(element) == false &&
                    IsAttribute(element) == false)
                {
                    RemoveParentRegionIfExists(element);

                    bool saved = SaveCodeBlock(element);

                    if (saved == true)
                    {
                        SourceRange fullRange =
                            element.GetFullBlockRange(BlockElements.AllSupportElements);
                        textDocument.QueueDelete(fullRange);
                    }
                }
            }
        }
        /// <summary>
        /// Saves the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public virtual bool Save(LanguageElement element)
        {
            bool saved = false;

            SourceRange fullRange =
                 element.GetFullBlockRange(BlockElements.AllSupportElements);

            if (fullRange != SourceRange.Empty)
            {
                string fullMethodName = GetMethodKey(element);
                string fullBlock = Utilities.GetRangeString(element, fullRange);
                codeBlocks.Add(fullMethodName, fullBlock);

                saved = true;
            }

            return saved;
        }