diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index f247eb5..45b705e 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -1,10 +1,16 @@ name: "Validate Gradle Wrapper" -on: [ push, pull_request ] +on: + push: + branches: [master] + pull_request: + +permissions: + contents: read jobs: validation: name: "Validation" - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v2 - - uses: gradle/wrapper-validation-action@v1 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + - uses: gradle/actions/wrapper-validation@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index d631dd9..cd7ee52 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,19 +1,24 @@ name: Main -on: [ push, pull_request ] +on: + push: + branches: [master] + pull_request: + +permissions: + contents: read jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v1 - - name: Set up JDK 1.11 - uses: actions/setup-java@v1 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + - name: Set up JDK 21 + uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1 with: - java-version: 1.11 - - name: Test - run: ./gradlew test - - name: Build with Gradle - run: ./gradlew buildPlugin + distribution: corretto + java-version: 21 + - name: Test, build and verify compatibility + run: xvfb-run -a ./gradlew test build buildPlugin verifyPlugin diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..1bcece4 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,5 @@ +# Development + +Use the globally installed `develop-intellij-plugin` skill for every development task. +Read `docs/workflow.md` for repository configuration. Retrieve operational state through the shared skill. +`CHANGES.md` records release history; this repository contains no local task queue. diff --git a/CHANGES.md b/CHANGES.md index 7957ba5..5ceacd9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,10 @@ +## 2026.0 (Unreleased) + +* Double-clicking a mapping category leaves its mappings unchanged instead of crashing the settings page. +* Custom mapping values and categories survive saving and loading IDE settings. +* JSON exports retain the plugin version on newer IDEs without using obsolete plugin lookup APIs. +* Source builds use updated build tooling and the latest PyCharm 2025.1 maintenance SDK, including upstream security fixes. Installed IDEs must still receive their own JetBrains updates. + ## 2025.2 (September 05, 2025) * Update dependencies diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..1bcece4 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +# Development + +Use the globally installed `develop-intellij-plugin` skill for every development task. +Read `docs/workflow.md` for repository configuration. Retrieve operational state through the shared skill. +`CHANGES.md` records release history; this repository contains no local task queue. diff --git a/README.md b/README.md index 30542b7..ab6c036 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Prettify Python Plugin +The source branch prepares 2026.0; Marketplace currently provides 2025.2. IDE 2024.3 and later remain supported. + [![JetBrains IntelliJ Plugins](https://img.shields.io/jetbrains/plugin/r/stars/12017?label=JetBrans%20Marketplace)](https://plugins.jetbrains.com/plugin/12017) [![JetBrains IntelliJ plugins](https://img.shields.io/jetbrains/plugin/d/12017)](https://plugins.jetbrains.com/plugin/12017) [![Twitter Follow](https://img.shields.io/twitter/follow/meanmaildev?style=plastic)](https://twitter.com/meanmaildev) diff --git a/build.gradle.kts b/build.gradle.kts index cb98d15..45cbc9c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,6 +9,7 @@ repositories { intellijPlatform { defaultRepositories() + jetbrainsRuntime() } } @@ -27,7 +28,10 @@ dependencies { testImplementation(libs.junit) intellijPlatform { - create(config("platformType"), config("platformVersion")) + create(config("platformType"), config("platformVersion")) { + useInstaller = false + } + jetbrainsRuntime() val plugins = providers.gradleProperty("plugins").map { it.split(',') } if (plugins.isPresent && plugins.get().isNotEmpty()) { plugins(plugins) @@ -57,6 +61,9 @@ intellijPlatform { buildSearchableOptions = false pluginVerification.ides { + create("PC", "2024.3.6.1") { + useInstaller = false + } recommended() } @@ -119,8 +126,18 @@ tasks { gradleVersion = config("gradleVersion") } + processResources { + val resourcePluginVersion = project.version.toString() + inputs.property("pluginVersion", resourcePluginVersion) + filesMatching("prettify-python-version.txt") { + expand("pluginVersion" to resourcePluginVersion) + } + } + test { useJUnit() + systemProperty("java.awt.headless", "false") + testLogging.exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL maxHeapSize = "1G" } diff --git a/docs/dependencies-2026-11.md b/docs/dependencies-2026-11.md new file mode 100644 index 0000000..c4768f5 --- /dev/null +++ b/docs/dependencies-2026-11.md @@ -0,0 +1,34 @@ +# November 2026 dependency maintenance + +| Input | Previous | Selected | Decision | +| --- | --- | --- | --- | +| Gradle Wrapper | 9.0.0 | 9.8.2 | Apply supported Gradle 9 fixes, including worker/daemon deserialization, repository TLS handling, dependency resolution and dependency-alignment reporting fixes. Preserve JVM 21 and configuration-cache settings. | +| IntelliJ Platform Gradle plugin | 2.9.0 | 2.19.0 | Apply current test/classpath, IDE resolution and verifier fixes. In particular, newer plugin versions correctly map Community verification targets to unified PyCharm for 2025.3+. | +| Compilation SDK | PC 2025.1 | PC 2025.1.6.2 | Apply the latest published maintenance release in the existing SDK branch. JetBrains' release metadata includes CVE-2026-59792. This SDK is used for source builds, not shipped as an IDE update. | +| Kotlin | 2.0.21 | 2.0.21 | Preserve the IDE 2024.3 Kotlin runtime boundary rather than unconditionally selecting a newer compiler. | +| kotlinx.serialization | 1.8.1 | 1.8.1 | Preserve the existing JSON format/runtime input during the category-editing repair; a newer runtime must first satisfy the IDE floor. | +| JUnit | 4.13.2 | 4.13.2 | Retain the current JUnit 4 release used by IDE fixtures. | +| actions/checkout | v1 / v2 | v7, immutable SHA | Apply current supported action runtime and authentication handling. | +| actions/setup-java | v1 | v6.0.1, immutable SHA | Apply current action runtime and explicitly select JDK 21, matching the existing JVM target. | +| Wrapper validation | legacy v1 action | gradle/actions v6.3.0, immutable SHA | Apply the maintained validation action. | + +The IntelliJ Gradle 2.14 defaults do not change this project's explicit minimum IDE build or verifier +configuration. Its optional signing/publishing environment defaults do not authorize those tasks; +the workflows execute neither. The 2.19 classpath exclusions and per-IDE verifier runtimes are +accepted; explicit Java/Kotlin bytecode targets remain 21. No removed `setupDependencies` task, +GrammarKit generator, native variant or subscription-key feature is used here. + +Newer Kotlin and serialization release lines are excluded from this bounded maintenance because +the plugin retains its IDE 2024.3 floor. No new paid feature, user-project dependency or JSON migration +is introduced. The build-only security fixes do not repair vulnerabilities in a user's installed IDE. + +The 2025.1.6.2 Community SDK is resolved from the official multi-OS Maven archive with its matching JBR. +The installer resolver could not select this four-component maintenance version even though its official +download and Maven artifact exist. This changes artifact resolution, not the platform version or IDE floor. + +Sources: [Gradle 9.8.2 notes](https://docs.gradle.org/9.8.2/release-notes.html), +[Gradle 9 migration guide](https://docs.gradle.org/current/userguide/upgrading_version_9.html), +[IntelliJ Gradle release history](https://github.com/JetBrains/intellij-platform-gradle-plugin/releases), +[PyCharm 2025.1.6.2 notes](https://youtrack.jetbrains.com/articles/PY-A-233538593/PyCharm-2025.1.6.2-251.29188.66-build-Release-Notes), +[JetBrains release metadata](https://data.services.jetbrains.com/products/releases?code=PCC&latest=false&type=release), +[IDE Kotlin requirements](https://plugins.jetbrains.com/docs/intellij/using-kotlin.html). diff --git a/docs/workflow.md b/docs/workflow.md new file mode 100644 index 0000000..f994e4a --- /dev/null +++ b/docs/workflow.md @@ -0,0 +1,69 @@ +# Workflow configuration + +The globally installed `develop-intellij-plugin` skill defines the development process. + +## Project + +- Prettify Python, a Free Python symbol-folding plugin with configurable mappings. +- Repository: `meanmail-dev/prettify-python-plugin`; authoritative ref: `origin/master`. +- Release authority: `https://plugins.jetbrains.com/plugins/list?pluginId=ru.meanmail.plugins.prettify-python`. +- Product history and notes: `CHANGES.md`; descriptions: `README.md` and `description.html`. +- Version syntax: year.minor; next major after published `2025.2` is `2026.0`. + Update `gradle.properties` and add a top unreleased `CHANGES.md` section for a behavior change. + No paid product descriptor or release date field is configured. +- External portfolio registration: Not configured. Local task queue and roadmap: Not configured. + +## Verification + +- CI-required: `xvfb-run -a ./gradlew test build buildPlugin verifyPlugin` on GitHub-hosted Ubuntu 24.04, + using JDK 21. Gradle resolves dependencies before executing the gate. This repository is public; + the organization's private runners intentionally do not accept public repositories. + Swing settings tests use a virtual display; the test JVM explicitly disables headless mode. +- CI-required: Gradle Wrapper validation in `gradle-wrapper-validation.yml`. +- Local-diagnostic dependency resolution: `./gradlew dependencies` before a focused local Gradle check. +- Local-diagnostic focused test: `./gradlew test --tests "dev.meanmail.prettifypython.settings.PrettifySettingsComponentTest"`. +- Local-required: `git diff --check`, changed XML parsing, official wrapper distribution/JAR checksum checks. +- Local-required native package: `./gradlew buildPlugin` when CI has no retained distribution. + Use the configured PyCharm 2025.1.6.2 SDK and JDK 21; newer SDKs can require a newer Kotlin compiler. + Record the native package hash. A locally built artifact is not the CI binary. + With a previously running Kotlin daemon on JDK 25, use JDK 21 and + `-Pkotlin.compiler.execution.strategy=in-process` for package preparation. +- The verifier explicitly covers the IDE 243 floor (PC 2024.3.6.1) in addition to recommended current IDEs. +- Separate lint/typecheck commands and generated sources: Not configured. +- Never run `gradlew clean` without the owner's permission. + +## Native Remote Development + +- Owner: Local-required through the shared `ide-test-mcp` installation. A reviewed isolated installation + of the same implementation can qualify a required adapter while preserving a dirty local checkout. +- Runtime: unmodified IDEA 2025.3.6, build 253.33813.25, bundled JBR 21, macOS arm64; + the controller itself uses the installed JDK 25 and its matching 253 Driver/agent. +- Official PythonCore 253.33813.55 belongs on the backend; Python for JetBrains Client + 253.30387.20 (`com.intellij.python.frontend`) belongs on the frontend. +- Product placement: backend. Use isolated localhost monolith/split fixtures with 1024 MiB heaps. +- Fixture: a synthetic Python file with foldable operators and a separate ordinary text file. + Verify native settings category editing, individual mapping editing/cancellation, mapping persistence, + useful folding, repeat use, exact source Save/Undo/Redo, close/reopen and same-client reconnect. +- On macOS IDE 253, open the native Settings menu entry and observe the `Settings` dialog. Locate the + Prettify Python page through its search field. Use `tree_activate` for category double-clicks; individual + mappings can be selected and opened with the actual Edit toolbar button. The runner's `open_dialog` + tree selector sends one click. Confirm applied values in the owned settings XML as well as the UI. +- These Swing tree controls belong to the monolithic UI. The 253 split frontend mirrors the page through + a Lux panel: use an observed `lux_render` image and its fresh one-use token for `lux_click`, and the + Lux `open_dialog` selector for Edit Mapping. Verify the visible remote dialog and cancellation; + backend semantic clicks alone do not establish frontend pointer forwarding. +- Compare the absent-product ordinary-editor control. Warm up for 60 seconds and sample each JVM for + 30 seconds; CPU below 20% of one core, backend/monolith RSS below 4 GiB, frontend below 2 GiB. +- Require at least 4 GiB free before package preparation/launch. Retain package hashes, scoped logs, + native operation results and resource observations in the private task evidence. + +## Publication and invariants + +- Candidate branches may be pushed for approved work. Publish reviewed exact-head-green changes through a PR + into `master`, assigned to the owner. A merge runs the same verification as its PR; these workflows contain + no signing, publication, release, deployment or artifact upload lane. Inspect the actual workflows before + reusing tree-equivalent candidate evidence. Marketplace publication always needs separate approval. +- Preserve the IDE 2024.3 floor, JVM 21, optional Python integration, Free mappings, JSON compatibility, + folding semantics and source bytes. Use `ApplicationManager` scheduling for IDE thread transitions. +- Repository-specific verification improvements belong here and in the existing workflows/tests, using the + same reviewed publication path. Shared-process improvements belong to the globally installed skill source. diff --git a/gradle.properties b/gradle.properties index 44df355..05b6015 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Gradle -gradleVersion=9.0.0 +gradleVersion=9.8.2 org.gradle.parallel=true # Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html org.gradle.configuration-cache=true @@ -12,14 +12,14 @@ jvmVersion=21 group=dev.meanmail repository=https://github.com/meanmail-dev/prettify-python-plugin pluginName=Prettify python -version=2025.2 +version=2026.0 # https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library kotlin.stdlib.default.dependency=false # # Platform platformSinceBuild=243 # Develop platform -platformVersion=2025.1 +platformVersion=2025.1.6.2 platformType=PC #plugins= platformBundledPlugins=PythonCore diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5c942f8..ea06b9e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ junit = "4.13.2" kotlinxSerialization = "1.8.1" # plugins -intelliJPlatform = "2.9.0" +intelliJPlatform = "2.19.0" # https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#kotlin-standard-library kotlin = "2.0.21" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 1b33c55..9fa7f28 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 48b43d3..5907d39 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,10 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-all.zip +distributionSha256Sum=21bd5da2de49b642904077f38c0efdc7778e92b3ed0889392dca61b97e389607 +distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-bin.zip networkTimeout=10000 +retries=0 +retryBackOffMs=500 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 23d15a9..249efbb 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ ############################################################################## # -# Gradle start up script for POSIX generated by Gradle. +# gradlew start up script for POSIX generated by Gradle. # # Important for running: # @@ -29,7 +29,7 @@ # bash, then to run this script, type that shell name before the whole # command line, like: # -# ksh Gradle +# ksh gradlew # # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -114,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -172,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" diff --git a/gradlew.bat b/gradlew.bat index db3a6ac..3185a43 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -19,12 +19,39 @@ @if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem -@rem Gradle startup script for Windows +@rem gradlew startup script for Windows @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +@rem Catch executions from older scripts and ensure they exit cleanly. +@rem This can be removed once we can be reasonably confident that few people +@rem will be migrating directly to this new wrapper. +goto afterSafetyNet +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +goto exitWithErrorLevel +:afterSafetyNet set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -45,13 +72,14 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 +1>&2 echo. +1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +1>&2 echo. +1>&2 echo Please set the JAVA_HOME variable in your environment to match the +1>&2 echo location of your Java installation. -goto fail +"%COMSPEC%" /c exit 1 +goto exitWithErrorLevel :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -59,36 +87,26 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 +1>&2 echo. +1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +1>&2 echo. +1>&2 echo Please set the JAVA_HOME variable in your environment to match the +1>&2 echo location of your Java installation. -goto fail +"%COMSPEC%" /c exit 1 +goto exitWithErrorLevel :execute @rem Setup the command line -set CLASSPATH= -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* +@rem Execute gradlew +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem This label must not be changed. We rely on old scripts being able to jump to this point. +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/src/main/kotlin/dev/meanmail/prettifypython/settings/MappingEntry.kt b/src/main/kotlin/dev/meanmail/prettifypython/settings/MappingEntry.kt index 033063b..359222a 100644 --- a/src/main/kotlin/dev/meanmail/prettifypython/settings/MappingEntry.kt +++ b/src/main/kotlin/dev/meanmail/prettifypython/settings/MappingEntry.kt @@ -4,7 +4,7 @@ import kotlinx.serialization.Serializable @Serializable data class MappingEntry( - val from: String = "", - val to: String = "", - val category: String = "" + var from: String = "", + var to: String = "", + var category: String = "" ) diff --git a/src/main/kotlin/dev/meanmail/prettifypython/settings/PrettifySettingsComponent.kt b/src/main/kotlin/dev/meanmail/prettifypython/settings/PrettifySettingsComponent.kt index 992676c..f36f0d5 100644 --- a/src/main/kotlin/dev/meanmail/prettifypython/settings/PrettifySettingsComponent.kt +++ b/src/main/kotlin/dev/meanmail/prettifypython/settings/PrettifySettingsComponent.kt @@ -1,12 +1,10 @@ package dev.meanmail.prettifypython.settings import com.intellij.icons.AllIcons -import com.intellij.ide.plugins.PluginManagerCore import com.intellij.openapi.actionSystem.ActionToolbarPosition import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.application.ApplicationInfo -import com.intellij.openapi.extensions.PluginId import com.intellij.openapi.ui.ComboBox import com.intellij.openapi.ui.DialogWrapper import com.intellij.openapi.ui.Messages @@ -95,7 +93,7 @@ class PrettifySettingsComponent { } private fun editMapping(node: DefaultMutableTreeNode) { - val mapping = node.userObject as MappingEntry + val mapping = node.userObject as? MappingEntry ?: return val existingCategories = getAllCategories() val dialog = MappingDialog(mainPanel, "Edit Mapping", mapping, existingCategories) if (dialog.showAndGet()) { @@ -266,16 +264,15 @@ class PrettifySettingsComponent { if (fileChooser.showSaveDialog(mainPanel) == JFileChooser.APPROVE_OPTION) { try { val mappings = getMappings() - val pluginId = PluginId.findId("ru.meanmail.plugins.prettify-python") - ?: throw IllegalStateException("Plugin ID not found") - val plugin = PluginManagerCore.getPlugin(pluginId) - ?: throw IllegalStateException("Plugin not found") + val pluginVersion = requireNotNull( + javaClass.getResourceAsStream("/prettify-python-version.txt") + ) { "Plugin version resource not found" }.bufferedReader().use { it.readText().trim() } val now = LocalDateTime.now(ZoneOffset.UTC) val mappingsData = MappingsData( mappings = mappings, ideVersion = ApplicationInfo.getInstance().fullVersion, - pluginVersion = plugin.version, + pluginVersion = pluginVersion, mappingsCount = mappings.size, exportDate = now.toString() ) diff --git a/src/main/resources/prettify-python-version.txt b/src/main/resources/prettify-python-version.txt new file mode 100644 index 0000000..9f9d531 --- /dev/null +++ b/src/main/resources/prettify-python-version.txt @@ -0,0 +1 @@ +${pluginVersion} diff --git a/src/test/kotlin/dev/meanmail/prettifypython/settings/PrettifySettingsComponentTest.kt b/src/test/kotlin/dev/meanmail/prettifypython/settings/PrettifySettingsComponentTest.kt new file mode 100644 index 0000000..75c7d46 --- /dev/null +++ b/src/test/kotlin/dev/meanmail/prettifypython/settings/PrettifySettingsComponentTest.kt @@ -0,0 +1,39 @@ +package dev.meanmail.prettifypython.settings + +import com.intellij.testFramework.ApplicationRule +import com.intellij.testFramework.EdtTestUtil +import org.junit.Assert.assertEquals +import org.junit.Rule +import org.junit.Test +import javax.swing.tree.DefaultMutableTreeNode + +class PrettifySettingsComponentTest { + @get:Rule + val application = ApplicationRule() + + @Test + fun editingCategoryDoesNotCastItsNameToMappingEntry() { + assertNonMappingEditIsIgnored("Mathematical operators") + } + + @Test + fun editingRootDoesNotOpenMappingDialog() { + assertNonMappingEditIsIgnored("Mappings") + } + + private fun assertNonMappingEditIsIgnored(label: String) { + EdtTestUtil.runInEdtAndWait { + val component = PrettifySettingsComponent() + component.setMappings(listOf( + MappingEntry("**", "^", "Mathematical operators"), + MappingEntry("!=", "≠", "Comparison operators"), + )) + val mappings = component.getMappings() + val method = PrettifySettingsComponent::class.java + .getDeclaredMethod("editMapping", DefaultMutableTreeNode::class.java) + method.isAccessible = true + method.invoke(component, DefaultMutableTreeNode(label)) + assertEquals("non-mapping nodes must leave every mapping intact", mappings, component.getMappings()) + } + } +} diff --git a/src/test/kotlin/dev/meanmail/prettifypython/settings/PrettifySettingsPersistenceTest.kt b/src/test/kotlin/dev/meanmail/prettifypython/settings/PrettifySettingsPersistenceTest.kt new file mode 100644 index 0000000..a0a9d01 --- /dev/null +++ b/src/test/kotlin/dev/meanmail/prettifypython/settings/PrettifySettingsPersistenceTest.kt @@ -0,0 +1,22 @@ +package dev.meanmail.prettifypython.settings + +import com.intellij.util.xmlb.XmlSerializer +import org.junit.Assert.assertEquals +import org.junit.Test + +class PrettifySettingsPersistenceTest { + @Test + fun customMappingsSurviveXmlRoundTrip() { + val expected = PrettifySettings.State( + mappings = listOf(MappingEntry("**", "pow", "Custom operators")), + categories = setOf("Custom operators"), + ) + + val restored = XmlSerializer.deserialize( + XmlSerializer.serialize(expected), PrettifySettings.State::class.java, + ) + + assertEquals(expected.mappings, restored.mappings) + assertEquals(expected.categories, restored.categories) + } +}