IntelliJ Goland or IntelliJ IDEA

I tried to integrate Goland with Hook and found that the current IntelliJ IDEA integration is not ideal.

Current Goland/IDEA supports internal jetbrains:// links to project, file in the project, and cursor position.

I created a script for creating a link and getting a nice name.

Get link

This script creates a link to the whole project because the link to the cursor position or file is pretty unuseful. It can be easily updated to get a link to file instead.

Preparation

You need to setup a keyboard shortcut for “Copy path…Toolbox URL” from keymap settings. In my case its ⌃⇧⌥⌘+С, if you choose differently — you’ll need to update the script.

Also, for IDEA/rubymine/pycharm users - you need to update application id from com.jetbrains.goland to id of your app. You can find this ID by passing to console osascript -e 'id of app "Goland"'

Script

set the clipboard to ""
tell application id "com.jetbrains.goland"
	activate
end tell

tell application "System Events"
	keystroke "c" using {shift down, command down, option down, control down}
	delay 0.1
	set fp to the clipboard
end tell

set AppleScript's text item delimiters to ":"
set theTextItems to every text item of fp
set result to (text items 1 thru ((length of theTextItems) - 2) of theTextItems as string)
get result

Get pretty name

The same thing, don’t forget about the custom shortcut.

set the clipboard to ""
tell application id "com.jetbrains.goland"
	activate
end tell

tell application "System Events"
	keystroke "c" using {shift down, command down, option down, control down}
	delay 0.1
	set fp to the clipboard
end tell

set AppleScript's text item delimiters to "project="
set parsePjName1 to text item 2 of (every text item of fp)
set AppleScript's text item delimiters to "&"
set result to text items 1 thru ((length of every text item of parsePjName1) - 1) of parsePjName1
get result as string

I assume that the first script may need to be updated to create a link based on project name, but on another side, some of you may want to have a link to the specific file, instead of the link to the project, so I decided to leave the first version of the script as more hackable option.

I wrote updated script for idea (no need to add “Get name” script, just add to “Get Address”, also, no need to assign custom shortcut)
I’m pretty sure it can be used as standard IDEA script, btw
But, intellij toolbox need to be installed for opening created links

set the clipboard to ""
tell application id "com.jetbrains.intellij"
	activate
end tell

tell application "System Events"
	key code 56
	key code 56
	delay 0.2
	keystroke "toolbox URL"
	delay 0.4
	key down return
	delay 0.2
	set fp to the clipboard
end tell


set AppleScript's text item delimiters to "&"
set parsePjLink to text item 1 of (every text item of fp)

set AppleScript's text item delimiters to "project="
set parsePjName1 to text item 2 of (every text item of fp)
set AppleScript's text item delimiters to "&"
set result to text items 1 thru ((length of every text item of parsePjName1) - 1) of parsePjName1
get result as string
set the fullink to "[" & result & "](" & parsePjLink as string & ")"
get fullink

wdyt?