diff --git a/.gitignore b/.gitignore index 031c751..819ef1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,115 @@ -.DS_Store -.idea -out \ No newline at end of file + +# macOS.gitignore + +# General +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +# JetBrains.gitignore + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + + + +# Java.gitignore + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# codestyles, markdown +/.idea/codeStyles/codeStyleConfig.xml +/.idea/markdown-navigator/profiles_settings.xml +/.idea/markdown-navigator.xml diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..05eca02 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/.run/Run Plugin.run.xml b/.run/Run Plugin.run.xml new file mode 100644 index 0000000..9db62fb --- /dev/null +++ b/.run/Run Plugin.run.xml @@ -0,0 +1,25 @@ + + + + + + + + false + true + false + false + + + \ No newline at end of file diff --git a/.run/Run Tests.run.xml b/.run/Run Tests.run.xml new file mode 100644 index 0000000..f281bdc --- /dev/null +++ b/.run/Run Tests.run.xml @@ -0,0 +1,25 @@ + + + + + + + + true + true + false + true + + + diff --git a/.run/Run Verifications.run.xml b/.run/Run Verifications.run.xml new file mode 100644 index 0000000..32783f5 --- /dev/null +++ b/.run/Run Verifications.run.xml @@ -0,0 +1,25 @@ + + + + + + + + true + true + false + false + + + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eacce5..c9e6b27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,66 +1,70 @@ -# Camel Case Plugin + -## Changelog +# Camel Case Changelog -### Release 3.0.12: -* Bugfix: use standard config if com.intellij.openapi.project.Project is null +## [3.0.13] - 2026-03-06 -### Release 3.0.11: -* Bugfix: if only camelCase and snake_case is selected in the options +- Fixed bug with multiple careats -### Release 3.0.10: -* Single word bugfix (Foo => FOO => foo) -* Pascal Case with space bugfix (foo foo => Foo Foo) +## [3.0.12] +- Bugfix: use standard config if com.intellij.openapi.project.Project is null -### Release 3.0.9: -* New Conversion added (Camel Case) +## [3.0.11] +- Bugfix: if only camelCase and snake_case is selected in the options -### Release 3.0.7: -* Support any text field and editor +## [3.0.10] +- Single word bugfix (Foo => FOO => foo) +- Pascal Case with space bugfix (foo foo => Foo Foo) -### Release 3.0.6: -* Fixed snake case bug -* Need IntelliJ Platform version higher than 191.4212.41 +## [3.0.9] +- New Conversion added (Camel Case) -### Release 3.0.5: -* Fix for string in lower case +## [3.0.7] +- Support any text field and editor -### Release 3.0.4: -* Select whole string with dashes +## [3.0.6] +- Fixed snake case bug +- Need IntelliJ Platform version higher than 191.4212.41 -### Release 3.0.3: -* Fixed conversion with special char +## [3.0.5] +- Fix for string in lower case -### Release 3.0.2: -* Fixed deprecated function +## [3.0.4] +- Select whole string with dashes -### Release 3.0.1: -* Restore multiple caret mode (see #2) +## [3.0.3] +- Fixed conversion with special char -### Release 3.0: -* Allow to use plugin in dialogs (like refactor/rename) +## [3.0.2] +- Fixed deprecated function -### Release 2.1: -* Introduce "space case" and allow to change conversion order in configuration. +## [3.0.1] +- Restore multiple caret mode (see #2) -### Release 2.0: -* Introduce config panel to switch off certain transformations (Preferences / Editor / Camel Case) +## [3.0.0] +- Allow to use plugin in dialogs (like refactor/rename) -### Release 1.6: -* Bugfix: double underscore (thanks to John) +## [2.1.0] +- Introduce "space case" and allow to change conversion order in configuration. -### Release 1.5: -* added hyphen-separated-notation +## [2.0.0] +- Introduce config panel to switch off certain transformations (Preferences / Editor / Camel Case) -### Release 1.4: -* optimized multiple caret support -* idea 14.1 is now required, please use release 1.2 for older IDEs +## [1.6.0] +- Bugfix: double underscore (thanks to John) -### Release 1.3: -* multiple selections support +## [1.5.0] +- added hyphen-separated-notation -### Release 1.2: -* Compiled for J2SE 6.0 +## [1.4.0] +- optimized multiple caret support +- idea 14.1 is now required, please use release 1.2 for older IDEs -### Release 1.1: -* Added undo functionality \ No newline at end of file +## [1.3.0] +- multiple selections support + +## [1.2.0] +- Compiled for J2SE 6.0 + +## [1.1.0] +- Added undo functionality diff --git a/README.md b/README.md index fd3dfe2..68e8bfe 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # Camel Case Plugin CamelCasePlugin for IntelliJ IDEs (e.g. PhpStorm, IntelliJ IDEA, ...) @@ -13,4 +14,5 @@ Please see this example for a demonstration: Use your IDE. Preferences/Plugins/Browse repositories and search for "camelcase". ## Build -Just clone this repo and open the project it in IntelliJ IDEA. \ No newline at end of file +Just clone this repo and open the project it in IntelliJ IDEA. + diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..9d61ab8 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,160 @@ +import org.jetbrains.changelog.Changelog +import org.jetbrains.changelog.markdownToHTML +import org.jetbrains.intellij.platform.gradle.TestFrameworkType + +plugins { + id("java") // Java support + alias(libs.plugins.kotlin) // Kotlin support + alias(libs.plugins.intelliJPlatform) // IntelliJ Platform Gradle Plugin + alias(libs.plugins.changelog) // Gradle Changelog Plugin + alias(libs.plugins.qodana) // Gradle Qodana Plugin + alias(libs.plugins.kover) // Gradle Kover Plugin +} + +group = providers.gradleProperty("pluginGroup").get() +version = providers.gradleProperty("pluginVersion").get() + +// Set the JVM language level used to build the project. +kotlin { + jvmToolchain(21) +} + +// Configure project's dependencies +repositories { + mavenCentral() + + // IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html + intellijPlatform { + defaultRepositories() + } +} + +// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/version_catalogs.html +dependencies { + testImplementation(libs.junit) + testImplementation(libs.opentest4j) + + // IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html + intellijPlatform { + intellijIdea(providers.gradleProperty("platformVersion")) + + // Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins. + bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') }) + + // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace. + plugins(providers.gradleProperty("platformPlugins").map { it.split(',') }) + + // Module Dependencies. Uses `platformBundledModules` property from the gradle.properties file for bundled IntelliJ Platform modules. + bundledModules(providers.gradleProperty("platformBundledModules").map { it.split(',') }) + + testFramework(TestFrameworkType.Platform) + } +} + +// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html +intellijPlatform { + pluginConfiguration { + name = providers.gradleProperty("pluginName") + version = providers.gradleProperty("pluginVersion") + + // Extract the section from README.md and provide for the plugin's manifest + description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map { + val start = "" + val end = "" + + with(it.lines()) { + if (!containsAll(listOf(start, end))) { + throw GradleException("Plugin description section not found in README.md:\n$start ... $end") + } + subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML) + } + } + + val changelog = project.changelog // local variable for configuration cache compatibility + // Get the latest available change notes from the changelog file + changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion -> + with(changelog) { + renderItem( + (getOrNull(pluginVersion) ?: getUnreleased()) + .withHeader(false) + .withEmptySections(false), + Changelog.OutputType.HTML, + ) + } + } + + ideaVersion { + sinceBuild = providers.gradleProperty("pluginSinceBuild") + } + } + + signing { + certificateChain = providers.environmentVariable("CERTIFICATE_CHAIN") + privateKey = providers.environmentVariable("PRIVATE_KEY") + password = providers.environmentVariable("PRIVATE_KEY_PASSWORD") + } + + publishing { + token = providers.environmentVariable("PUBLISH_TOKEN") + // The pluginVersion is based on the SemVer (https://semver.org) and supports pre-release labels, like 2.1.7-alpha.3 + // Specify pre-release label to publish the plugin in a custom Release Channel automatically. Read more: + // https://plugins.jetbrains.com/docs/intellij/publishing-plugin.html#specifying-a-release-channel + channels = providers.gradleProperty("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) } + } + + pluginVerification { + ides { + recommended() + } + } +} + +// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin +changelog { + groups.empty() + repositoryUrl = providers.gradleProperty("pluginRepositoryUrl") + versionPrefix = "" +} + +// Configure Gradle Kover Plugin - read more: https://kotlin.github.io/kotlinx-kover/gradle-plugin/#configuration-details +kover { + reports { + total { + xml { + onCheck = true + } + } + } +} + +tasks { + wrapper { + gradleVersion = providers.gradleProperty("gradleVersion").get() + } + + publishPlugin { + dependsOn(patchChangelog) + } + +} + +intellijPlatformTesting { + runIde { + register("runIdeForUiTests") { + task { + jvmArgumentProviders += CommandLineArgumentProvider { + listOf( + "-Drobot-server.port=8082", + "-Dide.mac.message.dialogs.as.sheets=false", + "-Djb.privacy.policy.text=", + "-Djb.consents.confirmation.enabled=false", + ) + } + } + + plugins { + robotServerPlugin() + } + } + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..f8cf08a --- /dev/null +++ b/gradle.properties @@ -0,0 +1,33 @@ +# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html + +pluginGroup = de.netnexus.camelcaseplugin +pluginName = CamelCase +pluginRepositoryUrl = https://github.com/JetBrains/intellij-platform-plugin-template +# SemVer format -> https://semver.org +pluginVersion =3.0.13 + +# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html +pluginSinceBuild = 253 + +# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension +platformVersion = 2025.3.3 + +# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html +# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP +platformPlugins = +# Example: platformBundledPlugins = com.intellij.java +platformBundledPlugins = +# Example: platformBundledModules = intellij.spellchecker +platformBundledModules = + +# Gradle Releases -> https://github.com/gradle/gradle/releases +gradleVersion = 9.3.1 + +# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib +kotlin.stdlib.default.dependency = false + +# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html +org.gradle.configuration-cache = true + +# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html +org.gradle.caching = true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..efcd141 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,22 @@ +[versions] +# libraries +junit = "4.13.2" +opentest4j = "1.3.0" + +# plugins +changelog = "2.5.0" +intelliJPlatform = "2.11.0" +kotlin = "2.3.0" +kover = "0.9.5" +qodana = "2025.3.1" + +[libraries] +junit = { group = "junit", name = "junit", version.ref = "junit" } +opentest4j = { group = "org.opentest4j", name = "opentest4j", version.ref = "opentest4j" } + +[plugins] +changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } +intelliJPlatform = { id = "org.jetbrains.intellij.platform", version.ref = "intelliJPlatform" } +kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } +qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..37f78a6 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..adff685 --- /dev/null +++ b/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# 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. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# 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 +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..c4bdd3a --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,93 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +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 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +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 + +goto fail + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +: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 diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..ef95a72 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,5 @@ +rootProject.name = "CamelCase" + +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" +} diff --git a/src/de/netnexus/CamelCasePlugin/ToggleCamelCase.java b/src/de/netnexus/CamelCasePlugin/ToggleCamelCase.java deleted file mode 100644 index 6b70e61..0000000 --- a/src/de/netnexus/CamelCasePlugin/ToggleCamelCase.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.netnexus.CamelCasePlugin; - -import com.intellij.openapi.editor.actions.TextComponentEditorAction; - -/** - * Switch between snake_case, SNAKE_CASE, SnakeCase, snakeCase. - */ -public class ToggleCamelCase extends TextComponentEditorAction { - - public ToggleCamelCase() { - super(new CamelCaseEditorActionHandler<>()); - } - -} diff --git a/src/main/java/de/netnexus/camelcase/action/ToggleCamelCaseAction.java b/src/main/java/de/netnexus/camelcase/action/ToggleCamelCaseAction.java new file mode 100644 index 0000000..42f6d73 --- /dev/null +++ b/src/main/java/de/netnexus/camelcase/action/ToggleCamelCaseAction.java @@ -0,0 +1,21 @@ +package de.netnexus.camelcase.action; + +import com.intellij.openapi.actionSystem.Presentation; +import com.intellij.openapi.editor.actions.TextComponentEditorAction; +import de.netnexus.camelcase.core.CamelCaseEditorActionHandler; +import de.netnexus.camelcase.i18n.CamelCaseBundle; + +/** + * Switch between snake_case, SNAKE_CASE, SnakeCase, snakeCase. + */ +public class ToggleCamelCaseAction extends TextComponentEditorAction { + + public ToggleCamelCaseAction() { + super(new CamelCaseEditorActionHandler<>()); + + Presentation presentation = getTemplatePresentation(); + presentation.setText(CamelCaseBundle.message("action.toggleCamelCase.text")); + presentation.setText(CamelCaseBundle.message("action.toggleCamelCase.description")); + } + +} diff --git a/src/de/netnexus/CamelCasePlugin/CamelCaseConfig.java b/src/main/java/de/netnexus/camelcase/config/CamelCaseConfig.java similarity index 98% rename from src/de/netnexus/CamelCasePlugin/CamelCaseConfig.java rename to src/main/java/de/netnexus/camelcase/config/CamelCaseConfig.java index 058f66d..7fd13ca 100644 --- a/src/de/netnexus/CamelCasePlugin/CamelCaseConfig.java +++ b/src/main/java/de/netnexus/camelcase/config/CamelCaseConfig.java @@ -1,4 +1,4 @@ -package de.netnexus.CamelCasePlugin; +package de.netnexus.camelcase.config; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.State; @@ -113,4 +113,4 @@ public CamelCaseConfig getState() { public void loadState(@NotNull CamelCaseConfig singleFileExecutionConfig) { XmlSerializerUtil.copyBean(singleFileExecutionConfig, this); } -} \ No newline at end of file +} diff --git a/src/de/netnexus/CamelCasePlugin/CamelCaseEditorActionHandler.java b/src/main/java/de/netnexus/camelcase/core/CamelCaseEditorActionHandler.java similarity index 80% rename from src/de/netnexus/CamelCasePlugin/CamelCaseEditorActionHandler.java rename to src/main/java/de/netnexus/camelcase/core/CamelCaseEditorActionHandler.java index 6fc49b4..fd0791e 100644 --- a/src/de/netnexus/CamelCasePlugin/CamelCaseEditorActionHandler.java +++ b/src/main/java/de/netnexus/camelcase/core/CamelCaseEditorActionHandler.java @@ -1,4 +1,4 @@ -package de.netnexus.CamelCasePlugin; +package de.netnexus.camelcase.core; import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.DataContext; @@ -14,6 +14,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.util.ThrowableRunnable; +import de.netnexus.camelcase.config.CamelCaseConfig; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -23,7 +24,7 @@ public class CamelCaseEditorActionHandler extends EditorActionHandler { - CamelCaseEditorActionHandler() { + public CamelCaseEditorActionHandler() { super(true); } @@ -99,13 +100,22 @@ private Pair beforeWriteAction(Editor editor) { if (project != null) { CamelCaseConfig config = CamelCaseConfig.getInstance(project); if (config != null && (config.getcb1State() || config.getcb2State() || config.getcb3State() || config.getcb4State() || config.getcb5State() || config.getcb6State())) { - newText = Conversion.transform(text, config.getcb7State(), // pascal case with space - config.getcb6State(), // space case - config.getcb1State(), // kebab case - config.getcb2State(), // upper snake case - config.getcb3State(), // pascal case - config.getcb4State(), // camel case - config.getcb5State(), // lower snake case + newText = Conversion.transform( + text, + // pascal case with space + config.getcb7State(), + // space case + config.getcb6State(), + // kebab case + config.getcb1State(), + // upper snake case + config.getcb2State(), + // pascal case + config.getcb3State(), + // camel case + config.getcb4State(), + // lower snake case + config.getcb5State(), config.getmodel()); } else { newText = this.runWithoutConfig(text); @@ -123,13 +133,22 @@ private Pair beforeWriteAction(Editor editor) { private String runWithoutConfig(String text) { String[] conversionList = {"kebab-case", "SNAKE_CASE", "CamelCase", "camelCase", "snake_case", "space case", "Camel Case"}; - return Conversion.transform(text, true, // pascal case with space - true, // space case - true, // kebab case - true, // upper snake case - true, // pascal case - true, // camel case - true, // lower snake case + return Conversion.transform( + text, + // pascal case with space + true, + // space case + true, + // kebab case + true, + // upper snake case + true, + // pascal case + true, + // camel case + true, + // lower snake case + true, conversionList); } @@ -142,4 +161,4 @@ private Runnable getRunnableWrapper(final Project project, final Runnable runnab return () -> CommandProcessor.getInstance().executeCommand(project, runnable, "CamelCase", ActionGroup.EMPTY_GROUP); } -} \ No newline at end of file +} diff --git a/src/de/netnexus/CamelCasePlugin/Conversion.java b/src/main/java/de/netnexus/camelcase/core/Conversion.java similarity index 98% rename from src/de/netnexus/CamelCasePlugin/Conversion.java rename to src/main/java/de/netnexus/camelcase/core/Conversion.java index cd38041..2548d99 100644 --- a/src/de/netnexus/CamelCasePlugin/Conversion.java +++ b/src/main/java/de/netnexus/camelcase/core/Conversion.java @@ -1,4 +1,4 @@ -package de.netnexus.CamelCasePlugin; +package de.netnexus.camelcase.core; import org.apache.commons.lang.WordUtils; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ import static java.lang.Character.isLowerCase; import static java.lang.Character.isUpperCase; -class Conversion { +public class Conversion { private static final String CONVERSION_SPACE_CASE = "space case"; private static final String CONVERSION_KEBAB_CASE = "kebab-case"; @@ -21,7 +21,7 @@ class Conversion { private static final String CONVERSION_LOWER_SNAKE_CASE = "snake_case"; @NotNull - static String transform(String text, + public static String transform(String text, boolean usePascalCaseWithSpace, boolean useSpaceCase, boolean useKebabCase, @@ -187,7 +187,7 @@ private static String toCamelCase(String in) { StringBuilder camelCased = new StringBuilder(); String[] tokens = in.split("_"); for (String token : tokens) { - if (token.length() >= 1) { + if (!token.isEmpty()) { camelCased.append(token.substring(0, 1).toUpperCase()).append(token.substring(1)); } else { camelCased.append("_"); diff --git a/src/main/java/de/netnexus/camelcase/i18n/CamelCaseBundle.java b/src/main/java/de/netnexus/camelcase/i18n/CamelCaseBundle.java new file mode 100644 index 0000000..d7125b7 --- /dev/null +++ b/src/main/java/de/netnexus/camelcase/i18n/CamelCaseBundle.java @@ -0,0 +1,30 @@ +package de.netnexus.camelcase.i18n; + +import com.intellij.DynamicBundle; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.PropertyKey; + +import java.util.function.Supplier; + +public class CamelCaseBundle extends DynamicBundle { + + @NonNls + private static final String BUNDLE = "messages.CamelCaseBundle"; + + private static final CamelCaseBundle INSTANCE = new CamelCaseBundle(); + + private CamelCaseBundle() { + super(BUNDLE); + } + + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) { + return INSTANCE.getMessage(key, params); + } + + @NotNull + public static Supplier messagePointer(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) { + return INSTANCE.getLazyMessage(key, params); + } +} diff --git a/src/de/netnexus/CamelCasePlugin/CamelCasePluginConfigurable.java b/src/main/java/de/netnexus/camelcase/ui/CamelCasePluginConfigurable.java similarity index 90% rename from src/de/netnexus/CamelCasePlugin/CamelCasePluginConfigurable.java rename to src/main/java/de/netnexus/camelcase/ui/CamelCasePluginConfigurable.java index 15c1ff9..31d4bd0 100644 --- a/src/de/netnexus/CamelCasePlugin/CamelCasePluginConfigurable.java +++ b/src/main/java/de/netnexus/camelcase/ui/CamelCasePluginConfigurable.java @@ -1,8 +1,9 @@ -package de.netnexus.CamelCasePlugin; +package de.netnexus.camelcase.ui; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.project.Project; +import de.netnexus.camelcase.config.CamelCaseConfig; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -65,12 +66,14 @@ public Runnable enableSearch(String s) { @Override public boolean isModified() { - return true; + return mGUI.isModified(); } @Override public void apply() throws ConfigurationException { - mGUI.apply(); + if (mGUI != null) { + mGUI.apply(); + } } @Override @@ -78,4 +81,4 @@ public void reset() { } -} \ No newline at end of file +} diff --git a/src/de/netnexus/CamelCasePlugin/OptionGui.form b/src/main/java/de/netnexus/camelcase/ui/OptionGui.form similarity index 97% rename from src/de/netnexus/CamelCasePlugin/OptionGui.form rename to src/main/java/de/netnexus/camelcase/ui/OptionGui.form index 24798b2..57a70a9 100644 --- a/src/de/netnexus/CamelCasePlugin/OptionGui.form +++ b/src/main/java/de/netnexus/camelcase/ui/OptionGui.form @@ -1,5 +1,5 @@ -
+ @@ -103,7 +103,7 @@ - + diff --git a/src/de/netnexus/CamelCasePlugin/OptionGui.java b/src/main/java/de/netnexus/camelcase/ui/OptionGui.java similarity index 73% rename from src/de/netnexus/CamelCasePlugin/OptionGui.java rename to src/main/java/de/netnexus/camelcase/ui/OptionGui.java index 66a2627..50a94cc 100644 --- a/src/de/netnexus/CamelCasePlugin/OptionGui.java +++ b/src/main/java/de/netnexus/camelcase/ui/OptionGui.java @@ -1,8 +1,11 @@ -package de.netnexus.CamelCasePlugin; +package de.netnexus.camelcase.ui; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Comparing; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; +import de.netnexus.camelcase.config.CamelCaseConfig; +import de.netnexus.camelcase.i18n.CamelCaseBundle; import javax.swing.*; import java.awt.*; @@ -27,38 +30,41 @@ public class OptionGui { private JButton upButton; private JButton downButton; private JList list1; + private JLabel orderLabel; OptionGui() { + initLocalization(); - upButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { + upButton.addActionListener(e -> { - String selectedItem = (String) list1.getSelectedValue(); - int itemIndex = list1.getSelectedIndex(); + String selectedItem = (String) list1.getSelectedValue(); + int itemIndex = list1.getSelectedIndex(); - if(itemIndex > 0){ - model.remove(itemIndex); - model.add(itemIndex - 1, selectedItem); - list1.setSelectedIndex(itemIndex - 1); - } + if(itemIndex > 0){ + model.remove(itemIndex); + model.add(itemIndex - 1, selectedItem); + list1.setSelectedIndex(itemIndex - 1); } }); - downButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - String selectedItem = (String) list1.getSelectedValue(); - int itemIndex = list1.getSelectedIndex(); - - if( itemIndex < model.getSize() -1 ){ - model.remove(itemIndex); - model.add(itemIndex + 1, selectedItem); - list1.setSelectedIndex(itemIndex + 1); - } + + downButton.addActionListener(e -> { + String selectedItem = (String) list1.getSelectedValue(); + int itemIndex = list1.getSelectedIndex(); + + if( itemIndex < model.getSize() -1 ){ + model.remove(itemIndex); + model.add(itemIndex + 1, selectedItem); + list1.setSelectedIndex(itemIndex + 1); } }); } + private void initLocalization() { + orderLabel.setText(CamelCaseBundle.message("action.order.text")); + upButton.setText(CamelCaseBundle.message("action.up.text")); + downButton.setText(CamelCaseBundle.message("action.down.text")); + } + public void createUI(Project project) { mConfig = CamelCaseConfig.getInstance(project); cb1.setSelected(mConfig.getcb1State()); @@ -91,6 +97,15 @@ private void createUIComponents() { // TODO: place custom component creation code here } + public boolean isModified() { + return !Comparing.equal(mConfig.cb1State, cb1.isSelected()) || + !Comparing.equal(mConfig.cb2State, cb2.isSelected()) || + !Comparing.equal(mConfig.cb3State, cb3.isSelected()) || + !Comparing.equal(mConfig.cb4State, cb4.isSelected()) || + !Comparing.equal(mConfig.cb5State, cb5.isSelected()) || + !Comparing.equal(mConfig.cb6State, cb6.isSelected()) || + !Comparing.equal(mConfig.cb7State, cb7.isSelected()); + } public void apply() { mConfig.setcb1State(cb1.isSelected()); diff --git a/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml similarity index 54% rename from META-INF/plugin.xml rename to src/main/resources/META-INF/plugin.xml index 229459c..51627fc 100644 --- a/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,30 +1,8 @@ de.netnexus.camelcaseplugin CamelCase - 3.0.12 NetNexus - - Please have a look at the preferences of this plugin: - You can disable some conversions or change their order. -
- If you find something is not working or missing, feel free to submit a PR on our GitHub repo. - ]]>
- - If you have any comments please let me know.

- -

Release 3.0.12: -

    -
  • Bugfix: use standard config if com.intellij.openapi.project.Project is null
  • -
-

- - ]]> -
- @@ -44,7 +22,7 @@ - @@ -55,8 +33,8 @@ - + serviceImplementation="de.netnexus.camelcase.config.CamelCaseConfig"/> +
diff --git a/src/main/resources/messages/CamelCaseBundle.properties b/src/main/resources/messages/CamelCaseBundle.properties new file mode 100644 index 0000000..a4b427a --- /dev/null +++ b/src/main/resources/messages/CamelCaseBundle.properties @@ -0,0 +1,5 @@ +action.order.text=Order +action.up.text=Up +action.down.text=Down +action.toggleCamelCase.text=Toggle CamelCase +action.toggleCamelCase.description=Switches between CamelCase, camelCase and snake_case diff --git a/src/main/resources/messages/CamelCaseBundle_zh.properties b/src/main/resources/messages/CamelCaseBundle_zh.properties new file mode 100644 index 0000000..2029a59 --- /dev/null +++ b/src/main/resources/messages/CamelCaseBundle_zh.properties @@ -0,0 +1,5 @@ +action.order.text=\u6392\u5E8F +action.up.text=\u5411\u4E0A +action.down.text=\u5411\u4E0B +action.toggleCamelCase.text=\u5207\u6362\u9A7C\u5CF0\u547D\u540D +action.toggleCamelCase.description=\u5728 CamelCase\u3001camelCase \u548C snake_case \u4E4B\u95F4\u5207\u6362