Understanding JetBrains URL Scheme

While using click-to-component recently, I discovered it didn’t support JB IDE integration, so I spent some time implementing support. Here, I’ll mark down JB’s URL Scheme support situation.

JB IDE itself doesn’t provide direct URL Scheme support. After research, I found the following 2 solutions.

JetBrains Toolbox

After installing the toolbox, it provides support for various JB IDEs.

Supported IDE List

  1. IntelliJ IDEA
  2. AppCode
  3. CLion
  4. PyCharm
  5. PhpStorm
  6. RubyMine
  7. WebStorm
  8. Rider
  9. GoLand
  10. RustRover

Supported Actions

  1. Checkout a repository and open it with the corresponding IDE
1
jetbrains://${toolTag}/checkout/git?checkout.repo=${cloneUrl}&idea.required.plugins.id=Git4Idea
  1. Open a repository file and move to the corresponding line and column position.
1
jetbrains://${toolTag}/navigate/reference?project=${project}&path=${filePath}:${lineIndex}:${columnIndex}

For specific URL Scheme rules, see the repository jetbrains-url-schemes

The drawback of this solution is that it doesn’t provide functionality to open a specific file directly.

IDE Remote Control

JB officially provides IDE Remote Control support, which means the IDE offers a control server that can be operated through HTTP API.

API Specification

1
2
3
4
5
6
7
8
9
10
11
* @apiExample {curl} Absolute path
* curl http://localhost:63342/api/file//absolute/path/to/file.kt
*
* @apiExample {curl} Relative path
* curl http://localhost:63342/api/file/relative/to/module/root/path/to/file.kt
*
* @apiExample {curl} With line and column
* curl http://localhost:63342/api/file/relative/to/module/root/path/to/file.kt:100:34
*
* @apiExample {curl} Query parameters
* curl http://localhost:63342/api/file?file=path/to/file.kt&line=100&column=34

For specific details, see JB’s official commit

The drawback of this solution is that IDE needs to install the IDE Remote Control plugin. And because it’s an HTTP service, it might conflict with local ports, requiring manual modification.

https://static.1991421.cn/2024/2024-12-25-111637.jpeg

At the end

Both solutions above can achieve file click-and-jump functionality, but both have shortcomings. Looking forward to JB IDE providing comprehensive URL Scheme support directly in the future.