@@ -7,9 +7,8 @@ namespace QtSharp
77{
88 public class GetCommentsFromQtDocsPass : TranslationUnitPass
99 {
10- public GetCommentsFromQtDocsPass ( string docsPath , string module , List < ASTContext > dependencies )
10+ public GetCommentsFromQtDocsPass ( string docsPath , string module )
1111 {
12- this . dependencies = dependencies ;
1312 this . documentation = new Documentation ( docsPath , module ) ;
1413 this . Options . VisitFunctionReturnType = false ;
1514 this . Options . VisitFunctionParameters = false ;
@@ -86,11 +85,10 @@ public override bool VisitFunctionDecl(Function function)
8685 var @class = function . OriginalNamespace as Class ;
8786 if ( @class != null && @class . IsInterface && @class . GenerationKind == GenerationKind . Link )
8887 {
89- function . Comment = ( from dependency in this . dependencies
90- from found in dependency . FindClass ( @class . Name )
91- from method in found . Methods
92- where method . USR == function . USR
93- select method . Comment ) . FirstOrDefault ( ) ;
88+ if ( functionsComments . ContainsKey ( function . Mangled ) )
89+ {
90+ function . Comment = new RawComment { BriefText = functionsComments [ function . Mangled ] } ;
91+ }
9492 }
9593 else
9694 {
@@ -115,17 +113,36 @@ public override bool VisitProperty(Property property)
115113 where @class != null && @class . IsInterface && @class . GenerationKind == GenerationKind . Link
116114 select @class )
117115 {
118- property . Comment = ( from dependency in this . dependencies
119- from found in dependency . FindClass ( @class . Name )
120- from prop in found . Properties
121- where prop . OriginalName == property . OriginalName
122- select prop . Comment ) . FirstOrDefault ( ) ;
116+ RawComment comment = null ;
117+ if ( property . GetMethod != null && functionsComments . ContainsKey ( property . GetMethod . Mangled ) )
118+ {
119+ comment = new RawComment { BriefText = functionsComments [ property . GetMethod . Mangled ] } ;
120+ }
121+ if ( comment == null && property . SetMethod != null && functionsComments . ContainsKey ( property . SetMethod . Mangled ) )
122+ {
123+ comment = new RawComment { BriefText = functionsComments [ property . SetMethod . Mangled ] } ;
124+ }
125+ property . Comment = comment ;
123126 if ( property . Comment != null )
124127 {
125128 return true ;
126129 }
127130 }
128131 this . documentation . DocumentProperty ( property ) ;
132+ if ( property . Comment != null )
133+ {
134+ if ( property . GetMethod != null )
135+ {
136+ functionsComments [ property . GetMethod . Mangled ] = property . Comment . BriefText ;
137+ }
138+ else
139+ {
140+ if ( property . SetMethod != null )
141+ {
142+ functionsComments [ property . SetMethod . Mangled ] = property . Comment . BriefText ;
143+ }
144+ }
145+ }
129146 return true ;
130147 }
131148 return false ;
@@ -177,10 +194,15 @@ private void DocumentFunction(Function function)
177194 {
178195 this . documentation . DocumentFunction ( function ) ;
179196 }
197+ if ( function . Comment != null )
198+ {
199+ functionsComments [ function . Mangled ] = function . Comment . BriefText ;
200+ }
180201 }
181202 }
182203
204+ private static readonly Dictionary < string , string > functionsComments = new Dictionary < string , string > ( ) ;
205+
183206 private readonly Documentation documentation ;
184- private readonly List < ASTContext > dependencies ;
185207 }
186208}
0 commit comments