/// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ITreeNode element = Utils.GetElementAtCaret(solution, textControl);

            ITreeNode currentNode = element;

            IDocCommentNode docCommentNode = currentNode as IDocCommentNode;

            IDocCommentBlockNode containingElement = docCommentNode.GetContainingNode <IDocCommentBlockNode>(true);

            ITreeNode rightNode = containingElement.FindFormattingRangeToRight();

            Utils.RemoveNewLineBefore(rightNode);
        }
        public static void ReflowAndRetagCommentBlockNode(ISolution solution, IProgressIndicator progress, IDocCommentBlockNode docCommentBlockNode)
        {
            if (docCommentBlockNode == null)
            {
                return;
            }

            // Get the settings.
            IContextBoundSettingsStore settingsStore = Shell.Instance.GetComponent <ISettingsStore>().BindToContextTransient(ContextRange.ApplicationWide);
            XmlDocumentationSettings   settings      =
                settingsStore.GetKey <XmlDocumentationSettings>(SettingsOptimization.OptimizeDefault);
            ReflowAndRetagSettings reflowSettings =
                settingsStore.GetKey <ReflowAndRetagSettings>(SettingsOptimization.OptimizeDefault);
            int maxLength = settings.MaxCharactersPerLine;

            // Get the comment block owner (ie the part of the declaration which will own the comment).
            IDocCommentBlockOwnerNode ownerNode =
                docCommentBlockNode.GetContainingNode <IDocCommentBlockOwnerNode>();

            // If we didn't get an owner then give up
            if (ownerNode == null)
            {
                return;
            }

            // Get a factory which can create elements in the C# docs
            //CSharpElementFactory factory = CSharpElementFactory.GetInstance(ownerNode.GetPsiModule());

            // Calculate line offset where /// starts and add 4 for the slashes and space
            int startPos = CalcLineOffset(ownerNode) + 4;

            // Create a new comment block with the adjusted text
            IDocCommentBlockNode comment = docCommentBlockNode; //factory.CreateDocCommentBlock(text);

            string reflownText = new XmlCommentReflower(settings, reflowSettings).ReflowAndRetag(comment, maxLength - startPos);

            // If the xml was malformed then the comment will now be empty - detect this and do nothing
            if (string.IsNullOrEmpty(reflownText))
            {
                return;
            }

            /*comment = factory.CreateDocCommentBlock(reflownText);
             *
             * // And set the comment on the declaration.
             * ownerNode.SetDocCommentBlockNode(comment);*/

            SetDocComment(ownerNode, reflownText, solution);
        }
        public static void ReflowAndRetagCommentNode(ISolution solution, IProgressIndicator progress, IDocCommentNode docCommentNode)
        {
            if (docCommentNode == null)
            {
                return;
            }

            IDocCommentBlockNode blockNode =
                docCommentNode.GetContainingNode <IDocCommentBlockNode>();

            if (blockNode == null)
            {
                return;
            }

            ReflowAndRetagCommentBlockNode(solution, progress, blockNode);
        }
