Announcing $300M Series B Raise: Sui-nami is rising!

Resources Move Mysten Labs Tue Jul 05 2022

Announcing Enhanced Move VSCode Plugin

Summary: Move VSCode plugin now ships with many more cool features!

Over the last few months, Mysten Labs has been working hard on new features for the Move language’s VSCode plugin (a plugin for the Visual Studio Code editor). And we are now finally ready to share what we have accomplished with the wider developer community. The plugin is intended to work both with the core Move language and with all existing Move language flavors such as Sui Move.

The VSCode plugin for Move is called move-analyzer and it is available in the Visual Studio Marketplace. The new features are supported via the Language Server Protocol; in order to unleash the full potential of the plugin, in addition to installing the plugin itself, you also need to install move-analyzer’s language server as described in installation instructions provided with the plugin distribution.

The Language Server Protocol (LSP) was originally introduced by Microsoft, but it is also supported by a range of other code editors and Integrated Development Environments (IDEs), such as Sublime Text or Eclipse. It is a standard protocol where an editor of an IDE can “ask” the language server for certain types of information concerning the code being edited. And it lets you visualize data obtained in a way that both enhances and simplifies the code development process. We hope to integrate these new features with other editors of IDEs, ideally with the help of the Move language community.

The new features provided by the current version of move-analyzer’s language server fall into two main categories: code comprehension and error reporting. They have been implemented by integrating the language server with the “standard” Move compiler (the compiler that was co-developed with the language and is part of the main Move source code repository). This integration not only guarantees accuracy of the information provided by the language server (e.g., error messages visualized by an editor or an IDE will directly correspond to error messages generated by the compiler), but it will also simplify the language server maintenance in the face of potential future Move language changes. You will find the description of the new features below, and you can also view a demo of the new features in this video:


Code comprehension

One of the problems with more traditional smart contract languages that the Move language design is trying to solve is code composition and reuse. To enable code reuse, the code can be grouped into packages (e.g., a standard library package), and these packages can be shared across different smart contract implementations. This means that developers writing new smart contracts may have to deal with a code base that is largely unknown to them. 

The new VSCode plugin delivers a set of features that can aid developers in better understanding their entire code base.

Type on hover

When encountering an identifier in an unknown code base, you may not know the type of the identifier. If you hover a cursor over the name of an identifier (e.g., a name of a local variable or a name of a function), you will see the name of this identifier displayed in a tooltip. See this example.

Go to definition

Another piece of information about an identifier that may not be immediately obvious is where this identifier is defined - it may just as well be a local variable defined in the same function but also, for example, a function defined in a different module. If you right-click on the identifier name and choose the Go to Definition option from the menu, your cursor will be transported to the location of the identifier’s definition. See this example.

Go to type definition

Even if you know where the definition of a given identifier is, and you know the name of its type, it does not necessarily mean that it is trivial to locate its type definition. For example, you may already know that the identifier type is struct SomeStruct but you will still not know what are the fields of this struct. If you right-click on the identifier name and choose the Go to Type Definition option from the menu, your cursor will be transported to where the type of this identifier is defined. See this example.

Find references

The latest feature enhancing code comprehension is the ability to find all occurrences of a given identifier in the entire code base. This can be useful, for example, if you would like to know where a given function is being called.  If you right-click on the identifier name and choose the Find All References option from the menu, all occurrences of this identifier will be displayed in the left pane of the VSCode editor window. See this example.

Error reporting

A standard method of obtaining compiler diagnostics (errors but also warnings) for a piece of Move code is to run the compiler on the command line and observe the output it produces. While this method is certainly sufficient, it may not be the most convenient. Instead, what we introduce in the new version of the VSCode plugin is displaying compiler diagnostics in the editor window. Whenever you save a file, the language server will run the compiler in the background and send the resulting output back to VSCode to be displayed (information concerning code comprehension is also recomputed at the same time). See this example.

. . .

Learn more about Sui

Build with us!!

We’re excited about what the future unfolds and invite creators and builders to join us.