Version 1 (modified by manualwiki, 13 years ago) (diff) |
---|
File (or module) entity
A file entity corresponds to an Erlang source file. This entity represents the module concept of Erlang, as modules are mapped to files, but header files also fall into this category.
Initial selectors
File entities can be referred at the start of a query by two selectors:
- files (or modules) yields every file (or module) loaded into the refactoring database
- @file (or @module) yields the current file (or module)
TODO: difference between files and modules
Selectors
The following selectors can be used on file entities. Note that every selector can be used on either module or header files, but some of them will give no results for headers (e.g. a header file can't export functions).
After the name of the selector between parentheses you can find the type of the elements in the resulted set.
- funs (function): returns the set of function entities defined in the file.
- records (record): returns every record entity defined in the file.
- macros (macro): returns the macro entities introduced in the file.
- includes (file): returns all the file entities included in the file, either directly with a -include directive, or indirectly through an include chain.
- included_by (file): using this selector on a particular file entity gives all the file entities that include the previous file.
- imports (function): returns the set of function entities that are referred with an import directive in the file.
- exports (function): returns the set of functions exported in the file.
Properties
These properties are defined for file entities:
- module (boolean): gives true if the file is a module.
- header (boolean): returns true if the file is a header (.hrl).
- name (atom, string): gives the name of the file. In case of modules it does not contain the .erl extension to make it easier to work with module names.
- filename (string): returns the file name as a string with the .erl extension.
- dir (string): returns the directory containing the file.
- path (string): returns the absolute path of the file (the directory and the complete file name).