Skip to main content

Module condition

Module condition 

Source
Expand description

The condition language of findrefs rules and callgraph endpoints.

rule  := part ( '&' part )*
part  := [ '!' ] KIND ':' value
value := ['=' | '*'] '{' rule '}' calls  method only: calls of the methods whose code matches the rule
       | ['=' | '*'] '@' PATH calls    method only: calls of the methods listed in a file
       | TEXT calls        method: a method target, e.g. Lc;->m(I)V
       | TEXT              the other KINDs' own syntax, e.g. a regex
calls := ( '[' constraint ( ',' constraint )* ']' )*
constraint := ( 'arg' N | 'this' ) ( '=' | '==' ) arg
            | 'ret' ( '=' | '==' ) ( 'used' | 'unused' )
arg   := '*' | INT | 'true' | 'false' | 'null' | '"' TEXT '"' | '~' REGEX
       | 'param' [ K ] | 'class:' TYPE | 'new:' TYPE | 'ret:' METHOD | 'field:' FIELD

A rule of one positive part is that condition; several parts make a compound (Query::All) whose ! parts are its none list. TEXT runs to the next & outside {} / (), or to the } closing the enclosing body; \ keeps the next character from ending it (string:a\&b is the regex a\&b).

A {rule} or @PATH set also takes the calls that may dispatch to its methods (Query::Virtual): those naming a method on a supertype of its class, or on a subclass inheriting it. A supertype method more than DEFAULT_FAN_OUT classes define is not followed (the search notes it); * in front follows every one, = keeps only the calls naming the set’s methods themselves.

Constraints keep the calls whose values they accept (Query::Call): argN is the Nth declared parameter of the called method (from 0), this its receiver, paramK the calling method’s own pK (smali numbering), ret: / field: the result of a call / a field read the target matches. Values are what the call site may hold: = keeps a site the analysis cannot decide (marked ?), == drops it. * only shows the values. A REGEX runs to the next , / ] outside () / {}, or is quoted like TEXT (\", \\ escape).

Functions§

has_constraints
Whether a method target carries call constraints (X[arg0=1]).
method_set
The methods of an @file: one per line, blank lines and # comments skipped. A line may be any method target spelling, or a line findrefs or callgraph printed: its first Lcls;->name... token is the method.
parse_condition_in
Parse one condition (a rule of a single part without !).
parse_rule_in
Parse a rule (see the module docs). @PATH files are read relative to dir (the current directory when None).