Support for Cadence, the resource-oriented smart contract language of Flow, in Intellij Platform IDEs.
Get the plugin
Report a Problem / Request a Feature
Table of Contents
- Cadence language support for intellij platform IDEs
- https://plugins.jetbrains.com/plugin/17764-cadence
- You can download the plugin by searching the marketplace in your Intellij Platform IDE
- Alternative you can get it from the Jetbrains Marketplace
- For the semantic analysis through the language server to work, you need to:
- Ensure you have flow-cli installed. Running the command
flow
should works from any terminal (aka it is in your PATH). - Ensure you have a file with the initial configuration, or generate one (named
flow.json
) by runningflow init
. - Go to
Settings
->Tools
->Cadence Settings
and set the location of your flow.json. - You can also edit the rest of the settings if you want
- Restart Intellij. (In a future release this will be improved so that this step is not needed)
- Ensure you have flow-cli installed. Running the command
⚠️ If you get an errorCan't start server due to Cannot run program "flow" ... No such file or directory
, please go toSettings
->Tools
->Cadence Settings
, set the absolute path to the flow executable, and restart the IDE
- The plugin will be immediately associated with any
.cdc
files and provide syntax highlighting. - It will follow the different themes / color schemes you choose from your IDE
- You can customize the colors by going to
Settings
->Editor
->Color Scheme
->Cadence
- To utilize the LSP support, ensure you followed the installation instructions
- If the Language Server is working correctly, you will see a green circle on the bottom toolbar (with information on hover)
- You can configure the settings for the LSP under
Settings
->Tools
->Cadence LSP settings
- Note: After changing settings, a restart is required for them to take effect. This will be addressed in a future release
All Intellij Platform products, from version 2021.2 and up:
- IntelliJ IDEA Ultimate
- IntelliJ IDEA Community
- IntelliJ IDEA Educational
- PyCharm Professional
- PyCharm Community
- PyCharm Educational
- GoLand
- RubyMine
- CLion
- PhpStorm
- WebStorm
- Rider
- Code With Me Guest
- Android Studio
- DataSpell
- DataGrip
- JetBrains Gateway
- MPS
- AppCode
- Refine syntax highlighting
- Improve support for Language Server Protocol
- Everyone is welcome to contribute, through issues reporting or pull requests
- Feel free to open an issue before you start working on it, to avoid duplicate work
- Open project with Intellij
- From project structure, set the project SDK to a JDK 11, and the language level to 11
- From project structure -> modules -> main, click the edit on the "gen" folder under sources and check the checkbox to mark it as generated
- Go to
Cadence.bnf
and from the context menuGenerate Parser Code
- Go to
Cadence.flex
and from the context menuRun JFlex Generator
- Build the project (run the gradle build task)
- Run the gradle task runide
- On the new IDE that runs, if you open a
.cdc
file you should see the plugin working - If you make changes on the code, generate any sources needed, and run the runide again
- If after changes you see "strange" results, it's a good idea to actually delete the
gen
folder and rerun the generations
- Declares the high level Token types
- All declared types will be available as return types at Cadence.flex
- After changing you must generate parser code (control+shift+g)
- It is good idea to also first delete the
gen
folder
- Used to define the regexes that recognise the tokens
- Generates the Lexer using JFlex
- After changing you must Run JFlex generator (control+shift+g)
- First rule that matches wins
- You can have states, in which you declare the rules that apply only there
Once a token is being recognised in the PSI structure, to add highlighting for it, you need to update:
CadenceSyntaxHighlighter
for the actual highlightingCadenceColorSettingsPage
to add new tokens to the Color Scheme page of the IDE
- The Language Server Protocol server provided by Cadence is utilized
- To provide the support the library lsp4intellij is used
- Settings and functionality for logging input / output commands to LSP server for local debugging are available
- Ensure everything is ready
- Make any required changes to build.gradle (version, changelog, release channel)
- commit, and push
- sign the plugin (for now using the sign-plugin.sh , will need to update the version)
- tag version:
git tag -a v1.4 -m "Version 1.4"
- push tag
git push 1.4
- make a release in github. Add the generated signed zip found under /build/distribution
- Go to plugins.jetbrains.com and upload new version
- Wait for approval
- Test that it works