Sui Move Analyzer, a Visual Studio Plug-in, streamlines the development process by analyzing and improving Move code written for the Sui network. It supports definitions and auto-complete within Visual Studio’s integrated development environment (IDE) and provides an outline to give developers an overview of large programs.
Unlike other Move development tools, Sui Move Analyzer includes Sui-specific features. A Sui project template and Move code snippets bootstrap development efforts, and an integrated Sui unit test increases developer velocity by ensuring effective, working code.
Along with downloading and installing Sui Move Analyzer, we need to set up our environment to begin building a project. Note that we used Ubuntu Linux LTS for this tutorial. Builders on other platforms will need to tailor some of the commands shown here for their own systems.
Setting up Sui
Getting started with Sui requires installing some prerequisites based on the builder’s operating system and getting the Sui binaries. Here we will refer to the Sui documentation, which includes detailed information for Linux, Mac, and Windows.
Along with the above steps, the documentation on setting up Sui includes other useful information.
Move Analyzer Language Server
Now we need to install the Move Language Analyzer Server, which receives requests from the Sui Move Analyzer plug-in, performs lexical and semantic analysis on the code, and helps the plug-in provide language-specific features. The most reliable means of installing this server is through the Rust toolchain, which is very convenient, highly reliable, and receives regular maintenance. The Rust toolchain includes a compiler and other tools useful for running Sui Move Analyzer.
To get the Rust toolchain, open a command line interface (CLI) and enter the following:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
After installing the Rust toolchain, execute the following command in the CLI:
cargo install --git https://github.com/movebit/move --branch move-analyzer2 move-analyzer
Use the following commands to check if the requirements have been installed correctly:
The CLI should output the current Move Analyzer Language Server version and help options, which means the dependencies have been successfully set up.
Sui Move Analyzer Plug-in
Now we have everything ready, we can install Sui Move Analyzer. We will, of course, need Microsoft Visual Studio.
Simply go to the Sui Move Analyzer download page and click the download button.
If you find an unexpected result when installing the Move Analyzer Language Server and Rust toolchain, we suggest taking the following steps:
- Make sure you have the latest version of Rust. Open your terminal and input the command
rustup update, then retry the installation steps and reboot Visual Studio.
- If you installed the move-analyzer executable to a location other than Visual Studio’s project directory, you can point it to the correct location in the settings. Use Visual Studio’s search function to find the move-analyzer.server.path setting, and set it to the location of the move-analyzer language server you installed. On MacOS, click the Code menu, then choose Preferences > Settings to input the correct directory.
Create a New Project
Setting up all the required files and configurations for a new project can be time-consuming, so we integrated the Sui framework with Sui Move Analyzer to jumpstart the process. To use the integrated commands, select the command palette tool and input “move analyzer/Sui”. On MacOS, go to the View menu and click Command Palette. The command list for Move Analyzer will appear.
Choose the “Create SUI project” command from the list. Sui Move Analyzer automatically generates a project from a template and can implement a multi-project development feature. You may need to reopen Visual Studio to ensure this feature is working properly after creating your project.
Along with project templates, Sui Move Analyzer includes features that increase developer efficiency. It supports many commonly used code snippets in the Sui framework. For example, typing “fun init” quickly generates an initial function.
Ensuring that code works properly at the module level helps avoid extensive bug hunts on deployed programs or smart contracts. Sui Move Analyzer integrates unit test tools to verify code. Including the “#[test_only]” tag causes a Run Test option to appear, as shown below.
The features we’ve gone over so far help new builders get started on Sui and eliminate some of the repetitive work associated with coding in general.
Coding with Move on Sui
Sui Move Analyzer includes the majority of features found in other language plug-ins, all of which can be easily accessed while coding. To bring up a context menu, right-click the cursor on an identifier, such as a local variable or parameter name, in the coding screen and choose an option. You will be able to see a definition of the identifier, a type definition, and references.
Hovering the cursor over an identifier shows its name in a tooltip. Sui Move Analyzer covers almost all Move’s identifiers including built-in type.
While typing, Sui Move Analyzer shows auto-complete suggestions for almost all elements in Move. As it integrates the Sui framework, typing “sui::” into the IDE brings up a list of modules you can select.
In addition to the features outlined above, we have also optimized the semantic analyzer’s code, resulting in efficiency and more reasonable memory allocation.
Coding with MSL
The Move Specification Language (MSL), a subset of Move, provides specifications for how Move functions interact with each other. MSL is at the core of Move Prover, a CLI tool designed to assist builders with accurate Move code. Similar to how Sui Move Analyzer supports Move on Sui, it also supports the MSL with features such as definitions and auto-complete. Builders who want to work on the MSL will find Sui Move Analyzer helpful.
MSL’s syntax is highly flexible, and we’ve considered various possible use cases. When selecting MSL syntax in a function, the auto-complete feature will show possible identifiers.
Specifications in the MSL determine how Move functions interact. Sui Move Analyzer can generate these specifications for a single function or all the functions within a .move file.
The above features extend Sui Move Analyzer from helping builders code apps for Sui to contributing to the MSL project. It makes code verification simple, especially for those using Move Prover.
We hope builders find that Sui Move Analyzer increases their coding velocity. Many of its features will be familiar to those who have used similar plug-ins with different programming languages.
Although we carefully tested its features, there still may be issues. We look forward to feedback on improvements or refinements. And feel free to contact MoveBit if you need help with Sui Move Analyzer.
The Sui Foundation accepts article contributions from across the Sui community. The views and opinions expressed by community members may not reflect those of the Sui Foundation.