Skip to content

Commit 218d5f9

Browse files
authored
Merge pull request #89 from martindurant/pycharm
add pycharm plugin
2 parents 5ddbcb9 + 1ad2d0e commit 218d5f9

27 files changed

Lines changed: 2767 additions & 0 deletions

pycharm_plugin/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
.gradle
3+
.idea
4+
.intellijPlatform
5+
.kotlin
6+
.qodana
7+
build
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Run Plugin" type="GradleRunConfiguration" factoryName="Gradle">
3+
<log_file alias="IDE logs" path="$PROJECT_DIR$/build/idea-sandbox/*/log/idea.log" show_all="true" />
4+
<ExternalSystemSettings>
5+
<option name="executionName" />
6+
<option name="externalProjectPath" value="$PROJECT_DIR$/pycharm_plugin" />
7+
<option name="externalSystemIdString" value="GRADLE" />
8+
<option name="scriptParameters" value="" />
9+
<option name="taskDescriptions">
10+
<list />
11+
</option>
12+
<option name="taskNames">
13+
<list>
14+
<option value="runIde" />
15+
</list>
16+
</option>
17+
<option name="vmOptions" value="" />
18+
</ExternalSystemSettings>
19+
<ExternalSystemDebugServerProcess>false</ExternalSystemDebugServerProcess>
20+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
21+
<ExternalSystemDebugDisabled>false</ExternalSystemDebugDisabled>
22+
<DebugAllEnabled>false</DebugAllEnabled>
23+
<RunAsTest>false</RunAsTest>
24+
<GradleProfilingDisabled>false</GradleProfilingDisabled>
25+
<GradleCoverageDisabled>false</GradleCoverageDisabled>
26+
<method v="2" />
27+
</configuration>
28+
</component>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Run Tests" type="GradleRunConfiguration" factoryName="Gradle">
3+
<log_file alias="idea.log" path="$PROJECT_DIR$/build/idea-sandbox/system/log/idea.log" />
4+
<ExternalSystemSettings>
5+
<option name="executionName" />
6+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
7+
<option name="externalSystemIdString" value="GRADLE" />
8+
<option name="scriptParameters" value="" />
9+
<option name="taskDescriptions">
10+
<list />
11+
</option>
12+
<option name="taskNames">
13+
<list>
14+
<option value="check" />
15+
</list>
16+
</option>
17+
<option name="vmOptions" value="" />
18+
</ExternalSystemSettings>
19+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
20+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
21+
<DebugAllEnabled>false</DebugAllEnabled>
22+
<RunAsTest>true</RunAsTest>
23+
<method v="2" />
24+
</configuration>
25+
</component>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="Run Verifications" type="GradleRunConfiguration" factoryName="Gradle">
3+
<log_file alias="idea.log" path="$PROJECT_DIR$/build/idea-sandbox/system/log/idea.log" />
4+
<ExternalSystemSettings>
5+
<option name="executionName" />
6+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
7+
<option name="externalSystemIdString" value="GRADLE" />
8+
<option name="scriptParameters" value="" />
9+
<option name="taskDescriptions">
10+
<list />
11+
</option>
12+
<option name="taskNames">
13+
<list>
14+
<option value="verifyPlugin" />
15+
</list>
16+
</option>
17+
<option name="vmOptions" value="" />
18+
</ExternalSystemSettings>
19+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
20+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
21+
<DebugAllEnabled>false</DebugAllEnabled>
22+
<RunAsTest>false</RunAsTest>
23+
<method v="2" />
24+
</configuration>
25+
</component>

