GhostDoc 源码分析。


核心代码在  

Weigelt.GhostDoc.Addin

Weigelt.DhostDoc.Configufation

入口点在:

 command = this.m_dteApplication.Commands.Item("Weigelt.GhostDoc.AddIn.DocumentThis", -1);

绑定了快捷点。绑定位置在:AssignHotkeyDialog。CreateKeyboardBindings

这个command的激活位置在: 

AddIn.cs: 

 this.m_objDocumentThisCommandImplementation.Execute(this.m_dteApplication);

private DocumentThisCommandImplementation m_objDocumentThisCommandImplementation; 

所以整个关键在:DocumentThisCommandImplementation

获取当前代码片段:

CodeElement: element = selection.ActivePoint.get_CodeElement(vsCMElement.vsCMElementFunction);

this.DocumentFunction(selection, (CodeFunction) element, unknown);

codeFunction.DocComment = DocCommentBuilder.GetDocComment(rule, args); 

备注的关键在:

DocCommentBuilder

我C 你 nn 个X。终于找到了词法分析的地方了。

1. 在 DocumentThisCommandImplementation。DocumentFunction

解析得到:  Label_0085: 得到

                MethodRuleArgs args2 = new MethodRuleArgs(this.m_objConfiguration, typeName, MemberModifiers.None, this.GetFullTypeName(codeFunction.Type), codeFunction.Name, argsArray, existingDocumentationXml, processedDocComment, codeLanguage);

关键就是这个args。里面构造函数: 

            this.m_objReturnTypeName = new TypeName(returnTypeName);

            this.m_objMethodName = new Weigelt.GhostDoc.MethodName(configuration, methodName);

            this.m_lstParameters = new ParameterRuleArgsList(configuration, parameters);

 名字解析在:MethodName

 this.m_objWords = new MethodNameWords(base.Configuration, base.ActualName);

又继承了Word.

到此。分析完成。 

原文地址:https://www.cnblogs.com/zc22/p/1716763.html