@@ -160,33 +160,33 @@ public Enumeration FindEnum(IntPtr ptr)
160
160
return Enums . FirstOrDefault ( f => f . OriginalPtr == ptr ) ;
161
161
}
162
162
163
- public Function FindFunction ( string name , bool createDecl = false )
163
+ public IEnumerable < Function > FindFunction ( string name , bool createDecl = false )
164
164
{
165
165
if ( string . IsNullOrEmpty ( name ) )
166
- return null ;
166
+ return Enumerable . Empty < Function > ( ) ;
167
167
168
168
var entries = name . Split ( new string [ ] { "::" } ,
169
169
StringSplitOptions . RemoveEmptyEntries ) . ToList ( ) ;
170
170
171
171
if ( entries . Count <= 1 )
172
172
{
173
- var function = Functions . FirstOrDefault ( e => e . Name . Equals ( name ) ) ;
173
+ var functions = Functions . Where ( e => e . Name . Equals ( name ) ) ;
174
174
175
- if ( function == null && createDecl )
175
+ if ( ! functions . Any ( ) && createDecl )
176
176
{
177
- function = new Function ( ) { Name = name , Namespace = this } ;
177
+ var function = new Function ( ) { Name = name , Namespace = this } ;
178
178
Declarations . Add ( function ) ;
179
179
}
180
180
181
- return function ;
181
+ return functions ;
182
182
}
183
183
184
- var funcName = entries [ entries . Count - 1 ] ;
184
+ var funcName = entries [ ^ 1 ] ;
185
185
var namespaces = entries . Take ( entries . Count - 1 ) ;
186
186
187
187
var @namespace = FindNamespace ( namespaces ) ;
188
188
if ( @namespace == null )
189
- return null ;
189
+ return Enumerable . Empty < Function > ( ) ;
190
190
191
191
return @namespace . FindFunction ( funcName , createDecl ) ;
192
192
}
@@ -201,14 +201,12 @@ public Function FindFunctionByUSR(string usr)
201
201
202
202
Class CreateClass ( string name , bool isComplete )
203
203
{
204
- var @class = new Class
204
+ return new Class
205
205
{
206
206
Name = name ,
207
207
Namespace = this ,
208
208
IsIncomplete = ! isComplete
209
209
} ;
210
-
211
- return @class ;
212
210
}
213
211
214
212
public Class FindClass ( string name ,
@@ -316,7 +314,7 @@ public TypedefNameDecl FindTypedef(string name, bool createDecl = false)
316
314
public T FindType < T > ( string name ) where T : Declaration
317
315
{
318
316
var type = FindEnum ( name )
319
- ?? FindFunction ( name )
317
+ ?? FindFunction ( name ) . FirstOrDefault ( )
320
318
?? ( Declaration ) FindClass ( name )
321
319
?? FindTypedef ( name ) ;
322
320
0 commit comments