Skip to content

Commit

Permalink
Merge pull request desktop#9387 from say25/Add-Rider-Windows
Browse files Browse the repository at this point in the history
Add support for JetBrains Rider on Windows
  • Loading branch information
rafeca authored Apr 2, 2020
2 parents 7981a5c + 4c68dbc commit e5f8b5b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
61 changes: 60 additions & 1 deletion app/src/lib/editors/win32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum ExternalEditor {
Webstorm = 'JetBrains Webstorm',
Phpstorm = 'JetBrains Phpstorm',
NotepadPlusPlus = 'Notepad++',
Rider = 'JetBrains Rider',
}

export function parse(label: string): ExternalEditor | null {
Expand Down Expand Up @@ -68,6 +69,9 @@ export function parse(label: string): ExternalEditor | null {
if (label === ExternalEditor.NotepadPlusPlus) {
return ExternalEditor.NotepadPlusPlus
}
if (label === ExternalEditor.Rider) {
return ExternalEditor.Rider
}

return null
}
Expand Down Expand Up @@ -371,7 +375,15 @@ function getRegistryKeys(
'SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Notepad++',
},
]

case ExternalEditor.Rider:
return [
// Rider 2019.3.4
{
key: HKEY.HKEY_LOCAL_MACHINE,
subKey:
'SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\JetBrains Rider 2019.3.4',
},
]
default:
return assertNever(editor, `Unknown external editor: ${editor}`)
}
Expand Down Expand Up @@ -414,6 +426,8 @@ function getExecutableShim(
return Path.join(installLocation, 'bin', 'phpstorm.exe')
case ExternalEditor.NotepadPlusPlus:
return Path.join(installLocation)
case ExternalEditor.Rider:
return Path.join(installLocation, 'bin', 'rider64.exe')
default:
return assertNever(editor, `Unknown external editor: ${editor}`)
}
Expand Down Expand Up @@ -478,6 +492,11 @@ function isExpectedInstallation(
return (
displayName.startsWith('Notepad++') && publisher === 'Notepad++ Team'
)
case ExternalEditor.Rider:
return (
displayName.startsWith('JetBrains Rider') &&
publisher === 'JetBrains s.r.o.'
)
default:
return assertNever(editor, `Unknown external editor: ${editor}`)
}
Expand Down Expand Up @@ -645,6 +664,37 @@ function extractApplicationInformation(
const displayName = getKeyOrEmpty(keys, 'DisplayName')
const publisher = getKeyOrEmpty(keys, 'Publisher')
const installLocation = getKeyOrEmpty(keys, 'DisplayIcon')

return { displayName, publisher, installLocation }
}

if (editor === ExternalEditor.Rider) {
let displayName = ''
let publisher = ''
let installLocation = ''

for (const item of keys) {
// NOTE:
// JetBrains Rider adds the current release number to the end of the Display Name, below checks for "JetBrains Rider"
if (
item.name === 'DisplayName' &&
item.type === RegistryValueType.REG_SZ &&
item.data.startsWith('JetBrains Rider ')
) {
displayName = 'JetBrains Rider'
} else if (
item.name === 'Publisher' &&
item.type === RegistryValueType.REG_SZ
) {
publisher = item.data
} else if (
item.name === 'InstallLocation' &&
item.type === RegistryValueType.REG_SZ
) {
installLocation = item.data
}
}

return { displayName, publisher, installLocation }
}

Expand Down Expand Up @@ -712,6 +762,7 @@ export async function getAvailableEditors(): Promise<
webstormPath,
phpstormPath,
notepadPlusPlusPath,
riderPath,
] = await Promise.all([
findApplication(ExternalEditor.Atom),
findApplication(ExternalEditor.AtomBeta),
Expand All @@ -726,6 +777,7 @@ export async function getAvailableEditors(): Promise<
findApplication(ExternalEditor.Webstorm),
findApplication(ExternalEditor.Phpstorm),
findApplication(ExternalEditor.NotepadPlusPlus),
findApplication(ExternalEditor.Rider),
])

if (atomPath) {
Expand Down Expand Up @@ -828,5 +880,12 @@ export async function getAvailableEditors(): Promise<
})
}

if (riderPath) {
results.push({
editor: ExternalEditor.Rider,
path: riderPath,
})
}

return results
}
2 changes: 2 additions & 0 deletions docs/technical/editor-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ These editors are currently supported:
- [SlickEdit](https://www.slickedit.com)
- [JetBrains WebStorm](https://www.jetbrains.com/webstorm/)
- [JetBrains Phpstorm](https://www.jetbrains.com/phpstorm/)
- [JetBrains Rider](https://www.jetbrains.com/rider/)
- [Notepad++](https://notepad-plus-plus.org/)

These are defined in an enum at the top of the file:
Expand All @@ -52,6 +53,7 @@ export enum ExternalEditor {
Webstorm = 'JetBrains Webstorm',
Phpstorm = 'JetBrains Phpstorm',
NotepadPlusPlus = 'Notepad++',
Rider = 'JetBrains Rider',
}
```

Expand Down

0 comments on commit e5f8b5b

Please sign in to comment.