@@ -170,34 +170,75 @@ private module Cached {
170170
171171 cached
172172 newtype TArgumentPosition =
173- TPositionalArgumentPosition ( int pos ) { exists ( Cmd c | exists ( c .getArgument ( pos ) ) ) }
173+ TKeywordArgumentPosition ( string name ) { name = any ( CmdParameter p ) .getName ( ) } or
174+ TPositionalArgumentPosition ( int pos , NamedSet ns ) {
175+ exists ( Cmd cmd |
176+ cmd = ns .getABindingCall ( ) and
177+ exists ( cmd .getArgument ( pos ) )
178+ )
179+ }
174180
175181 cached
176- newtype TParameterPosition = TPositionalParameterPosition ( int pos ) { none ( ) /* TODO */ }
182+ newtype TParameterPosition =
183+ TKeywordParameter ( string name ) { name = any ( CmdParameter p ) .getName ( ) } or
184+ TPositionalParameter ( int pos , NamedSet ns ) {
185+ exists ( Cmd cmd |
186+ cmd = ns .getABindingCall ( ) and
187+ exists ( cmd .getArgument ( pos ) )
188+ )
189+ }
177190}
178191
179192import Cached
180193
181194/** A parameter position. */
182195class ParameterPosition extends TParameterPosition {
183- /** Holds if this position represents a positional parameter at position `pos`. */
184- predicate isPositional ( int pos ) { this = TPositionalParameterPosition ( pos ) }
196+ /**
197+ * Holds if this position represents a positional parameter at position `pos`
198+ * with function is called with exactly the named parameters from the set `ns`
199+ */
200+ predicate isPositional ( int pos , NamedSet ns ) { this = TPositionalParameter ( pos , ns ) }
201+
202+ /** Holds if this parameter is a keyword parameter with `name`. */
203+ predicate isKeyword ( string name ) { this = TKeywordParameter ( name ) }
185204
186205 /** Gets a textual representation of this position. */
187- string toString ( ) { exists ( int pos | this .isPositional ( pos ) and result = "position " + pos ) }
206+ string toString ( ) {
207+ exists ( int pos , NamedSet ns |
208+ this .isPositional ( pos , ns ) and result = "pos(" + pos + ", " + ns .toString ( ) + ")"
209+ )
210+ or
211+ exists ( string name | this .isKeyword ( name ) and result = "kw(" + name + ")" )
212+ }
188213}
189214
190215/** An argument position. */
191216class ArgumentPosition extends TArgumentPosition {
192217 /** Holds if this position represents a positional argument at position `pos`. */
193- predicate isPositional ( int pos ) { this = TPositionalArgumentPosition ( pos ) }
218+ predicate isPositional ( int pos , NamedSet ns ) { this = TPositionalArgumentPosition ( pos , ns ) }
219+
220+ predicate isKeyword ( string name ) { this = TKeywordArgumentPosition ( name ) }
194221
195222 /** Gets a textual representation of this position. */
196- string toString ( ) { exists ( int pos | this .isPositional ( pos ) and result = "position " + pos ) }
223+ string toString ( ) {
224+ exists ( int pos , NamedSet ns |
225+ this .isPositional ( pos , ns ) and result = "pos(" + pos + ", " + ns .toString ( ) + ")"
226+ )
227+ or
228+ exists ( string name | this .isKeyword ( name ) and result = "kw(" + name + ")" )
229+ }
197230}
198231
199232/** Holds if arguments at position `apos` match parameters at position `ppos`. */
200233pragma [ nomagic]
201234predicate parameterMatch ( ParameterPosition ppos , ArgumentPosition apos ) {
202- exists ( int pos | ppos .isPositional ( pos ) and apos .isPositional ( pos ) )
235+ exists ( string name |
236+ ppos .isKeyword ( name ) and
237+ apos .isKeyword ( name )
238+ )
239+ or
240+ exists ( int pos , NamedSet ns |
241+ ppos .isPositional ( pos , ns ) and
242+ apos .isPositional ( pos , ns )
243+ )
203244}
0 commit comments