37 | | }}} |
38 | | = Function entity = |
39 | | |
40 | | 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. |
41 | | |
42 | | == Initial selector == |
43 | | * {{{@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). |
44 | | |
45 | | == Selectors == |
46 | | ''In parentheses you find the type of the result elements.'' |
47 | | |
48 | | * {{{refs}}} (''expression''): returns every expression that refers to the function. These references can be either function applications, import/export directives or fun-expressions. |
49 | | * {{{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. |
50 | | * {{{calls}}} (''function''): returns the set of function entities called in the body of the function. |
51 | | * {{{dyncalls}}} (''function''): returns the set of functions dynamically called in body of the function (for details, see DynamicCallAnalysis). |
52 | | * {{{called_by}}} (''function''): returns every function that calls the specified function (not including dynamic calls). |
53 | | * {{{dyn_calledby}}} (''function''): returns the set of functions that call the given function dynamically (for details, see DynamicCallAnalysis). |
54 | | * {{{args}}} (''expression''): gives the function arguments as a list of expression entities. |
55 | | * {{{body}}} (''expression''): returns the top-level expressions of each clause body. |
56 | | * {{{exprs}}} (''expression''): returns the top-level argument, guard, and body expressions of each clause. |
57 | | * {{{vars}}} (''variable''): returns the set of variable entities defined (bound) in the body of the function. |
58 | | * {{{file}}} (''file''): returns the file entity (the module) that the given function is defined in. |
59 | | |
60 | | == Properties == |
61 | | |
62 | | The following properties are defined on function entities: |
63 | | * {{{name}}} (''atom, string''): gives the name of the function. |
64 | | * {{{exported}}} (''bool''): returns true if the function is exported. |
65 | | * {{{arity}}} (''int''): gives the arity (number of arguments). |
66 | | * {{{bif}}} (''bool''): returns true if the function is an auto-imported built-in function. |
67 | | * {{{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. |
68 | | * {{{dirty}}} (''bool''): returns true if the function has side-effects, or in other words, it is impure. |
69 | | * {{{defined}}} (''bool''): returns true if the definition of the function is loaded into the database. |
70 | | * {{{module}}} (''atom''): returns the name of the defining module. |
71 | | * {{{spec}}} (''string''): returns the specification of the function (If it is not available in the source code, !RefactorErl calculates it.) |