创建在 Intellij 中打开文件的 Web 浏览器链接。可能的?

mom*_*omo 7 google-chrome intellij-idea

例如,qbittorent 可以用来打开 torrent 文件的链接。

电子邮件客户端mailto:

是否可以在浏览器中创建链接以在 Intellij 中打开给定文件?(不是完整路径,但可能是整个包)。

想法是这将为 bitbucket 创建。

Cra*_*der 12

有一个开放的功能请求添加idea://协议处理程序。

目前,它仅适用于开箱即用的 macOS。对于其他平台,您可以从票证评论中尝试第三方解决方案或其他解决方法。

还有一个内置的 Web 服务器提供REST API 来打开文件

仅当 IDE 已在运行且项目已打开时,它才会使用相对路径:http://localhost:63342/api/file/relative/to/module/root/path/to/file.kt.

随着JetBrains的工具箱应用程序安装在一台将能够使用jetbrains://协议的导航,它的工作进展情况,并应在提供2019.2

参考JBProtocolNavigateCommand.kt

// handles URLs of the following types:

// jetbrains://idea/navigate/reference?project=IDEA
// [&reference[X]=com.intellij.navigation.JBProtocolNavigateCommand[.perform][#perform]]+
// [&path[X]=com/intellij/openapi/project/impl/JBProtocolNavigateCommand.kt[:23[:1]]]+
// [&selection[X]=25:5-26:6]+
Run Code Online (Sandbox Code Playgroud)

示例网址:

jetbrains://idea/navigate/reference?project=IDEA&fqn=com.intellij.openapi.application.JetBrainsProtocolHandler#getParameters

工具箱 URL 匹配正则表达式:

"${JetBrainsProtocolHandler.PROTOCOL}([\\w\\-]+)/navigate/reference\\?project=(?<project>[\\w]+)(&fqn[\\d]*=(?<fqn>[\\w.\\-#]+))*(&path[\\d]*=(?<path>[\\w-_/\\\\.]+)(:(?<location1>[\\d]+))?(:(?<location2>[\\d]+))?)*(&selection[\\d]*=(?<line1>[\\d]+):(?<column1>[\\d]+)-(?<line2>[\\d]+):(?<column2>[\\d]+))*"

还有用于直接从编辑器复制 TBX 协议 URL 的 UI,类似于上下文菜单中的复制参考操作。这同样适用于 IDE 设置导航。