| 1 | {{{#!comment |
| 2 | = Function entity = |
| 3 | |
| 4 | Function entities correspond to Erlang functions. They can come from two sources: they are either defined in a module loaded into the database, or just referred to in the loaded code. In the latter case, information about the function may be incomplete. |
| 5 | |
| 6 | == Initial selector == |
| 7 | * {{{@fun}}} at the start of a query, this selector can be used to refer to the "current" function (either a function invoked by the selected call-expression, or a function defined at the current selection). |
| 8 | |
| 9 | == Selectors == |
| 10 | ''In parentheses you find the type of the result elements.'' |
| 11 | |
| 12 | * {{{refs}}} (''expression''): returns every expression that refers to the function. These references can be either function applications, import/export directives or fun-expressions. |
| 13 | * {{{dynref}}} (''expression''): returns every expression that refers to the function by a dynamic function call (e.g. an {{{apply}}} call, for details see DynamicCallAnalysis). Note that you have to run dynamic call analysis prior to using this query. |
| 14 | * {{{calls}}} (''function''): returns the set of function entities called in the body of the function. |
| 15 | * {{{dyncalls}}} (''function''): returns the set of functions dynamically called in body of the function (for details, see DynamicCallAnalysis). |
| 16 | * {{{called_by}}} (''function''): returns every function that calls the specified function (not including dynamic calls). |
| 17 | * {{{dyn_calledby}}} (''function''): returns the set of functions that call the given function dynamically (for details, see DynamicCallAnalysis). |
| 18 | * {{{args}}} (''expression''): gives the function arguments as a list of expression entities. |
| 19 | * {{{body}}} (''expression''): returns the top-level expressions of each clause body. |
| 20 | * {{{exprs}}} (''expression''): returns the top-level argument, guard, and body expressions of each clause. |
| 21 | * {{{vars}}} (''variable''): returns the set of variable entities defined (bound) in the body of the function. |
| 22 | * {{{file}}} (''file''): returns the file entity (the module) that the given function is defined in. |
| 23 | * {{{clause}}} (''clause''): returns the clauses of the given function. |
| 24 | |
| 25 | == Properties == |
| 26 | |
| 27 | The following properties are defined on function entities: |
| 28 | * {{{name}}} (''atom, string''): gives the name of the function. |
| 29 | * {{{exported}}} (''bool''): returns true if the function is exported. |
| 30 | * {{{arity}}} (''int''): gives the arity (number of arguments). |
| 31 | * {{{bif}}} (''bool''): returns true if the function is an auto-imported built-in function. |
| 32 | * {{{pure}}} (''bool''): returns true if the function is free of side-effects. We have to mention here, that those functions that are not loaded into the database of !RefactorErl (for example, library functions) are considered as impure. If you need a more precise analysis, you should add the affected files to the database of !RefactorErl. The knowledge about the BIF-s is built into the tool. |
| 33 | * {{{dirty}}} (''bool''): returns true if the function has side-effects, or in other words, it is impure. |
| 34 | * {{{defined}}} (''bool''): returns true if the definition of the function is loaded into the database. |
| 35 | * {{{module}}} (''atom''): returns the name of the defining module. |
| 36 | * {{{spec}}} (''string''): returns the specification of the function (If it is not available in the source code, !RefactorErl calculates it.) |
| 37 | }}} |