Navigating in Sourced Files
BashSupport Pro supports the source
command and also follows sourced files to locate declarations of variables and functions.
Both of the following scenarios are supported:
- The declaration is in a sourced file
- The declaration is in a file, which sources the current file
Please note, that Go to Declaration and related features are only available if the definition is in scope.
Source Command Support
If you use the source
command with relative paths, then the plugin will automatically follow these files.
It assumes that the paths are relative to the current file’s parent directory.
Definitions found in sourced files are supported by all features of BashSupport Pro, for example:
- Code completion
- Go to declaration
- Rename
- Quick documentation
- Find usages
|
|
|
|
Shellcheck Support
If you’re using dynamic values with the source
command, then ShellCheck and BashSupport Pro need help to locate the file.
For example, code like this is commonly used:
|
|
$_basedir
is only known at runtime, of course.
You need to provide a hint where the file is located inside your project.
Define a shellcheck source directive to tell BashSupport Pro where to find the sourced file:
|
|
Now Go to Declaration, Find Usages…, Rename…, etc. will also take care of the definitions in the sourced file.