@@ -209,19 +209,31 @@ class Parameter extends Parameter_ {
209209
210210 /** Gets the expression for the default value of this parameter */
211211 Expr getDefault ( ) {
212- exists ( Function f , int n , int c , int d , Arguments args | args = f .getDefinition ( ) .getArgs ( ) |
213- f .getArg ( n ) = this and
214- c = count ( f .getAnArg ( ) ) and
215- d = count ( args .getADefault ( ) ) and
216- result = args .getDefault ( d - c + n )
212+ exists ( Function f , int i , Arguments args | args = f .getDefinition ( ) .getArgs ( ) |
213+ // positional (normal)
214+ f .getArg ( i ) = this and
215+ result = args .getDefault ( i )
216+ )
217+ or
218+ exists ( Function f , int i , Arguments args | args = f .getDefinition ( ) .getArgs ( ) |
219+ // keyword-only
220+ f .getKeywordOnlyArg ( i ) = this and
221+ result = args .getKwDefault ( i )
217222 )
218223 }
219224
220225 /** Gets the annotation expression of this parameter */
221226 Expr getAnnotation ( ) {
222- exists ( Function f , int n , Arguments args | args = f .getDefinition ( ) .getArgs ( ) |
223- f .getArg ( n ) = this and
224- result = args .getAnnotation ( n )
227+ exists ( Function f , int i , Arguments args | args = f .getDefinition ( ) .getArgs ( ) |
228+ // positional (normal)
229+ f .getArg ( i ) = this and
230+ result = args .getAnnotation ( i )
231+ )
232+ or
233+ exists ( Function f , int i , Arguments args | args = f .getDefinition ( ) .getArgs ( ) |
234+ // keyword-only
235+ f .getKeywordOnlyArg ( i ) = this and
236+ result = args .getKwAnnotation ( i )
225237 )
226238 or
227239 exists ( Function f , Arguments args | args = f .getDefinition ( ) .getArgs ( ) |
@@ -342,4 +354,19 @@ class Arguments extends Arguments_ {
342354 result = this .getAKwAnnotation ( ) or
343355 result = this .getKwargannotation ( )
344356 }
357+
358+ // The following 4 methods are overwritten to provide better QLdoc. Since the
359+ // Arguments_ is auto-generated, we can't change the poor auto-generated docs there :(
360+
361+ /** Gets the default value for the `index`'th positional parameter. */
362+ override Expr getDefault ( int index ) { result = super .getDefault ( index ) }
363+
364+ /** Gets the default value for the `index`'th keyword-only parameter. */
365+ override Expr getKwDefault ( int index ) { result = super .getKwDefault ( index ) }
366+
367+ /** Gets the annotation for the `index`'th positional parameter. */
368+ override Expr getAnnotation ( int index ) { result = super .getAnnotation ( index ) }
369+
370+ /** Gets the annotation for the `index`'th keyword-only parameter. */
371+ override Expr getKwAnnotation ( int index ) { result = super .getKwAnnotation ( index ) }
345372}
0 commit comments