@@ -125,7 +125,7 @@ public Java8DocScraper (string dir)
125
125
}
126
126
}
127
127
128
- public abstract class AndroidDocScraper
128
+ public abstract class AndroidDocScraper : IAndroidDocScraper
129
129
{
130
130
readonly String pattern_head ;
131
131
readonly String reset_pattern_head ;
@@ -269,6 +269,54 @@ public static void LoadXml (String filename)
269
269
} catch ( Exception ex ) {
270
270
Log . Error ( "Annotations parser error: " + ex ) ;
271
271
}
272
- }
272
+ }
273
+ }
274
+
275
+ public interface IAndroidDocScraper
276
+ {
277
+ String [ ] GetParameterNames ( string package , string type , string method , string [ ] ptypes , bool isVarArgs ) ;
278
+ }
279
+
280
+ public class ApiXmlDocScraper : IAndroidDocScraper
281
+ {
282
+ public ApiXmlDocScraper ( string apiXmlFile )
283
+ {
284
+ xdoc = XDocument . Load ( apiXmlFile ) ;
285
+ }
286
+
287
+ XDocument xdoc ;
288
+
289
+ public string [ ] GetParameterNames ( string package , string type , string method , string [ ] ptypes , bool isVarArgs )
290
+ {
291
+ var methodOrCtor = method == "constructor" ?
292
+ "constructor[" : $ "method[@name='{ method } '";
293
+
294
+ var pcount = ptypes . Length ;
295
+
296
+ var xpath = new StringBuilder ( ) ;
297
+
298
+ xpath . Append ( $ "/api/package[@name='{ package } ']/*[self::class or self::interface]/") ;
299
+
300
+ if ( method == "constructor" )
301
+ xpath . Append ( "constructor[" ) ;
302
+ else
303
+ xpath . Append ( $ "method[@name='{ method } '") ;
304
+
305
+ xpath . Append ( $ " and count(parameter)={ pcount } ") ;
306
+
307
+ if ( pcount > 0 ) {
308
+ xpath . Append ( " and " ) ;
309
+ xpath . Append ( string . Join ( " and " , ptypes . Select ( ( pt , pindex ) => $ "parameter[{ pindex + 1 } ][@type='{ pt } ']") ) ) ;
310
+ }
311
+
312
+ xpath . Append ( "]" ) ;
313
+
314
+ var methodElem = xdoc . XPathSelectElement ( xpath . ToString ( ) ) ;
315
+
316
+ if ( methodElem != null )
317
+ return methodElem . Elements ( "parameter" ) . Select ( pe => pe . Attribute ( "name" ) ? . Value ) . ToArray ( ) ;
318
+
319
+ return new string [ 0 ] ;
320
+ }
273
321
}
274
322
}
0 commit comments