Exemple #4
0
        public static void ReFlowCommentBlockNode(ISolution solution, IProgressIndicator progress, IDocCommentBlockNode docCommentBlockNode)
        {
            if (docCommentBlockNode == null)
            {
                return;
            }

            // Get the settings.
            IContextBoundSettingsStore settingsStore = Shell.Instance.GetComponent <ISettingsStore>().BindToContextTransient(ContextRange.ApplicationWide);
            XmlDocumentationSettings   settings      =
                settingsStore.GetKey <XmlDocumentationSettings>(SettingsOptimization.OptimizeDefault);
            ReflowAndRetagSettings reflowSettings =
                settingsStore.GetKey <ReflowAndRetagSettings>(SettingsOptimization.OptimizeDefault);
            int maxLength = settings.MaxCharactersPerLine;

            IDocCommentBlockOwnerNode ownerNode =
                docCommentBlockNode.GetContainingNode <IDocCommentBlockOwnerNode>();

            // If we didn't get an owner then give up
            if (ownerNode == null)
            {
                return;
            }

            // Get a factory which can create elements in the C# docs
            //CSharpElementFactory factory = CSharpElementFactory.GetInstance(ownerNode.GetPsiModule());

            // Calculate line offset where /// starts and add 3 for each
            // slash.
            int startPos = CalcLineOffset(ownerNode) + 3;

            // Create a new comment block with the adjusted text
            IDocCommentBlockNode comment = docCommentBlockNode; //factory.CreateDocCommentBlock(text);

            // Work out if we have a space between the /// and <summary>
            string reflownText = new XmlCommentReflower(settings, reflowSettings).Reflow(comment, maxLength - startPos);

            //comment = factory.CreateDocCommentBlock(reflownText);

            SetDocComment(ownerNode, reflownText, solution);

            // And set the comment on the declaration.
            //ownerNode.SetDocCommentBlockNode(comment);
        }
        public void CheckCommentSpelling(
            IClassMemberDeclaration decl,
            IDocCommentBlockNode docNode,
            IHighlightingConsumer highlightingConsumer,
            bool spellCheck)
        {
            if (docNode == null)
            {
                return;
            }

            IFile file = decl.GetContainingFile();

            if (file == null)
            {
                return;
            }

            foreach (Range wordRange in this.GetWordsFromXmlComment(docNode))
            {
                DocumentRange range = file.GetDocumentRange(wordRange.TreeTextRange);
                string        word  = wordRange.Word;

                if (decl.DeclaredName != word)
                {
                    if ((IdentifierResolver.IsIdentifier(decl, _solution, word, _identifierSettings.IdentifierLookupScope) ||
                         IdentifierResolver.IsKeyword(decl, _solution, word)) &&
                        IdentifierResolver.AnalyzeForMetaTagging(word, _xmlDocumentationSettings.CompiledWordsToIgnoreForMetatagging))
                    {
                        var highlighting = new CanBeSurroundedWithMetatagsHighlight(word,
                                                                                    range, decl, _solution);

                        highlightingConsumer.AddHighlighting(highlighting, range, file);
                    }
                    else if (spellCheck)
                    {
                        this.CheckWordSpelling(decl, wordRange, highlightingConsumer, range, file);
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Updates the elements header with the current xml.
        /// </summary>
        public void Update()
        {
            if (this.DocCommentBlockNode != null)
            {
                IFile file = this.Declaration.GetContainingFile();

                using (this.DocCommentBlockNode.CreateWriteLock())
                {
                    string header = LayoutDocumentationHeader(this.XmlNode, this.Declaration);
                    IDocCommentBlockNode newDocCommentNode = Utils.CreateDocCommentBlockNode(file, header);

                    if (newDocCommentNode == null)
                    {
                        ModificationUtil.DeleteChild(this.DocCommentBlockNode);
                    }
                    else
                    {
                        ModificationUtil.ReplaceChild(this.DocCommentBlockNode, newDocCommentNode);
                    }
                }
            }
        }
Exemple #7
0
 public void Process(IDocCommentBlockNode docCommentBlockNode)
Exemple #8
0
 public void SetDocCommentBlockNode(IDocCommentBlockNode node)
 {
     _classDeclaration.SetDocCommentBlockNode(node);
 }
Exemple #9
0
 public XmlCommentReflowableBlockLexer(IDocCommentBlockNode docCommentBlock)
 {
     _docLexer = new XmlDocLexer(docCommentBlock);
     _docLexer.Start();
 }
Exemple #10
0
 public XmlDocLexer(IDocCommentBlockNode docCommentBlock)
 {
     _myDocCommentBlock = docCommentBlock;
     Start();
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="blockNode"></param>
 /// <param name="maxLineLength"></param>
 /// <returns></returns>
 public string Reflow(IDocCommentBlockNode blockNode, int maxLineLength)
 {
     return(ReflowToLineLength(Parse(blockNode), maxLineLength));
 }
Exemple #12
0
 public void SetDocCommentBlockNode(IDocCommentBlockNode node)
 {
     _classDeclaration.SetDocCommentBlockNode(node);
 }
 public DocCommentBlockModel(IAnalyzeUnit analyzeUnit, IDocCommentBlockNode docCommentNode)