VSCode for MOOSE
This extension provides language support and IntelliSense for input files of MOOSE (Multiphysics Object Oriented Simulation Environment) applications.
Note: A major API change occurred in v0.7.0
Auto Completion Demo
Loading MOOSE Syntax Data
MOOSE object and hierarchy data is read primarily from the YAML file you can create from your MOOSE application:
>> ./moose-opt --yaml > syntax.yaml
Additional data (descriptions and source file paths) will also be read, if available, from the JSON output:
>> ./moose-opt --json > syntax.json
These can also be created within VS Code via selecting '
MOOSE: Create Syntax Files' in the Command Palette (
Cmnd+Shift+P), or downloading example files from the Extension Repository.
By default, these files are expected to be in the top-level of the workspace, but their paths can be altered in the Settings.
Auto-Completion and Definition/Reference Identification
Autocompletion is triggered either by
Ctrl+Space or typing
Note that if there is an inline comment at a variable description,
[./a] # describe the variable, this comment will show in the auto-completion.
Defining Material Property Names
Material property names are defined in the Material C++ object files, using the
However, these names are resolved dynamically (at runtime), and so are not directly available for static analysis.
VSCode for MOOSE attempts to find material property name definitions (or defaults) for common materials, including:
f_name (used by
prop_names (used by
tensor_name (used by
property (used by
function_name (used by
To override these definitions and/or specify other names that a Material sub-block defines,
an inline comment should be added to the sub-block, which includes
<defines: name1 name2>:
Files are diagnosed for multiple types of syntax and formatting errors:
closure: if block(s) have not been closed,
duplication: duplication of block or parameter names,
refcheck: internal variable reference checks
matcheck: internal material reference checks
dbcheck: checks against the syntax database (e.g. block or parameter not found and required parameters missing)
format: formatting warnings, including bad indentation and multiple blank lines
Some of these errors can be fixed by Code Actions:
Additionally, blocks which have been set as inactive (by the
inactive parameters) will be rendered faded out:
The amount of fading is controlled by the
editorUnnecessaryCode.opacity theme colour or can be underlined using
Diagnostics types can be turned on/off in the Settings.
Format Document option will format the document by:
- Indenting the sections according to their level (the number of space per indentation can be controlled in the Settings).
- Removing multiple blank lines.
Format as you type can also be set in the general settings (
Settings are configured in
Preferences -> Settings:
|the path of the YAML file
|the path of the JSON file
|the number of spaces per indentation
|specify which syntax error types are flagged as errors
|specify which syntax error types are flagged as warnings
|log debug and warning messages to the console
MOOSE: Reset MOOSE Objects Database
MOOSE: Create Syntax Files
How to install from Marketplace
This extension is hosted at Visual Studio Marketplace
- Upgrade to Visual Studio Code 1.15.0 or above.
- Switch to the Extensions view by clicking the fifth icon in the left most bar.
- Type “moose” in the search box and hit the Enter key.
- Click “Install” button to install “MOOSE for VSCode” extension.
Major API change (using syntax.yaml)
Fixed some bugs:
- ignore commented out blocks
- include active/inactive parameters at block level
- underline TODO comments
- added variables and materials names to autocompletion and hover functionality
- added variable / material definition locations to DefinitionProvider
cpp_type to description in HoverProvider
- fixed bug when parameter is defined before any blocks
- fixed bug when parameters are defined in GlobalParams block
- added autocompletion for values of active/inactive parameters
- added identification and fading of inactive blocks
- added error checking for missing required parameters
- classified errors by type and allowed control of their reporting via settings
- added CodeActions to provide errors corrections
- fixed bug whereby assessing outline/errors would show for wrong document
- general code refactoring
- added reference provider functionality
- improved identification of variable/material definitions and references
- added diagnostics of internal variable/material references
- split diagnostics user option to set which error types are flagged as errors or warnings
- added reading of comments, inline to block openings
- added overriding of materials properties via identifying
<defines: > in inline Materials sub-block comment
- performance improvements for building outline / diagnostics
- improved hover markdown string format
- fixed bug in syntax highlighting of types
- fixed bug if type parameter overrides subblock name
material_property_names parameter in Materials sub-block;
- provide autocompletion / hover of material names
- add referenced material names to "Find References" result
Thanks to Daniel Schwen for supplying code for MOOSE autocompletion in ATOM.io
VS Code Extension Development
Some useful links:
To create an extension:
>>> yo code
To open MOOSE for VSCode extension:
>>> cd /path/to/extension
>>> code .
Use F5 to open test environment.
To publish extension:
>>> vsce publish