Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

google chrome - Create a web browser link that opens a file in Intellij. Possible?

Example, qbittorent can be made to open links that are of torrent files.

Email clients mailto:

Is it possible to create links in a browser that will open the given file in Intellij? (Not full path, but entire package possibly ).

Idea is that this will be created for bitbucket.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is an open feature request to add idea:// protocol handler.

At the moment it works on macOS only out of the box. For other platforms you can try the third-party solution or other workarounds from the ticket comments.

There is also a built-in web server providing the REST API to open files.

It will work with the relative paths only when the IDE is already running and the project is open: http://localhost:63342/api/file/relative/to/module/root/path/to/file.kt.

With the JetBrains Toolbox App installed one will be able to use jetbrains:// protocol for navigation, it's work in progress and should be available in 2019.2.

See JBProtocolNavigateCommand.kt for the reference:

// 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]+

Sample URL:

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

Toolbox URL matches regexp:

"${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]+))*"

There will be also UI for copying TBX protocol URLs directly from the editor similar to the Copy Reference action in the context menu. The same will work for IDE settings navigation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...