IntelliJ Candid Language Plugin

Hello :wave:

I recently made my repo public and released a rather primitive version but already usable of a plugin to support Candid inside any intellij based editor.

It has for now only a few basic feature but it is my goal to work on it on the upcoming weeks so expect to see a few updates.

  • :bulb: Syntax Highlighting
  • :keyboard: Auto Completion
  • :mag: Find Usage
  • :lipstick: Code Format

A random screenshot to show what it looks like with a random code taken on github :slight_smile:

Just wanted to share it, maybe it will be useful to someone even at the early stage.

15 Likes

Since I made this topic, I will keep using it as a sort of changelog but with more visual. I just made an update to v0.1.0 fixing a few things and features.

Auto import on completion
candid-import

Menu entry to create a new file
image

Show if a type is not from the current file during the completion:
image

Please note whenever I make an update although the entire release process is well automated through github actions - the jetbrains marketplace is manually reviewing every update. It usually takes around 1-2 business day. There’s also the option to directly grab the plugin on github in the release section if you want it faster.

1 Like

Incredible work! Thanks a lot!

Just can’t believe my eyes seeing this :smiley:
Screenshot from 2022-05-14 20-41-18

2 Likes

@Alaanor looks great! I don’t use IntelliJ so I’m wondering if this is (or could be) implemented using the language server protocol so that other editors could benefit from it as well.

1 Like

Nope, unfortunately intellij way to make a language plugin is different from implementing a custom language for the language server protocol that most editor use. I was aware of this constraint from the beginning and still made the choice to go with this. There’s some github repo that have tried making the conversion possible but nothing of production grade. Imo this is something that has to be build twice, let’s hope someone will do it during the supernova hackathon :slight_smile:

2 Likes

Amazing stuff Alaanor! If you’d like to implement the language server for this as well that would be grant material dfinity.org/grants.

Sorry for the delay and that’s really cool to know this would be grant material @Fulco, thanks. I’m not yet sure whatever I’ll do it but there’s good chance I’ll just focus on this one rather for now.

I recently released the v0.2.0 which include a bunch of new small features. To make it more visual, here are some screenshots showing the added content.

  1. :magic_wand: Suggest missing import whenever possible
    image

  2. :face_with_monocle: Marking self import as invalid (#2)
    image

  3. :face_with_monocle: Marking duplicated type name as invalid (#3)
    image

  • :face_with_monocle: Marking empty and invalid import as invalid (#4)
    image

  • :sparkles: Comment code through shortcut (#5)
    It allow the use those two shortcuts, useful when selecting multiple line of text and want to comment it on/off
    image

  • :memo: Documentation for type reference (#6)

source on hover

Also some fixes:

  • Added missing top level keyword import
  • Missing keyword completion for query and oneway
  • Stop suggesting top level keyword inside a service

Concerning unit testing - This is something I would like to add, I am not yet sure how much of it is doable. I will probably dedicate a week to it.

5 Likes

Awesome ! Thanks a lot for this plugin, will try it asap !

Hello ! This time the release is the latest feature release :tada:. I consider the plugin to have enough feature. If there’s anything still missing in your opinion, now is the good time to create a github issue and suggest :slight_smile:

:crab: Rust integration

The release v0.3.0 was focused on integrating rust in the plugin.

  • :wrench: Line marker on rust files when a matching candid method is found

You can click on the line marker in the gutter and it will bring you directly to the corresponding candid method.

  • :wrench: Resolve candid method to their corresponding rust method

candid-rust

  • :face_with_monocle: Unused candid method inspection

image

How does the plugin detect :crab: rust correctly ?

For the sake of correctness, the plugin will only enable rust integration for a given candid file if the followings are found in dfx.json:

{
  "canisters": {
    "foobar-canister": {
      "type": "rust",
      "candid": "correct/path/to/candid-file.did",
      "package": "rust-package-name"
    }
  }
}

All three type, candid and package fields are required to enable rust integration. dfx.json is expected to be found at the root of the project. The type custom will not be supported because of the lack of explicit information that the plugin require to correctly resolve items.

Whats coming next ?

I will probably dedicate the remaining weekends for making the plugin more resilient by adding multiples unit tests, improve the codebase quality and optimizing performance if required.

Ps: @GLdev maybe now this feature can convince you to use clion :stuck_out_tongue:

3 Likes