pycharm_plugin/CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!-- Keep a Changelog guide -> https://keepachangelog.com -->
2+
3+
# projspec PyCharm Plugin Changelog
4+
5+
## [Unreleased]
6+
7+
### Changed
8+
- UI re-implemented as the two-pane Library / Details layout described in
9+
`vsextension/ACTIONS.md`, reusing the VSCode extension's HTML, CSS and
10+
JavaScript verbatim inside JCEF.
11+
- All interactions (Add, Reload, Configure, search filter, kebab menu with
12+
Open-with / Rescan / Create spec / Remove from library, per-artifact Make
13+
and ℹ️ info popups) now flow through the same message bus as the VSCode
14+
panel.
15+
- Enum values in the YAML-style item tree are rendered by their member name.
16+
17+
### Added
18+
- "Configure" button that opens `$PROJSPEC_CONFIG_DIR/projspec.json`
19+
(creating a default if absent).
20+
- "Open with VSCode / system filebrowser / PyCharm / jupyter" launchers.
21+
- Reveal-in-project-view button for local file artifacts.
22+
23+
### Removed
24+
- Tools → Projspec menu actions (ShowLibrary, ProjspecScan, ShowProjectJson,
25+
ShowInfo, ShowItemDetails) — everything is now driven from the tool window.
26+
- Split-editor JSON viewer and HTML scan preview (replaced by the webview
27+
Details panel).
28+
29+
## [0.0.1]
30+
31+
### Added
32+
- Initial project scaffold created from [IntelliJ Platform Plugin Template](https://github.com/JetBrains/intellij-platform-plugin-template)
33+
34+
[Unreleased]: https://github.com/fsspec/projspec/compare/v0.0.1...HEAD
35+
[0.0.1]: https://github.com/fsspec/projspec/commits/v0.0.1

pycharm_plugin/README.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# projspec PyCharm Plugin
2+
3+
PyCharm integration for the [projspec](https://github.com/fsspec/projspec) CLI tool.
4+
5+
<!-- Plugin description -->
6+
PyCharm integration for the **projspec** CLI tool.
7+
8+
- Browse your **Project Library** in a dedicated sidebar tool window
9+
- **Add**, **Rescan** and **Remove** directories from the library
10+
- **Create** new spec types inside an existing project with autocomplete
11+
- **Make** individual artifacts in an interactive terminal tab
12+
- Open projects with VSCode, PyCharm, Jupyter Lab, or the system file browser
13+
- Edit the projspec configuration file with one click
14+
15+
Requires the `projspec` CLI. Configure the binary path under
16+
**Settings → Tools → Projspec**.
17+
<!-- Plugin description end -->
18+
19+
## Installation
20+
21+
1. Install the plugin from JetBrains Marketplace (search for `projspec`), or
22+
build from source with `./gradlew buildPlugin`.
23+
2. Open **Settings → Tools → Projspec** and set the path to your `projspec` binary
24+
(or leave as `projspec` if it is on your `PATH`).
25+
3. The **Project Library** tool window appears in the left sidebar.
26+
27+
## UI overview
28+
29+
The tool window has two panes, mirroring the VSCode extension described in
30+
[`vsextension/ACTIONS.md`](../vsextension/ACTIONS.md):
31+
32+
- **Library (left)** – a toolbar (*Add*, *Reload*, *Configure*), a filter
33+
field, and one widget per registered project. Each widget shows the
34+
project's basename, URL, storage options, and colour-coded chips for its
35+
*Contents*, *Artifacts* and spec types. A kebab menu offers *Open with
36+
VSCode / system filebrowser / PyCharm / jupyter*, *Rescan*, *Create spec*
37+
and *Remove from library*.
38+
- **Details (right)** – title, doc/link for the selected spec, and one
39+
card per content/artifact of the selected project. Artifact cards
40+
include a **Make** button (runs `projspec make …` in a terminal tab) and
41+
every card has an **ℹ️** info popup. Bodies render as a YAML-style
42+
collapsible tree, with enum values shown by their member name.
43+
44+
## Development
45+
46+
### Prerequisites
47+
48+
- JDK 21
49+
- Gradle 9.x (the Gradle Wrapper is included)
50+
51+
### Run configurations
52+
53+
After opening the project in IntelliJ IDEA, three pre-configured run configurations
54+
are available from the `.run/` directory:
55+
56+
| Configuration | Gradle task | Description |
57+
|---|---|---|
58+
| **Run Plugin** | `runIde` | Launch a sandboxed PyCharm instance with the plugin loaded. Use the Debug icon for breakpoint debugging. |
59+
| **Run Tests** | `check` | Run all unit tests and generate a Kover coverage report. |
60+
| **Run Verifications** | `verifyPlugin` | Run the IntelliJ Plugin Verifier to check compatibility against the target IDE range. |
61+
62+
### Build
63+
64+
```bash
65+
./gradlew buildPlugin # produces build/distributions/projspec-pycharm-*.zip
66+
./gradlew runIde # launch sandboxed PyCharm
67+
./gradlew check # run tests + coverage
68+
./gradlew verifyPlugin # plugin compatibility check
69+
./gradlew publishPlugin # publish to JetBrains Marketplace (requires secrets)
70+
```
71+
72+
### Environment variables (for signing & publishing)
73+
74+
| Variable | Purpose |
75+
|---|---|
76+
| `PRIVATE_KEY` | RSA private key for plugin signing |
77+
| `PRIVATE_KEY_PASSWORD` | Password for the private key |
78+
| `CERTIFICATE_CHAIN` | Certificate chain for plugin signing |
79+
| `PUBLISH_TOKEN` | JetBrains Marketplace publish token |
80+
81+
## Architecture
82+
83+
This plugin is a Kotlin port of the VSCode `projspec` extension
84+
(`vsextension/`). The HTML/CSS/JavaScript that draws the two-pane UI is
85+
**reused verbatim** from the VSCode webview – the only changes needed for
86+
JCEF are:
87+
88+
1. `acquireVsCodeApi().postMessage(msg)``window.__javaBridge.query(JSON.stringify(msg))`
89+
(the bridge is a `JBCefJSQuery` registered from Kotlin).
90+
2. `panel.webview.postMessage(msg)``window.__projspecDeliver(msg)`
91+
(Kotlin calls this via `executeJavaScript` because JCEF does not deliver
92+
host→frame `message` events the way VSCode does).
93+
3. A `:root { --vscode-*: … }` block is prepended to the stylesheet so the
94+
VSCode theme variables map to Darcula-ish colours.
95+
96+
Key type mapping between the two implementations:
97+
98+
| VSCode concept | PyCharm equivalent |
99+
|-------------------------------|--------------------------------------------------------|
100+
| `createWebviewPanel` | `JBCefBrowser` (JCEF/Chromium) |
101+
| `acquireVsCodeApi()` | `JBCefJSQuery` (`window.__javaBridge`) |
102+
| `panel.webview.postMessage` | `executeJavaScript("window.__projspecDeliver(…)")` |
103+
| `commands.registerCommand` | Tool-window message dispatch |
104+
| `showOpenDialog` | `FileChooser.chooseFile` with a folder descriptor |
105+
| `workspace.openTextDocument` | `FileEditorManager.openFile` + `LocalFileSystem` |
106+
| `createTerminal` / `sendText` | `TerminalToolWindowManager` (via reflection) |
107+
| `child_process.spawn` | `GeneralCommandLine` + `CapturingProcessHandler` |
108+
| `showErrorMessage` | Balloon notification via the `Projspec` group |
109+
110+
### Source layout
111+
112+
```
113+
src/main/kotlin/com/projspec/
114+
toolwindow/
115+
HtmlContent.kt — the full HTML/CSS/JS page (reused verbatim
116+
from vsextension/src/panel.ts)
117+
ProjspecToolWindowFactory.kt — registers the tool window
118+
ProjspecToolWindowPanel.kt — Kotlin side of the JS↔Java bridge,
119+
mirrors panel.ts's message handlers
120+
util/
121+
ProjspecRunner.kt — all `projspec …` subprocess invocations
122+
TerminalRunner.kt — `projspec make …` in a terminal tab
123+
OpenWithHelper.kt — "Open with …" kebab-menu actions
124+
Notifier.kt — balloon notification helpers
125+
CliResult.kt — Success/Failure result type
126+
settings/
127+
ProjspecSettings.kt — persistent cliPath setting
128+
ProjspecSettingsConfigurable.kt — Settings → Tools → Projspec UI
129+
```
130+
131+
## License
132+
133+
Apache 2.0 — see [LICENSE](https://github.com/fsspec/projspec/blob/main/LICENSE).

0 commit comments

Comments
 (0)