Go to Declaration
Basic Usage
BashSupport Pro helps you to quickly navigate in shell scripts.
Place the text cursor on an element in a shell script and choose Navigate → Declaration or Usages… to navigate to the declaration (JetBrains help pages).
BashSupport Pro lets you navigate to the declarations of these elements:
- Function Calls
- It navigates to the declaration of the function.
- Variable References
- It navigates to the closest declaration of the variable. For example, it navigates to
export myVar
if you invoke it for$myVar
. - Variable Declarations
- It navigates to the closest, earlier declaration of a variable declaration.
- For example, for
myVar=1; myVar=2; export myVar
, it will navigate tomyVar=2
if you call it for the exported definition. When you invoke the action again onmyVar=2
, then it will navigate tomyVar=1
. - If you prefer to always navigate to the earliest declaration, then see below for a setting to configure this behaviour.
- Predefined Variables
- Variables defined by Bash or POSIX, e.g.
$HOME
or$RANDOM
, are contained in stub files. Go to Declaration will open such a stub file if you navigate to the declaration of a predefined variable.
Supported Shell Commands
Local Scope
BashSupport Pro supports the local
variable scope. local
allows to restrict the visibility of variables to the current function. It’s only available for Bash scripts, i.e. it’s not available in POSIX scripts.
Go to… supports local scope. If you call it within a function, then it will only navigate to the local declarations. If you call it outside a function, then it will ignore variables declared as local.
|
|
Unset
BashSupport Pro supports the unset command. unset allows you to make a variable unavailable to all following commands. The plugin considers variables, which have been unset as a new variable.
|
|
Scratch Files
BashSupport Pro allows you to navigate in scratch files. The complete feature-set is available, but limited to the current file.
Code Injection
BashSupport Pro allows you to navigate in code with an injected language. The complete feature-set is available, but limited to the code block. Navigation between multiple blocks is only supported where smart language injection is performed, for example in Makefile files with the Makefile language plugin installed.
Settings
By default, Go To Declaration navigates to the closest (re)declaration of a variable. In our opinion, this is the most useful implementation to navigate within complex shell scripts.
If you don’t like this, then the setting Prefer the closest definition for Go To Declaration
lets you change the behaviour.
To do this, disable the checkbox in the settings at Settings → Languages & Frameworks → BashSupport Pro.