diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e67d8e..7e4fffd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,67 +5,70 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- [Kotlin AutoAormatter](https://github.com/hovinen/kotlin-auto-formatter) plugin (since I'm lazy). + - Also formatted code with this plugin. ### Changes -- Merged changes from JetBrains plugin template -- [[#120]](https://github.com/Roboroads/laravel-tinker/issues/120) Changes remote tip text in settings +- Merged changes from JetBrains plugin template. +- [[#120]](https://github.com/Roboroads/laravel-tinker/issues/120) Changes remote tip text in settings. ### Fixed -- [[#121]](https://github.com/Roboroads/laravel-tinker/issues/121) Exception when the IDE has no foreground color for given attribute +- [[#121]](https://github.com/Roboroads/laravel-tinker/issues/121) Exception when the IDE has no foreground color for given attribute. ## [2.3.0] ### Added - [[#112]](https://github.com/Roboroads/laravel-tinker/issues/112) Adds Open new console and Reopen last console actions to the tinker output toolwindow. ### Changed - Cleaned up the output toolwindow a little bit. -- Added dependabot updates [#113](https://github.com/Roboroads/laravel-tinker/pull/113) & [#114](https://github.com/Roboroads/laravel-tinker/pull/114) +- Added dependabot updates [#113](https://github.com/Roboroads/laravel-tinker/pull/113) & [#114](https://github.com/Roboroads/laravel-tinker/pull/114). ### Fixed -- [[#110]](https://github.com/Roboroads/laravel-tinker/issues/110) Fixes typo in caster for the Model class +- [[#110]](https://github.com/Roboroads/laravel-tinker/issues/110) Fixes typo in caster for the Model class. ## [2.2.2] ### Added -- Way of migrating to newer versions of this plugin -- [[#105]](https://github.com/Roboroads/laravel-tinker/pull/105) Adds the stringable caster added in [laravel/tinker v2.6.1](https://github.com/laravel/tinker/pull/121) - - Thanks [@emargareten](https://github.com/emargareten) +- Way of migrating to newer versions of this plugin. +- [[#105]](https://github.com/Roboroads/laravel-tinker/pull/105) Adds the stringable caster added in [laravel/tinker v2.6.1](https://github.com/laravel/tinker/pull/121). + - Thanks [@emargareten](https://github.com/emargareten). ### Changed - Restyling of Tinker console tabs. ### Fixed -- [[#61]](https://github.com/Roboroads/laravel-tinker/issues/61) Fixes re-indexing issue causing infinite errors and 100% CPU +- [[#61]](https://github.com/Roboroads/laravel-tinker/issues/61) Fixes re-indexing issue causing infinite errors and 100% CPU. - Big thanks to [@fawzanm](https://github.com/fawzanm) who helped me figure out a reproduction method and testing my fix. ## [2.2.1] ### Added -- [[#96]](https://github.com/Roboroads/laravel-tinker/issues/96) Added compatibility with newer API versions +- [[#96]](https://github.com/Roboroads/laravel-tinker/issues/96) Added compatibility with newer API versions. ## [2.2.0] ### Added -- [[#34]](https://github.com/Roboroads/laravel-tinker/issues/34) Setting to change tinker execution root +- [[#34]](https://github.com/Roboroads/laravel-tinker/issues/34) Setting to change tinker execution root. ### Fixed - [[#75]](https://github.com/Roboroads/laravel-tinker/issues/75) Empty directory list of tinker consoles resulting in fatal error. ## [2.1.0] ### Added -- Dependabot +- Dependabot. - [[#35]](https://github.com/Roboroads/laravel-tinker/issues/35) Setting to enable/disable line wrapping in output window. - [[#33]](https://github.com/Roboroads/laravel-tinker/issues/33) Adds way for Patreon supporters to disable the support plug. ### Changed -- [[#53]](https://github.com/Roboroads/laravel-tinker/issues/53) Updates compatibility with 2021.1 -- Updated all dependencies +- [[#53]](https://github.com/Roboroads/laravel-tinker/issues/53) Updates compatibility with 2021.1. +- Updated all dependencies. ### Removed - Tinker Consoles having an IS_TINKER_CONSOLE userdata key. ### Fixed -- [[#47]](https://github.com/Roboroads/laravel-tinker/issues/47) [[#40]](https://github.com/Roboroads/laravel-tinker/issues/40) `<` and `>` are now replaced by `>` and `<` to make them not parse as HTML in tinker output +- [[#47]](https://github.com/Roboroads/laravel-tinker/issues/47) [[#40]](https://github.com/Roboroads/laravel-tinker/issues/40) `<` and `>` are now replaced by `>` and `<` to make them not parse as HTML in tinker output. - [[#40]](https://github.com/Roboroads/laravel-tinker/issues/40) Fixes always showing output on the last opened project when having multiple projects open. - [[#41]](https://github.com/Roboroads/laravel-tinker/issues/41) When pressing the x icon on the progress bar to stop the PHP execution, the process now gets destroyed within 250ms. ## [2.0.1] ### Changed -- New branding by [Joey "Veritas" de Vries](https://joeyveritas.nl) +- New branding by [Joey "Veritas" de Vries](https://joeyveritas.nl). ### Fixed - [[#50]](https://github.com/Roboroads/laravel-tinker/issues/50) Tinker Create/Smart action overwriting its own files from a previous session. @@ -73,55 +76,55 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [2.0.0] ### Added -- BREAKING: [[#39]](https://github.com/Roboroads/laravel-tinker/issues/39) Tinker consoles are now available under "Scratches and Consoles" -- [[#37]](https://github.com/Roboroads/laravel-tinker/issues/37) [[#38]](https://github.com/Roboroads/laravel-tinker/issues/38) When selecting text and running the `Smart Action` a new console opens with your selected text - - This can also be achieved by selecting text, right-clicking and selecting `Open Tinker Console With Selection` +- BREAKING: [[#39]](https://github.com/Roboroads/laravel-tinker/issues/39) Tinker consoles are now available under "Scratches and Consoles". +- [[#37]](https://github.com/Roboroads/laravel-tinker/issues/37) [[#38]](https://github.com/Roboroads/laravel-tinker/issues/38) When selecting text and running the `Smart Action` a new console opens with your selected text. + - This can also be achieved by selecting text, right-clicking and selecting `Open Tinker Console With Selection`. ### Changed -- BREAKING: Every action is now independently listed - - The default action is now "Smart Action" which will have kind-of the same functionality as you have been using it up till now +- BREAKING: Every action is now independently listed. + - The default action is now "Smart Action" which will have kind-of the same functionality as you have been using it up till now. - Every action this plugin can do is now individually bindable in your keymap. ### Removed -- BREAKING: Per-project cache (which stored your last executed tinker code) +- BREAKING: Per-project cache (which stored your last executed tinker code). - You can probably find your last snippet still in `%Project%/.idea/laravel-tinker.xml` if you really need it! - `%Project%/.idea/laravel-tinker.xml` can be deleted otherwise. ### Other -- Reorganization of a lot of classes -- Dependencies have been updated +- Reorganization of a lot of classes. +- Dependencies have been updated. ## [1.3.1] ### Changed -- Updated dependencies +- Updated dependencies. ### Fixed -- Compatibility with 2020.3 +- Compatibility with 2020.3. ## [1.3.0] ### Added -- Laravel Tinker settings page (under Tools) -- [[#30]](https://github.com/Roboroads/laravel-tinker/issues/30) Ability to disable start and finish messages in output -- [[#21]](https://github.com/Roboroads/laravel-tinker/issues/21) Ability to add a shortcut to close all involving Tinker +- Laravel Tinker settings page (under Tools). +- [[#30]](https://github.com/Roboroads/laravel-tinker/issues/30) Ability to disable start and finish messages in output. +- [[#21]](https://github.com/Roboroads/laravel-tinker/issues/21) Ability to add a shortcut to close all involving Tinker. ### Changed -- Dependencies updated to the latest versions +- Dependencies updated to the latest versions. ### Fixed - The title of the tinker screen was editable - now it isn't. -- [[#28]](https://github.com/Roboroads/laravel-tinker/issues/28) Ending your tinker console with a comment now works correctly again - - Credits to [@emargareten](https://github.com/emargareten) +- [[#28]](https://github.com/Roboroads/laravel-tinker/issues/28) Ending your tinker console with a comment now works correctly again. + - Credits to [@emargareten](https://github.com/emargareten). ## [1.2.1] ### Added -- [[#25]](https://github.com/Roboroads/laravel-tinker/issues/25) When running tinker it will now save all documents before executing +- [[#25]](https://github.com/Roboroads/laravel-tinker/issues/25) When running tinker it will now save all documents before executing. ### Fixed - [[#23]](https://github.com/Roboroads/laravel-tinker/issues/23) Fixed a bug where output would display twice when the output highlighter didn't find output to highlight. ## [1.2.0] ### Added -- [[#7]](https://github.com/Roboroads/laravel-tinker/issues/7) Output syntax highlighting +- [[#7]](https://github.com/Roboroads/laravel-tinker/issues/7) Output syntax highlighting. ### Fixed - [[#11]](https://github.com/Roboroads/laravel-tinker/issues/11) Plugin won't create a null file anymore on windows. @@ -129,12 +132,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - [[#18]](https://github.com/Roboroads/laravel-tinker/issues/18) Added the LARAVEL_START constant to the tinker run script. - [[#19]](https://github.com/Roboroads/laravel-tinker/issues/19) Colors in output window now reset to IDE colors when running. - [[#12]](https://github.com/Roboroads/laravel-tinker/issues/12) [[#20]](https://github.com/Roboroads/laravel-tinker/issues/20) Fixes `Class 'Laravel\Tinker\ClassAliasAutoloader' not found` - - By just checking if it exists before loading it - - Should fix the plugin for laravel/tinker versions `<= 1.0.1` + - By just checking if it exists before loading it. + - Should fix the plugin for laravel/tinker versions `<= 1.0.1`. ## [1.1.1] ### Added -- [[#10]](https://github.com/Roboroads/laravel-tinker/issues/10) Your last command will now be saved (on per-project level) +- [[#10]](https://github.com/Roboroads/laravel-tinker/issues/10) Your last command will now be saved (on per-project level). - Non-obtrusive reminder you can support this package. @@ -143,11 +146,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - The link to PHP settings in error dialogs now *acually* links to the correct settings page. -- [[#9]](https://github.com/Roboroads/laravel-tinker/issues/9) Output showing slow on larger outputs +- [[#9]](https://github.com/Roboroads/laravel-tinker/issues/9) Output showing slow on larger outputs. ## [1.1.0] ### Added -- Run button at the opening tag of the tinker console +- Run button at the opening tag of the tinker console. ### Changed - Cleaned output of tinker output window @@ -155,29 +158,29 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed -- Default keybinding in Mac OS -- Toolwindow not opening automatically if not opened before -- Leaving zombie processes (something pcntl did) -- Silent crash when docker was not set -- Tinker process not shutting down because of waiting for non-existent input +- Default keybinding in Mac OS. +- Toolwindow not opening automatically if not opened before. +- Leaving zombie processes (something pcntl did). +- Silent crash when docker was not set. +- Tinker process not shutting down because of waiting for non-existent input. ## [1.0.0] ### Added -- [[#1]](https://github.com/Roboroads/laravel-tinker/issues/1) A correct way to interact with remote interpreters +- [[#1]](https://github.com/Roboroads/laravel-tinker/issues/1) A correct way to interact with remote interpreters. ### Changed -- Made errors more to the point -- Better code splitting in message balloons -- More text in the readme -- Better formatting in tinker output +- Made errors more to the point. +- Better code splitting in message balloons. +- More text in the readme. +- Better formatting in tinker output. ### Fixed -- Laravel now actually gets bootstrapped -- Removed needless output from interpreter, like docker startup messages -- Made output toolwindow font show in readable colors -- Campatibility issues that arose in 0.0.1-ALPHA +- Laravel now actually gets bootstrapped. +- Removed needless output from interpreter, like docker startup messages. +- Made output toolwindow font show in readable colors. +- Campatibility issues that arose in 0.0.1-ALPHA. ## [0.0.1-ALPHA] ### Added -- Everything +- Everything. diff --git a/build.gradle.kts b/build.gradle.kts index 8af5147..1eab356 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,15 +14,15 @@ plugins { id("org.jetbrains.changelog") version "1.3.1" // Gradle Qodana Plugin id("org.jetbrains.qodana") version "0.1.13" + // Kotlin formatter + id("tech.formatter-kt.formatter") version "0.7.9" } group = properties("pluginGroup") version = properties("pluginVersion") // Configure project's dependencies -repositories { - mavenCentral() -} +repositories { mavenCentral() } dependencies { implementation("at.favre.lib:bcrypt:0.9.0") @@ -36,10 +36,13 @@ intellij { type.set(properties("platformType")) // Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file. - plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)) + plugins.set( + properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty) + ) } -// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin +// Configure Gradle Changelog Plugin - read more: +// https://github.com/JetBrains/gradle-changelog-plugin changelog { version.set(properties("pluginVersion")) groups.set(emptyList()) @@ -55,44 +58,49 @@ qodana { tasks { // Set the JVM compatibility versions - properties("javaVersion").let { - withType { - sourceCompatibility = it - targetCompatibility = it - } - withType { - kotlinOptions.jvmTarget = it + properties("javaVersion") + .let { + withType { + sourceCompatibility = it + targetCompatibility = it + } + withType { kotlinOptions.jvmTarget = it } } - } - wrapper { - gradleVersion = properties("gradleVersion") - } + wrapper { gradleVersion = properties("gradleVersion") } patchPluginXml { version.set(properties("pluginVersion")) sinceBuild.set(properties("pluginSinceBuild")) untilBuild.set(properties("pluginUntilBuild")) - // Extract the section from README.md and provide for the plugin's manifest + // Extract the section from README.md and provide for the + // plugin's manifest pluginDescription.set( - projectDir.resolve("README.md").readText().lines().run { - val start = "" - val end = "" - - if (!containsAll(listOf(start, end))) { - throw GradleException("Plugin description section not found in README.md:\n$start ... $end") + projectDir.resolve("README.md") + .readText() + .lines() + .run { + val start = "" + val end = "" + + if (!containsAll(listOf(start, end))) { + throw GradleException( + "Plugin description section not found in README.md:\n$start ... $end" + ) + } + subList(indexOf(start) + 1, indexOf(end)) } - subList(indexOf(start) + 1, indexOf(end)) - }.joinToString("\n").run { markdownToHTML(this) } + .joinToString("\n") + .run { markdownToHTML(this) } ) // Get the latest available change notes from the changelog file - changeNotes.set(provider { - changelog.run { - getOrNull(properties("pluginVersion")) ?: getLatest() - }.toHTML() - }) + changeNotes.set( + provider { + changelog.run { getOrNull(properties("pluginVersion")) ?: getLatest() }.toHTML() + } + ) } // Configure UI tests plugin @@ -113,9 +121,15 @@ tasks { publishPlugin { dependsOn("patchChangelog") token.set(System.getenv("PUBLISH_TOKEN")) - // 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: + // 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/deployment.html#specifying-a-release-channel - channels.set(listOf(properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first())) + channels.set( + listOf( + properties("pluginVersion").split('-').getOrElse(1) { "default" }.split('.').first() + ) + ) } } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/Strings.kt b/src/main/kotlin/nl/deschepers/laraveltinker/Strings.kt index e0d0b12..2a616f1 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/Strings.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/Strings.kt @@ -9,6 +9,9 @@ private const val BUNDLE = "strings.strings" object Strings : AbstractBundle(BUNDLE) { @JvmStatic - fun get(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any) = - getMessage(key, *params) + fun get( + @PropertyKey(resourceBundle = BUNDLE) + key: String, + vararg params: Any + ) = getMessage(key, *params) } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/action/EditLaravelTinkerProjectSettingsAction.kt b/src/main/kotlin/nl/deschepers/laraveltinker/action/EditLaravelTinkerProjectSettingsAction.kt index 342eabf..d5f2f24 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/action/EditLaravelTinkerProjectSettingsAction.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/action/EditLaravelTinkerProjectSettingsAction.kt @@ -7,16 +7,14 @@ import com.intellij.openapi.options.ShowSettingsUtil import nl.deschepers.laraveltinker.Strings import nl.deschepers.laraveltinker.settings.ProjectSettingsConfigurable -class EditLaravelTinkerProjectSettingsAction : NotificationAction( - Strings.get("lt.settings.tinker_project_settings") -) { +class EditLaravelTinkerProjectSettingsAction : + NotificationAction(Strings.get("lt.settings.tinker_project_settings")) { + override fun actionPerformed(e: AnActionEvent, notification: Notification) { val project = e.project if (project != null) { - ShowSettingsUtil.getInstance().showSettingsDialog( - project, - ProjectSettingsConfigurable::class.java - ) + ShowSettingsUtil.getInstance() + .showSettingsDialog(project, ProjectSettingsConfigurable::class.java) } } } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/action/EditPhpInterpreterSettingsAction.kt b/src/main/kotlin/nl/deschepers/laraveltinker/action/EditPhpInterpreterSettingsAction.kt index 7da1213..b93130b 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/action/EditPhpInterpreterSettingsAction.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/action/EditPhpInterpreterSettingsAction.kt @@ -7,16 +7,14 @@ import com.intellij.openapi.options.ShowSettingsUtil import com.jetbrains.php.config.PhpProjectConfigurable import nl.deschepers.laraveltinker.Strings -class EditPhpInterpreterSettingsAction : NotificationAction( - Strings.get("lt.settings.php_interpreter") -) { +class EditPhpInterpreterSettingsAction : + NotificationAction(Strings.get("lt.settings.php_interpreter")) { + override fun actionPerformed(e: AnActionEvent, notification: Notification) { val project = e.project if (project != null) { - ShowSettingsUtil.getInstance().showSettingsDialog( - project, - PhpProjectConfigurable::class.java - ) + ShowSettingsUtil.getInstance() + .showSettingsDialog(project, PhpProjectConfigurable::class.java) } } } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/action/OpenNewConsoleWithSelectionAction.kt b/src/main/kotlin/nl/deschepers/laraveltinker/action/OpenNewConsoleWithSelectionAction.kt index 7a09a4b..296c0ca 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/action/OpenNewConsoleWithSelectionAction.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/action/OpenNewConsoleWithSelectionAction.kt @@ -31,7 +31,10 @@ class OpenNewConsoleWithSelectionAction : AnAction() { val currentEditor: Editor = e.getData(CommonDataKeys.EDITOR) ?: return if (currentEditor.selectionModel.hasSelection()) { - val tinkerConsole = tinkerConsoleUtil.createNewTinkerConsole("\n${currentEditor.selectionModel.selectedText!!}\n") + val tinkerConsole = + tinkerConsoleUtil.createNewTinkerConsole( + "\n${currentEditor.selectionModel.selectedText!!}\n" + ) FileEditorManager.getInstance(project).openFile(tinkerConsole, true) } } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/action/SmartAction.kt b/src/main/kotlin/nl/deschepers/laraveltinker/action/SmartAction.kt index ffb2cd6..df61f8b 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/action/SmartAction.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/action/SmartAction.kt @@ -10,11 +10,10 @@ import com.jetbrains.php.lang.PhpFileType import nl.deschepers.laraveltinker.Strings import nl.deschepers.laraveltinker.util.TinkerConsoleUtil -/** The default 1.x tinker action: - * Opens the last console if none is open - * or Opens a new console with your selected text - * or Switches to the tinker console tab is one is open - * or Runs the currently viewing tinker tab. +/** + * The default 1.x tinker action: Opens the last console if none is open or Opens a new console + * with your selected text or Switches to the tinker console tab is one is open or Runs the + * currently viewing tinker tab. */ class SmartAction : AnAction() { override fun update(e: AnActionEvent) { @@ -22,7 +21,8 @@ class SmartAction : AnAction() { e.presentation.isVisible = true e.presentation.isEnabled = false - e.presentation.text = Strings.get("lt.menu.action.smart", Strings.get("lt.menu.action.open_new_console")) + e.presentation.text = + Strings.get("lt.menu.action.smart", Strings.get("lt.menu.action.open_new_console")) val project = e.project ?: return val tinkerConsoleUtil = TinkerConsoleUtil(project) @@ -30,19 +30,25 @@ class SmartAction : AnAction() { val virtualFile: VirtualFile? = e.getData(CommonDataKeys.VIRTUAL_FILE) if (virtualFile != null && tinkerConsoleUtil.isTinkerConsole(virtualFile)) { - e.presentation.text = Strings.get("lt.menu.action.smart", Strings.get("lt.menu.action.run_console")) + e.presentation.text = + Strings.get("lt.menu.action.smart", Strings.get("lt.menu.action.run_console")) return } for (editor in FileEditorManager.getInstance(project).selectedEditors) { if (editor.file != null && tinkerConsoleUtil.isTinkerConsole(editor.file!!)) { - e.presentation.text = Strings.get("lt.menu.action.smart", Strings.get("lt.menu.action.switch_to_tinker_console")) + e.presentation.text = + Strings.get( + "lt.menu.action.smart", + Strings.get("lt.menu.action.switch_to_tinker_console") + ) return } } if (tinkerConsoleUtil.getLastOpenTinkerConsole() != null) { - e.presentation.text = Strings.get("lt.menu.action.smart", Strings.get("lt.menu.action.open_last_console")) + e.presentation.text = + Strings.get("lt.menu.action.smart", Strings.get("lt.menu.action.open_last_console")) } } @@ -52,21 +58,21 @@ class SmartAction : AnAction() { // First smart action - running with a console open: run val virtualFile: VirtualFile? = e.getData(CommonDataKeys.VIRTUAL_FILE) - if ( - virtualFile != null && - tinkerConsoleUtil.isTinkerConsole(virtualFile) && + if (virtualFile != null && tinkerConsoleUtil.isTinkerConsole(virtualFile) && tinkerConsoleUtil.runTinkerWithFile(virtualFile) - ) return + ) + return // Second action: Open a new console with the selected text val currentEditor: Editor? = e.getData(CommonDataKeys.EDITOR) val isFile = currentEditor != null && virtualFile != null - if ( - isFile && - virtualFile!!.fileType is PhpFileType && + if (isFile && virtualFile!!.fileType is PhpFileType && currentEditor!!.selectionModel.hasSelection() ) { - val tinkerConsole = tinkerConsoleUtil.createNewTinkerConsole("\n${currentEditor.selectionModel.selectedText!!}\n") + val tinkerConsole = + tinkerConsoleUtil.createNewTinkerConsole( + "\n${currentEditor.selectionModel.selectedText!!}\n" + ) FileEditorManager.getInstance(project).openFile(tinkerConsole, true) } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/balloon/Balloon.kt b/src/main/kotlin/nl/deschepers/laraveltinker/balloon/Balloon.kt index e7c88e3..99cdf12 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/balloon/Balloon.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/balloon/Balloon.kt @@ -13,24 +13,24 @@ open class Balloon(private val project: Project) { open var content: String = "" fun show() { - val notificationGroup = NotificationGroupManager.getInstance().getNotificationGroup("Laravel Tinker") + val notificationGroup = + NotificationGroupManager.getInstance().getNotificationGroup("Laravel Tinker") - val notification: Notification = if (title != null) { - notificationGroup.createNotification( - title!!, - content, - if (isError) NotificationType.ERROR else NotificationType.INFORMATION - ) - } else { - notificationGroup.createNotification( - content, - if (isError) NotificationType.ERROR else NotificationType.INFORMATION - ) - } + val notification: Notification = + if (title != null) { + notificationGroup.createNotification( + title!!, + content, + if (isError) NotificationType.ERROR else NotificationType.INFORMATION + ) + } else { + notificationGroup.createNotification( + content, + if (isError) NotificationType.ERROR else NotificationType.INFORMATION + ) + } - this.getActions().forEach { - notification.addAction(it) - } + this.getActions().forEach { notification.addAction(it) } Notifications.Bus.notify(notification, project) } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/balloon/LaravelRootDoesNotExistBalloon.kt b/src/main/kotlin/nl/deschepers/laraveltinker/balloon/LaravelRootDoesNotExistBalloon.kt index d92d9ae..6d89105 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/balloon/LaravelRootDoesNotExistBalloon.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/balloon/LaravelRootDoesNotExistBalloon.kt @@ -8,8 +8,7 @@ import nl.deschepers.laraveltinker.action.EditLaravelTinkerProjectSettingsAction class LaravelRootDoesNotExistBalloon(project: Project) : Balloon(project) { override var isError: Boolean = false override var title: String? = Strings.get("lt.error.laravel_root.does_not_exist.title") - override var content: String = - Strings.get("lt.error.laravel_root.does_not_exist.message") + override var content: String = Strings.get("lt.error.laravel_root.does_not_exist.message") override fun getActions(): List { return listOf(EditLaravelTinkerProjectSettingsAction()) diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/balloon/LaravelRootDoesNotHaveVendorBalloon.kt b/src/main/kotlin/nl/deschepers/laraveltinker/balloon/LaravelRootDoesNotHaveVendorBalloon.kt index 5ec21c1..1c714df 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/balloon/LaravelRootDoesNotHaveVendorBalloon.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/balloon/LaravelRootDoesNotHaveVendorBalloon.kt @@ -8,8 +8,7 @@ import nl.deschepers.laraveltinker.action.EditLaravelTinkerProjectSettingsAction class LaravelRootDoesNotHaveVendorBalloon(project: Project) : Balloon(project) { override var isError: Boolean = false override var title: String? = Strings.get("lt.error.laravel_root.no_vendor.title") - override var content: String = - Strings.get("lt.error.laravel_root.no_vendor.message") + override var content: String = Strings.get("lt.error.laravel_root.no_vendor.message") override fun getActions(): List { return listOf(EditLaravelTinkerProjectSettingsAction()) diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/linemarkerprovider/TinkerRunLineMarkerProvider.kt b/src/main/kotlin/nl/deschepers/laraveltinker/linemarkerprovider/TinkerRunLineMarkerProvider.kt index e49d463..3202f0c 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/linemarkerprovider/TinkerRunLineMarkerProvider.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/linemarkerprovider/TinkerRunLineMarkerProvider.kt @@ -6,9 +6,9 @@ import com.intellij.icons.AllIcons.RunConfigurations.TestState.Run import com.intellij.openapi.editor.markup.GutterIconRenderer.Alignment.RIGHT import com.intellij.psi.PsiElement import com.intellij.psi.util.elementType +import java.awt.event.MouseEvent import nl.deschepers.laraveltinker.Strings import nl.deschepers.laraveltinker.util.TinkerConsoleUtil -import java.awt.event.MouseEvent class TinkerRunLineMarkerProvider : LineMarkerProvider { companion object { @@ -17,20 +17,20 @@ class TinkerRunLineMarkerProvider : LineMarkerProvider { override fun getLineMarkerInfo(element: PsiElement): LineMarkerInfo<*>? { val tinkerConsoleUtil = TinkerConsoleUtil(element.project) - if ( - tinkerConsoleUtil.isTinkerConsole(element.containingFile.virtualFile) && + if (tinkerConsoleUtil.isTinkerConsole(element.containingFile.virtualFile) && element.elementType.toString() == PHP_OPEN_TAG - ) return LineMarkerInfo( - element, - element.textRange, - Run, - null, - { _: MouseEvent, psiElement: PsiElement -> - tinkerConsoleUtil.runTinkerWithFile(psiElement.containingFile.virtualFile) - }, - RIGHT, - { Strings.get("lt.run") } ) + return LineMarkerInfo( + element, + element.textRange, + Run, + null, + { _: MouseEvent, psiElement: PsiElement -> + tinkerConsoleUtil.runTinkerWithFile(psiElement.containingFile.virtualFile) + }, + RIGHT, + { Strings.get("lt.run") } + ) return null } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/listener/PhpProcessListener.kt b/src/main/kotlin/nl/deschepers/laraveltinker/listener/PhpProcessListener.kt index 7a17cc7..338eece 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/listener/PhpProcessListener.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/listener/PhpProcessListener.kt @@ -13,7 +13,9 @@ import nl.deschepers.laraveltinker.settings.PatreonSupport import nl.deschepers.laraveltinker.settings.PersistentApplicationCache import nl.deschepers.laraveltinker.toolwindow.TinkerOutputToolWindowFactory -class PhpProcessListener(private val project: Project, private val processHandler: ProcessHandler) : ProcessListener { +class PhpProcessListener(private val project: Project, private val processHandler: ProcessHandler) : + ProcessListener { + companion object { private const val OUTPUT_START_SEQUENCE = "%%START-OUTPUT%%" private const val OUTPUT_END_SEQUENCE = "%%END-OUTPUT%%" @@ -34,23 +36,25 @@ class PhpProcessListener(private val project: Project, private val processHandle } override fun processTerminated(event: ProcessEvent) { - ApplicationManager.getApplication().invokeLater( - { - val pluginSettings = GlobalSettingsState.getInstance() + ApplicationManager.getApplication() + .invokeLater( + { + val pluginSettings = GlobalSettingsState.getInstance() - if (pluginSettings.showExecutionEnded) { - TinkerOutputToolWindowFactory.tinkerOutputToolWindow[project]?.addOutput( - Strings.get("lt.execution.finished") - ) - } + if (pluginSettings.showExecutionEnded) { + TinkerOutputToolWindowFactory.tinkerOutputToolWindow[project] + ?.addOutput(Strings.get("lt.execution.finished")) + } - if (PersistentApplicationCache.instance.state.executionsCount >= SUPPORT_MESSAGE_EXECUTIONS && !PatreonSupport.hasValidKey()) { - TinkerOutputToolWindowFactory.tinkerOutputToolWindow[project]?.plug = true - PersistentApplicationCache.instance.state.executionsCount = 0 - } - }, - ModalityState.NON_MODAL - ) + if (PersistentApplicationCache.instance.state.executionsCount >= + SUPPORT_MESSAGE_EXECUTIONS && !PatreonSupport.hasValidKey() + ) { + TinkerOutputToolWindowFactory.tinkerOutputToolWindow[project]?.plug = true + PersistentApplicationCache.instance.state.executionsCount = 0 + } + }, + ModalityState.NON_MODAL + ) } override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) { @@ -66,9 +70,10 @@ class PhpProcessListener(private val project: Project, private val processHandle } if (!capturing && capText.contains(OUTPUT_START_SEQUENCE)) { - capText = capText.substring( - capText.indexOf(OUTPUT_START_SEQUENCE) + OUTPUT_START_SEQUENCE.length - ) + capText = + capText.substring( + capText.indexOf(OUTPUT_START_SEQUENCE) + OUTPUT_START_SEQUENCE.length + ) capturing = true } if (capturing && capText.contains(OUTPUT_END_SEQUENCE)) { @@ -79,10 +84,14 @@ class PhpProcessListener(private val project: Project, private val processHandle if (capturing) { processOutput.add(capText) - ApplicationManager.getApplication().invokeLater( - { TinkerOutputToolWindowFactory.tinkerOutputToolWindow[project]?.addOutput(capText) }, - ModalityState.NON_MODAL - ) + ApplicationManager.getApplication() + .invokeLater( + { + TinkerOutputToolWindowFactory.tinkerOutputToolWindow[project] + ?.addOutput(capText) + }, + ModalityState.NON_MODAL + ) } } } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/settings/GlobalSettingsComponent.kt b/src/main/kotlin/nl/deschepers/laraveltinker/settings/GlobalSettingsComponent.kt index 8922ea0..ee6bcde 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/settings/GlobalSettingsComponent.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/settings/GlobalSettingsComponent.kt @@ -4,14 +4,16 @@ import com.intellij.ui.IdeBorderFactory import com.intellij.ui.components.JBCheckBox import com.intellij.ui.components.JBLabel import com.intellij.util.ui.FormBuilder -import nl.deschepers.laraveltinker.Strings import javax.swing.JPanel import javax.swing.JTextField +import nl.deschepers.laraveltinker.Strings class GlobalSettingsComponent { private var settingsPanel: JPanel - private val showExecutionStartedCheckbox = JBCheckBox(Strings.get("lt.setting.show_execution_start")) - private val showExecutionEndedCheckbox = JBCheckBox(Strings.get("lt.setting.show_execution_end")) + private val showExecutionStartedCheckbox = + JBCheckBox(Strings.get("lt.setting.show_execution_start")) + private val showExecutionEndedCheckbox = + JBCheckBox(Strings.get("lt.setting.show_execution_end")) private val useWordWrappingCheckbox = JBCheckBox(Strings.get("lt.setting.use_word_wrapping")) private val patreonKeyTextField = JTextField() @@ -37,27 +39,35 @@ class GlobalSettingsComponent { } init { - val outputSettingsPanel = FormBuilder.createFormBuilder() - .addComponent(showExecutionStartedCheckbox) - .addComponent(showExecutionEndedCheckbox) - .addComponent(useWordWrappingCheckbox) - .addComponentFillVertically(JPanel(), 0) - .panel - outputSettingsPanel.border = IdeBorderFactory.createTitledBorder(Strings.get("lt.settings.output_settings")) + val outputSettingsPanel = + FormBuilder.createFormBuilder() + .addComponent(showExecutionStartedCheckbox) + .addComponent(showExecutionEndedCheckbox) + .addComponent(useWordWrappingCheckbox) + .addComponentFillVertically(JPanel(), 0) + .panel + outputSettingsPanel.border = + IdeBorderFactory.createTitledBorder(Strings.get("lt.settings.output_settings")) - val otherSettingsPanel = FormBuilder.createFormBuilder() - .addLabeledComponent(JBLabel(Strings.get("lt.setting.patreon_key")), patreonKeyTextField) - .addTooltip(Strings.get("lt.setting.patreon_key.tooltip")) - .addTooltip(Strings.get("lt.setting.patreon_key.tooltip_patreon")) - .addComponentFillVertically(JPanel(), 0) - .panel - otherSettingsPanel.border = IdeBorderFactory.createTitledBorder(Strings.get("lt.settings.other_settings")) + val otherSettingsPanel = + FormBuilder.createFormBuilder() + .addLabeledComponent( + JBLabel(Strings.get("lt.setting.patreon_key")), + patreonKeyTextField + ) + .addTooltip(Strings.get("lt.setting.patreon_key.tooltip")) + .addTooltip(Strings.get("lt.setting.patreon_key.tooltip_patreon")) + .addComponentFillVertically(JPanel(), 0) + .panel + otherSettingsPanel.border = + IdeBorderFactory.createTitledBorder(Strings.get("lt.settings.other_settings")) - settingsPanel = FormBuilder.createFormBuilder() - .addComponent(outputSettingsPanel) - .addComponent(otherSettingsPanel) - .addComponentFillVertically(JPanel(), 0) - .panel + settingsPanel = + FormBuilder.createFormBuilder() + .addComponent(outputSettingsPanel) + .addComponent(otherSettingsPanel) + .addComponentFillVertically(JPanel(), 0) + .panel } fun getPanel(): JPanel { diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/settings/GlobalSettingsConfigurable.kt b/src/main/kotlin/nl/deschepers/laraveltinker/settings/GlobalSettingsConfigurable.kt index cce33e0..f9ec391 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/settings/GlobalSettingsConfigurable.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/settings/GlobalSettingsConfigurable.kt @@ -1,8 +1,8 @@ package nl.deschepers.laraveltinker.settings import com.intellij.openapi.options.Configurable -import nl.deschepers.laraveltinker.Strings import javax.swing.JComponent +import nl.deschepers.laraveltinker.Strings class GlobalSettingsConfigurable : Configurable { private var appSettingsComponent: GlobalSettingsComponent? = null diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/settings/PatreonSupport.kt b/src/main/kotlin/nl/deschepers/laraveltinker/settings/PatreonSupport.kt index 4b80fbc..e273998 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/settings/PatreonSupport.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/settings/PatreonSupport.kt @@ -2,496 +2,497 @@ package nl.deschepers.laraveltinker.settings import at.favre.lib.crypto.bcrypt.BCrypt -/** ========== - * Before you place a bug: I am aware this is insecure. - * I just don't want to bother actual Patreon supporters with my donation message - * Just note that decoding this does not give you any extra features - it JUST removes the "Please support me" message. - * Consider supporting me to get a legit key: - * see https://www.patreon.com/roboroads - * ========== */ - +/** + * ========== + * Before you place a bug: I am aware this is insecure. I just don't want to bother actual Patreon + * supporters with my donation message Just note that decoding this does not give you any extra + * features - it JUST removes the "Please support me" message. Consider supporting me to get a legit + * key: see https://www.patreon.com/roboroads + * ========== + */ object PatreonSupport { - private val KEY = object : Any() { - var t = 0 - override fun toString(): String { - val buf = ByteArray(237) - t = -201911662 - buf[0] = (t ushr 1).toByte() - t = 986482749 - buf[1] = (t ushr 5).toByte() - t = 1456563283 - buf[2] = (t ushr 20).toByte() - t = 181758622 - buf[3] = (t ushr 3).toByte() - t = 2134549888 - buf[4] = (t ushr 15).toByte() - t = -1916779236 - buf[5] = (t ushr 18).toByte() - t = 1718622616 - buf[6] = (t ushr 16).toByte() - t = 1130661631 - buf[7] = (t ushr 4).toByte() - t = -1819106682 - buf[8] = (t ushr 19).toByte() - t = 505421070 - buf[9] = (t ushr 6).toByte() - t = -1380543795 - buf[10] = (t ushr 12).toByte() - t = 798193625 - buf[11] = (t ushr 11).toByte() - t = -1393194839 - buf[12] = (t ushr 21).toByte() - t = 353989584 - buf[13] = (t ushr 22).toByte() - t = 677947252 - buf[14] = (t ushr 16).toByte() - t = -1403938007 - buf[15] = (t ushr 3).toByte() - t = -1091935413 - buf[16] = (t ushr 11).toByte() - t = -1429532768 - buf[17] = (t ushr 11).toByte() - t = 1845517489 - buf[18] = (t ushr 6).toByte() - t = -1425465224 - buf[19] = (t ushr 19).toByte() - t = 353037810 - buf[20] = (t ushr 9).toByte() - t = 241516162 - buf[21] = (t ushr 16).toByte() - t = -551875317 - buf[22] = (t ushr 14).toByte() - t = 827616899 - buf[23] = (t ushr 16).toByte() - t = 1677879753 - buf[24] = (t ushr 8).toByte() - t = -1414697221 - buf[25] = (t ushr 8).toByte() - t = -32557585 - buf[26] = (t ushr 7).toByte() - t = 1511608236 - buf[27] = (t ushr 14).toByte() - t = 174053092 - buf[28] = (t ushr 1).toByte() - t = 1532521792 - buf[29] = (t ushr 2).toByte() - t = 442971693 - buf[30] = (t ushr 7).toByte() - t = -396540465 - buf[31] = (t ushr 14).toByte() - t = 1221474271 - buf[32] = (t ushr 17).toByte() - t = -1934311384 - buf[33] = (t ushr 15).toByte() - t = 927124793 - buf[34] = (t ushr 23).toByte() - t = 101729614 - buf[35] = (t ushr 14).toByte() - t = 1328399400 - buf[36] = (t ushr 13).toByte() - t = -1167842114 - buf[37] = (t ushr 16).toByte() - t = -994475863 - buf[38] = (t ushr 1).toByte() - t = 932839822 - buf[39] = (t ushr 14).toByte() - t = -1847661391 - buf[40] = (t ushr 5).toByte() - t = -942274104 - buf[41] = (t ushr 2).toByte() - t = -703386241 - buf[42] = (t ushr 11).toByte() - t = 1495610232 - buf[43] = (t ushr 7).toByte() - t = -1147376193 - buf[44] = (t ushr 2).toByte() - t = 2073523547 - buf[45] = (t ushr 19).toByte() - t = -1520761258 - buf[46] = (t ushr 4).toByte() - t = 1050964984 - buf[47] = (t ushr 12).toByte() - t = -1061232739 - buf[48] = (t ushr 9).toByte() - t = 958014372 - buf[49] = (t ushr 3).toByte() - t = 9784244 - buf[50] = (t ushr 12).toByte() - t = 190947457 - buf[51] = (t ushr 10).toByte() - t = -1687538518 - buf[52] = (t ushr 7).toByte() - t = 2076499160 - buf[53] = (t ushr 6).toByte() - t = 2015816032 - buf[54] = (t ushr 5).toByte() - t = -1578701110 - buf[55] = (t ushr 1).toByte() - t = 1705109398 - buf[56] = (t ushr 4).toByte() - t = 19558709 - buf[57] = (t ushr 15).toByte() - t = 1276898950 - buf[58] = (t ushr 14).toByte() - t = -1723332859 - buf[59] = (t ushr 18).toByte() - t = -1380608927 - buf[60] = (t ushr 10).toByte() - t = -2096617713 - buf[61] = (t ushr 4).toByte() - t = 119585336 - buf[62] = (t ushr 20).toByte() - t = 191174389 - buf[63] = (t ushr 16).toByte() - t = 243209357 - buf[64] = (t ushr 21).toByte() - t = -489070204 - buf[65] = (t ushr 14).toByte() - t = -1120243991 - buf[66] = (t ushr 8).toByte() - t = 9890024 - buf[67] = (t ushr 1).toByte() - t = 2053894655 - buf[68] = (t ushr 19).toByte() - t = 651640024 - buf[69] = (t ushr 7).toByte() - t = 317871313 - buf[70] = (t ushr 6).toByte() - t = 123301177 - buf[71] = (t ushr 20).toByte() - t = 1340310418 - buf[72] = (t ushr 11).toByte() - t = 1022382978 - buf[73] = (t ushr 3).toByte() - t = 980563388 - buf[74] = (t ushr 2).toByte() - t = 395938707 - buf[75] = (t ushr 3).toByte() - t = -1172714173 - buf[76] = (t ushr 23).toByte() - t = 2088553563 - buf[77] = (t ushr 1).toByte() - t = -1526043493 - buf[78] = (t ushr 18).toByte() - t = -581622387 - buf[79] = (t ushr 16).toByte() - t = 2057824438 - buf[80] = (t ushr 19).toByte() - t = 361467060 - buf[81] = (t ushr 2).toByte() - t = 1393216353 - buf[82] = (t ushr 24).toByte() - t = -1227623136 - buf[83] = (t ushr 17).toByte() - t = -842943056 - buf[84] = (t ushr 21).toByte() - t = 418562887 - buf[85] = (t ushr 22).toByte() - t = -1842159002 - buf[86] = (t ushr 15).toByte() - t = 187478889 - buf[87] = (t ushr 21).toByte() - t = 233695899 - buf[88] = (t ushr 21).toByte() - t = -748965937 - buf[89] = (t ushr 11).toByte() - t = -1723725672 - buf[90] = (t ushr 11).toByte() - t = -1270534590 - buf[91] = (t ushr 5).toByte() - t = 1053595221 - buf[92] = (t ushr 4).toByte() - t = 1655248653 - buf[93] = (t ushr 15).toByte() - t = -117155027 - buf[94] = (t ushr 3).toByte() - t = 371677255 - buf[95] = (t ushr 6).toByte() - t = 1496668705 - buf[96] = (t ushr 22).toByte() - t = -1823537200 - buf[97] = (t ushr 19).toByte() - t = 1855582627 - buf[98] = (t ushr 24).toByte() - t = 1029817978 - buf[99] = (t ushr 4).toByte() - t = -1446161596 - buf[100] = (t ushr 10).toByte() - t = -1881642837 - buf[101] = (t ushr 8).toByte() - t = -359846071 - buf[102] = (t ushr 13).toByte() - t = 1558232800 - buf[103] = (t ushr 22).toByte() - t = 351679081 - buf[104] = (t ushr 22).toByte() - t = 1397207972 - buf[105] = (t ushr 3).toByte() - t = -515449677 - buf[106] = (t ushr 6).toByte() - t = 1515627522 - buf[107] = (t ushr 22).toByte() - t = -1915114834 - buf[108] = (t ushr 21).toByte() - t = -1113367140 - buf[109] = (t ushr 2).toByte() - t = -395369783 - buf[110] = (t ushr 3).toByte() - t = 1706554541 - buf[111] = (t ushr 15).toByte() - t = -1549174571 - buf[112] = (t ushr 19).toByte() - t = 585263620 - buf[113] = (t ushr 5).toByte() - t = -876239064 - buf[114] = (t ushr 4).toByte() - t = 2000140434 - buf[115] = (t ushr 15).toByte() - t = -1521506780 - buf[116] = (t ushr 4).toByte() - t = -2073971123 - buf[117] = (t ushr 16).toByte() - t = -2029317056 - buf[118] = (t ushr 11).toByte() - t = 1628880998 - buf[119] = (t ushr 12).toByte() - t = -840676091 - buf[120] = (t ushr 18).toByte() - t = 1642694698 - buf[121] = (t ushr 5).toByte() - t = -1190015772 - buf[122] = (t ushr 23).toByte() - t = 1026083427 - buf[123] = (t ushr 9).toByte() - t = -1793169082 - buf[124] = (t ushr 22).toByte() - t = -2122332380 - buf[125] = (t ushr 4).toByte() - t = -1892038251 - buf[126] = (t ushr 21).toByte() - t = 1777809094 - buf[127] = (t ushr 24).toByte() - t = -996739349 - buf[128] = (t ushr 4).toByte() - t = -1768297235 - buf[129] = (t ushr 5).toByte() - t = -1442654809 - buf[130] = (t ushr 23).toByte() - t = 468096079 - buf[131] = (t ushr 22).toByte() - t = -250444233 - buf[132] = (t ushr 9).toByte() - t = -1446314122 - buf[133] = (t ushr 18).toByte() - t = -1372393773 - buf[134] = (t ushr 15).toByte() - t = 1259023556 - buf[135] = (t ushr 19).toByte() - t = -1659633546 - buf[136] = (t ushr 22).toByte() - t = 1035547351 - buf[137] = (t ushr 7).toByte() - t = 575390980 - buf[138] = (t ushr 2).toByte() - t = -775383186 - buf[139] = (t ushr 9).toByte() - t = -1235595305 - buf[140] = (t ushr 20).toByte() - t = -1411932885 - buf[141] = (t ushr 12).toByte() - t = -1940801974 - buf[142] = (t ushr 14).toByte() - t = -138707046 - buf[143] = (t ushr 11).toByte() - t = 18657850 - buf[144] = (t ushr 14).toByte() - t = -361288463 - buf[145] = (t ushr 7).toByte() - t = 467619962 - buf[146] = (t ushr 22).toByte() - t = 784184601 - buf[147] = (t ushr 21).toByte() - t = -100346074 - buf[148] = (t ushr 4).toByte() - t = -162816148 - buf[149] = (t ushr 11).toByte() - t = 1395519627 - buf[150] = (t ushr 19).toByte() - t = -1381536576 - buf[151] = (t ushr 8).toByte() - t = 1753638598 - buf[152] = (t ushr 12).toByte() - t = 1641155300 - buf[153] = (t ushr 5).toByte() - t = -2039109718 - buf[154] = (t ushr 10).toByte() - t = -145874199 - buf[155] = (t ushr 20).toByte() - t = 958452070 - buf[156] = (t ushr 9).toByte() - t = 595331683 - buf[157] = (t ushr 19).toByte() - t = 831436247 - buf[158] = (t ushr 2).toByte() - t = -1365519888 - buf[159] = (t ushr 21).toByte() - t = 348659963 - buf[160] = (t ushr 22).toByte() - t = -1701925831 - buf[161] = (t ushr 13).toByte() - t = 386124598 - buf[162] = (t ushr 20).toByte() - t = 1884419768 - buf[163] = (t ushr 24).toByte() - t = -2106138855 - buf[164] = (t ushr 9).toByte() - t = -651436871 - buf[165] = (t ushr 6).toByte() - t = -925635673 - buf[166] = (t ushr 3).toByte() - t = 1686431380 - buf[167] = (t ushr 4).toByte() - t = -1555449350 - buf[168] = (t ushr 10).toByte() - t = -899310022 - buf[169] = (t ushr 10).toByte() - t = -1363863025 - buf[170] = (t ushr 3).toByte() - t = -777685267 - buf[171] = (t ushr 4).toByte() - t = 540747006 - buf[172] = (t ushr 11).toByte() - t = 748746838 - buf[173] = (t ushr 23).toByte() - t = -448203019 - buf[174] = (t ushr 4).toByte() - t = -573225838 - buf[175] = (t ushr 18).toByte() - t = 472507685 - buf[176] = (t ushr 15).toByte() - t = -363186706 - buf[177] = (t ushr 14).toByte() - t = -1460282395 - buf[178] = (t ushr 6).toByte() - t = -1696318548 - buf[179] = (t ushr 3).toByte() - t = -1886992489 - buf[180] = (t ushr 12).toByte() - t = 1825531108 - buf[181] = (t ushr 8).toByte() - t = -290946008 - buf[182] = (t ushr 4).toByte() - t = 1499803318 - buf[183] = (t ushr 22).toByte() - t = -661583348 - buf[184] = (t ushr 3).toByte() - t = 1513381327 - buf[185] = (t ushr 2).toByte() - t = -1694489790 - buf[186] = (t ushr 3).toByte() - t = -778536877 - buf[187] = (t ushr 14).toByte() - t = 1049470373 - buf[188] = (t ushr 13).toByte() - t = 815778603 - buf[189] = (t ushr 3).toByte() - t = 1722206459 - buf[190] = (t ushr 9).toByte() - t = 1252755943 - buf[191] = (t ushr 5).toByte() - t = 1039617217 - buf[192] = (t ushr 5).toByte() - t = -1966178602 - buf[193] = (t ushr 19).toByte() - t = -1831178353 - buf[194] = (t ushr 8).toByte() - t = 1103686549 - buf[195] = (t ushr 9).toByte() - t = -1351759320 - buf[196] = (t ushr 10).toByte() - t = 658304756 - buf[197] = (t ushr 20).toByte() - t = 794839446 - buf[198] = (t ushr 2).toByte() - t = 1791678528 - buf[199] = (t ushr 9).toByte() - t = 478653236 - buf[200] = (t ushr 3).toByte() - t = -526320932 - buf[201] = (t ushr 18).toByte() - t = -646563388 - buf[202] = (t ushr 12).toByte() - t = 1932053074 - buf[203] = (t ushr 6).toByte() - t = -534670749 - buf[204] = (t ushr 11).toByte() - t = -1887894774 - buf[205] = (t ushr 4).toByte() - t = -2041977214 - buf[206] = (t ushr 21).toByte() - t = -1290563112 - buf[207] = (t ushr 20).toByte() - t = 86942167 - buf[208] = (t ushr 20).toByte() - t = 606020031 - buf[209] = (t ushr 2).toByte() - t = 743810107 - buf[210] = (t ushr 21).toByte() - t = -164011421 - buf[211] = (t ushr 8).toByte() - t = 419654965 - buf[212] = (t ushr 5).toByte() - t = -1683067661 - buf[213] = (t ushr 22).toByte() - t = -91663496 - buf[214] = (t ushr 8).toByte() - t = -1056383802 - buf[215] = (t ushr 1).toByte() - t = -635084470 - buf[216] = (t ushr 22).toByte() - t = 1120947386 - buf[217] = (t ushr 5).toByte() - t = 672367013 - buf[218] = (t ushr 11).toByte() - t = 677736673 - buf[219] = (t ushr 16).toByte() - t = -2103385023 - buf[220] = (t ushr 9).toByte() - t = 1462226554 - buf[221] = (t ushr 5).toByte() - t = -1970999918 - buf[222] = (t ushr 19).toByte() - t = 1882042891 - buf[223] = (t ushr 10).toByte() - t = 1801282926 - buf[224] = (t ushr 8).toByte() - t = 909172579 - buf[225] = (t ushr 15).toByte() - t = 1134099442 - buf[226] = (t ushr 19).toByte() - t = -376144602 - buf[227] = (t ushr 18).toByte() - t = 603884070 - buf[228] = (t ushr 3).toByte() - t = -2089037016 - buf[229] = (t ushr 19).toByte() - t = 384582111 - buf[230] = (t ushr 20).toByte() - t = -174528424 - buf[231] = (t ushr 9).toByte() - t = 1112319588 - buf[232] = (t ushr 9).toByte() - t = 1087271936 - buf[233] = (t ushr 8).toByte() - t = 528165716 - buf[234] = (t ushr 11).toByte() - t = 1633207626 - buf[235] = (t ushr 24).toByte() - t = 727810118 - buf[236] = (t ushr 19).toByte() - return String(buf) - } - }.toString() + private val KEY = + object : Any() { + var t = 0 + override fun toString(): String { + val buf = ByteArray(237) + t = -201911662 + buf[0] = (t ushr 1).toByte() + t = 986482749 + buf[1] = (t ushr 5).toByte() + t = 1456563283 + buf[2] = (t ushr 20).toByte() + t = 181758622 + buf[3] = (t ushr 3).toByte() + t = 2134549888 + buf[4] = (t ushr 15).toByte() + t = -1916779236 + buf[5] = (t ushr 18).toByte() + t = 1718622616 + buf[6] = (t ushr 16).toByte() + t = 1130661631 + buf[7] = (t ushr 4).toByte() + t = -1819106682 + buf[8] = (t ushr 19).toByte() + t = 505421070 + buf[9] = (t ushr 6).toByte() + t = -1380543795 + buf[10] = (t ushr 12).toByte() + t = 798193625 + buf[11] = (t ushr 11).toByte() + t = -1393194839 + buf[12] = (t ushr 21).toByte() + t = 353989584 + buf[13] = (t ushr 22).toByte() + t = 677947252 + buf[14] = (t ushr 16).toByte() + t = -1403938007 + buf[15] = (t ushr 3).toByte() + t = -1091935413 + buf[16] = (t ushr 11).toByte() + t = -1429532768 + buf[17] = (t ushr 11).toByte() + t = 1845517489 + buf[18] = (t ushr 6).toByte() + t = -1425465224 + buf[19] = (t ushr 19).toByte() + t = 353037810 + buf[20] = (t ushr 9).toByte() + t = 241516162 + buf[21] = (t ushr 16).toByte() + t = -551875317 + buf[22] = (t ushr 14).toByte() + t = 827616899 + buf[23] = (t ushr 16).toByte() + t = 1677879753 + buf[24] = (t ushr 8).toByte() + t = -1414697221 + buf[25] = (t ushr 8).toByte() + t = -32557585 + buf[26] = (t ushr 7).toByte() + t = 1511608236 + buf[27] = (t ushr 14).toByte() + t = 174053092 + buf[28] = (t ushr 1).toByte() + t = 1532521792 + buf[29] = (t ushr 2).toByte() + t = 442971693 + buf[30] = (t ushr 7).toByte() + t = -396540465 + buf[31] = (t ushr 14).toByte() + t = 1221474271 + buf[32] = (t ushr 17).toByte() + t = -1934311384 + buf[33] = (t ushr 15).toByte() + t = 927124793 + buf[34] = (t ushr 23).toByte() + t = 101729614 + buf[35] = (t ushr 14).toByte() + t = 1328399400 + buf[36] = (t ushr 13).toByte() + t = -1167842114 + buf[37] = (t ushr 16).toByte() + t = -994475863 + buf[38] = (t ushr 1).toByte() + t = 932839822 + buf[39] = (t ushr 14).toByte() + t = -1847661391 + buf[40] = (t ushr 5).toByte() + t = -942274104 + buf[41] = (t ushr 2).toByte() + t = -703386241 + buf[42] = (t ushr 11).toByte() + t = 1495610232 + buf[43] = (t ushr 7).toByte() + t = -1147376193 + buf[44] = (t ushr 2).toByte() + t = 2073523547 + buf[45] = (t ushr 19).toByte() + t = -1520761258 + buf[46] = (t ushr 4).toByte() + t = 1050964984 + buf[47] = (t ushr 12).toByte() + t = -1061232739 + buf[48] = (t ushr 9).toByte() + t = 958014372 + buf[49] = (t ushr 3).toByte() + t = 9784244 + buf[50] = (t ushr 12).toByte() + t = 190947457 + buf[51] = (t ushr 10).toByte() + t = -1687538518 + buf[52] = (t ushr 7).toByte() + t = 2076499160 + buf[53] = (t ushr 6).toByte() + t = 2015816032 + buf[54] = (t ushr 5).toByte() + t = -1578701110 + buf[55] = (t ushr 1).toByte() + t = 1705109398 + buf[56] = (t ushr 4).toByte() + t = 19558709 + buf[57] = (t ushr 15).toByte() + t = 1276898950 + buf[58] = (t ushr 14).toByte() + t = -1723332859 + buf[59] = (t ushr 18).toByte() + t = -1380608927 + buf[60] = (t ushr 10).toByte() + t = -2096617713 + buf[61] = (t ushr 4).toByte() + t = 119585336 + buf[62] = (t ushr 20).toByte() + t = 191174389 + buf[63] = (t ushr 16).toByte() + t = 243209357 + buf[64] = (t ushr 21).toByte() + t = -489070204 + buf[65] = (t ushr 14).toByte() + t = -1120243991 + buf[66] = (t ushr 8).toByte() + t = 9890024 + buf[67] = (t ushr 1).toByte() + t = 2053894655 + buf[68] = (t ushr 19).toByte() + t = 651640024 + buf[69] = (t ushr 7).toByte() + t = 317871313 + buf[70] = (t ushr 6).toByte() + t = 123301177 + buf[71] = (t ushr 20).toByte() + t = 1340310418 + buf[72] = (t ushr 11).toByte() + t = 1022382978 + buf[73] = (t ushr 3).toByte() + t = 980563388 + buf[74] = (t ushr 2).toByte() + t = 395938707 + buf[75] = (t ushr 3).toByte() + t = -1172714173 + buf[76] = (t ushr 23).toByte() + t = 2088553563 + buf[77] = (t ushr 1).toByte() + t = -1526043493 + buf[78] = (t ushr 18).toByte() + t = -581622387 + buf[79] = (t ushr 16).toByte() + t = 2057824438 + buf[80] = (t ushr 19).toByte() + t = 361467060 + buf[81] = (t ushr 2).toByte() + t = 1393216353 + buf[82] = (t ushr 24).toByte() + t = -1227623136 + buf[83] = (t ushr 17).toByte() + t = -842943056 + buf[84] = (t ushr 21).toByte() + t = 418562887 + buf[85] = (t ushr 22).toByte() + t = -1842159002 + buf[86] = (t ushr 15).toByte() + t = 187478889 + buf[87] = (t ushr 21).toByte() + t = 233695899 + buf[88] = (t ushr 21).toByte() + t = -748965937 + buf[89] = (t ushr 11).toByte() + t = -1723725672 + buf[90] = (t ushr 11).toByte() + t = -1270534590 + buf[91] = (t ushr 5).toByte() + t = 1053595221 + buf[92] = (t ushr 4).toByte() + t = 1655248653 + buf[93] = (t ushr 15).toByte() + t = -117155027 + buf[94] = (t ushr 3).toByte() + t = 371677255 + buf[95] = (t ushr 6).toByte() + t = 1496668705 + buf[96] = (t ushr 22).toByte() + t = -1823537200 + buf[97] = (t ushr 19).toByte() + t = 1855582627 + buf[98] = (t ushr 24).toByte() + t = 1029817978 + buf[99] = (t ushr 4).toByte() + t = -1446161596 + buf[100] = (t ushr 10).toByte() + t = -1881642837 + buf[101] = (t ushr 8).toByte() + t = -359846071 + buf[102] = (t ushr 13).toByte() + t = 1558232800 + buf[103] = (t ushr 22).toByte() + t = 351679081 + buf[104] = (t ushr 22).toByte() + t = 1397207972 + buf[105] = (t ushr 3).toByte() + t = -515449677 + buf[106] = (t ushr 6).toByte() + t = 1515627522 + buf[107] = (t ushr 22).toByte() + t = -1915114834 + buf[108] = (t ushr 21).toByte() + t = -1113367140 + buf[109] = (t ushr 2).toByte() + t = -395369783 + buf[110] = (t ushr 3).toByte() + t = 1706554541 + buf[111] = (t ushr 15).toByte() + t = -1549174571 + buf[112] = (t ushr 19).toByte() + t = 585263620 + buf[113] = (t ushr 5).toByte() + t = -876239064 + buf[114] = (t ushr 4).toByte() + t = 2000140434 + buf[115] = (t ushr 15).toByte() + t = -1521506780 + buf[116] = (t ushr 4).toByte() + t = -2073971123 + buf[117] = (t ushr 16).toByte() + t = -2029317056 + buf[118] = (t ushr 11).toByte() + t = 1628880998 + buf[119] = (t ushr 12).toByte() + t = -840676091 + buf[120] = (t ushr 18).toByte() + t = 1642694698 + buf[121] = (t ushr 5).toByte() + t = -1190015772 + buf[122] = (t ushr 23).toByte() + t = 1026083427 + buf[123] = (t ushr 9).toByte() + t = -1793169082 + buf[124] = (t ushr 22).toByte() + t = -2122332380 + buf[125] = (t ushr 4).toByte() + t = -1892038251 + buf[126] = (t ushr 21).toByte() + t = 1777809094 + buf[127] = (t ushr 24).toByte() + t = -996739349 + buf[128] = (t ushr 4).toByte() + t = -1768297235 + buf[129] = (t ushr 5).toByte() + t = -1442654809 + buf[130] = (t ushr 23).toByte() + t = 468096079 + buf[131] = (t ushr 22).toByte() + t = -250444233 + buf[132] = (t ushr 9).toByte() + t = -1446314122 + buf[133] = (t ushr 18).toByte() + t = -1372393773 + buf[134] = (t ushr 15).toByte() + t = 1259023556 + buf[135] = (t ushr 19).toByte() + t = -1659633546 + buf[136] = (t ushr 22).toByte() + t = 1035547351 + buf[137] = (t ushr 7).toByte() + t = 575390980 + buf[138] = (t ushr 2).toByte() + t = -775383186 + buf[139] = (t ushr 9).toByte() + t = -1235595305 + buf[140] = (t ushr 20).toByte() + t = -1411932885 + buf[141] = (t ushr 12).toByte() + t = -1940801974 + buf[142] = (t ushr 14).toByte() + t = -138707046 + buf[143] = (t ushr 11).toByte() + t = 18657850 + buf[144] = (t ushr 14).toByte() + t = -361288463 + buf[145] = (t ushr 7).toByte() + t = 467619962 + buf[146] = (t ushr 22).toByte() + t = 784184601 + buf[147] = (t ushr 21).toByte() + t = -100346074 + buf[148] = (t ushr 4).toByte() + t = -162816148 + buf[149] = (t ushr 11).toByte() + t = 1395519627 + buf[150] = (t ushr 19).toByte() + t = -1381536576 + buf[151] = (t ushr 8).toByte() + t = 1753638598 + buf[152] = (t ushr 12).toByte() + t = 1641155300 + buf[153] = (t ushr 5).toByte() + t = -2039109718 + buf[154] = (t ushr 10).toByte() + t = -145874199 + buf[155] = (t ushr 20).toByte() + t = 958452070 + buf[156] = (t ushr 9).toByte() + t = 595331683 + buf[157] = (t ushr 19).toByte() + t = 831436247 + buf[158] = (t ushr 2).toByte() + t = -1365519888 + buf[159] = (t ushr 21).toByte() + t = 348659963 + buf[160] = (t ushr 22).toByte() + t = -1701925831 + buf[161] = (t ushr 13).toByte() + t = 386124598 + buf[162] = (t ushr 20).toByte() + t = 1884419768 + buf[163] = (t ushr 24).toByte() + t = -2106138855 + buf[164] = (t ushr 9).toByte() + t = -651436871 + buf[165] = (t ushr 6).toByte() + t = -925635673 + buf[166] = (t ushr 3).toByte() + t = 1686431380 + buf[167] = (t ushr 4).toByte() + t = -1555449350 + buf[168] = (t ushr 10).toByte() + t = -899310022 + buf[169] = (t ushr 10).toByte() + t = -1363863025 + buf[170] = (t ushr 3).toByte() + t = -777685267 + buf[171] = (t ushr 4).toByte() + t = 540747006 + buf[172] = (t ushr 11).toByte() + t = 748746838 + buf[173] = (t ushr 23).toByte() + t = -448203019 + buf[174] = (t ushr 4).toByte() + t = -573225838 + buf[175] = (t ushr 18).toByte() + t = 472507685 + buf[176] = (t ushr 15).toByte() + t = -363186706 + buf[177] = (t ushr 14).toByte() + t = -1460282395 + buf[178] = (t ushr 6).toByte() + t = -1696318548 + buf[179] = (t ushr 3).toByte() + t = -1886992489 + buf[180] = (t ushr 12).toByte() + t = 1825531108 + buf[181] = (t ushr 8).toByte() + t = -290946008 + buf[182] = (t ushr 4).toByte() + t = 1499803318 + buf[183] = (t ushr 22).toByte() + t = -661583348 + buf[184] = (t ushr 3).toByte() + t = 1513381327 + buf[185] = (t ushr 2).toByte() + t = -1694489790 + buf[186] = (t ushr 3).toByte() + t = -778536877 + buf[187] = (t ushr 14).toByte() + t = 1049470373 + buf[188] = (t ushr 13).toByte() + t = 815778603 + buf[189] = (t ushr 3).toByte() + t = 1722206459 + buf[190] = (t ushr 9).toByte() + t = 1252755943 + buf[191] = (t ushr 5).toByte() + t = 1039617217 + buf[192] = (t ushr 5).toByte() + t = -1966178602 + buf[193] = (t ushr 19).toByte() + t = -1831178353 + buf[194] = (t ushr 8).toByte() + t = 1103686549 + buf[195] = (t ushr 9).toByte() + t = -1351759320 + buf[196] = (t ushr 10).toByte() + t = 658304756 + buf[197] = (t ushr 20).toByte() + t = 794839446 + buf[198] = (t ushr 2).toByte() + t = 1791678528 + buf[199] = (t ushr 9).toByte() + t = 478653236 + buf[200] = (t ushr 3).toByte() + t = -526320932 + buf[201] = (t ushr 18).toByte() + t = -646563388 + buf[202] = (t ushr 12).toByte() + t = 1932053074 + buf[203] = (t ushr 6).toByte() + t = -534670749 + buf[204] = (t ushr 11).toByte() + t = -1887894774 + buf[205] = (t ushr 4).toByte() + t = -2041977214 + buf[206] = (t ushr 21).toByte() + t = -1290563112 + buf[207] = (t ushr 20).toByte() + t = 86942167 + buf[208] = (t ushr 20).toByte() + t = 606020031 + buf[209] = (t ushr 2).toByte() + t = 743810107 + buf[210] = (t ushr 21).toByte() + t = -164011421 + buf[211] = (t ushr 8).toByte() + t = 419654965 + buf[212] = (t ushr 5).toByte() + t = -1683067661 + buf[213] = (t ushr 22).toByte() + t = -91663496 + buf[214] = (t ushr 8).toByte() + t = -1056383802 + buf[215] = (t ushr 1).toByte() + t = -635084470 + buf[216] = (t ushr 22).toByte() + t = 1120947386 + buf[217] = (t ushr 5).toByte() + t = 672367013 + buf[218] = (t ushr 11).toByte() + t = 677736673 + buf[219] = (t ushr 16).toByte() + t = -2103385023 + buf[220] = (t ushr 9).toByte() + t = 1462226554 + buf[221] = (t ushr 5).toByte() + t = -1970999918 + buf[222] = (t ushr 19).toByte() + t = 1882042891 + buf[223] = (t ushr 10).toByte() + t = 1801282926 + buf[224] = (t ushr 8).toByte() + t = 909172579 + buf[225] = (t ushr 15).toByte() + t = 1134099442 + buf[226] = (t ushr 19).toByte() + t = -376144602 + buf[227] = (t ushr 18).toByte() + t = 603884070 + buf[228] = (t ushr 3).toByte() + t = -2089037016 + buf[229] = (t ushr 19).toByte() + t = 384582111 + buf[230] = (t ushr 20).toByte() + t = -174528424 + buf[231] = (t ushr 9).toByte() + t = 1112319588 + buf[232] = (t ushr 9).toByte() + t = 1087271936 + buf[233] = (t ushr 8).toByte() + t = 528165716 + buf[234] = (t ushr 11).toByte() + t = 1633207626 + buf[235] = (t ushr 24).toByte() + t = 727810118 + buf[236] = (t ushr 19).toByte() + return String(buf) + } + }.toString() fun hasValidKey(): Boolean { val pluginSettings = GlobalSettingsState.getInstance() @@ -502,6 +503,8 @@ object PatreonSupport { actualKey += KEY[i] } - return BCrypt.verifyer().verify(actualKey.toCharArray(), pluginSettings.patreonKey.toCharArray()).verified + return BCrypt.verifyer() + .verify(actualKey.toCharArray(), pluginSettings.patreonKey.toCharArray()) + .verified } } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/settings/PersistentApplicationCache.kt b/src/main/kotlin/nl/deschepers/laraveltinker/settings/PersistentApplicationCache.kt index 4221de7..7ce3385 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/settings/PersistentApplicationCache.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/settings/PersistentApplicationCache.kt @@ -5,15 +5,13 @@ import com.intellij.openapi.components.PersistentStateComponent import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage -@State( - reloadable = true, - name = "laravelTinker", - storages = [Storage("laravel-tinker-plugin.xml")] -) +@State(reloadable = true, name = "laravelTinker", storages = [Storage("laravel-tinker-plugin.xml")]) class PersistentApplicationCache : PersistentStateComponent { companion object { val instance: PersistentApplicationCache - get() = ApplicationManager.getApplication().getService(PersistentApplicationCache::class.java) + get() = + ApplicationManager.getApplication() + .getService(PersistentApplicationCache::class.java) } class State { diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/settings/ProjectSettingsComponent.kt b/src/main/kotlin/nl/deschepers/laraveltinker/settings/ProjectSettingsComponent.kt index 957bf01..2fee413 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/settings/ProjectSettingsComponent.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/settings/ProjectSettingsComponent.kt @@ -6,8 +6,8 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton import com.intellij.ui.IdeBorderFactory import com.intellij.ui.components.JBLabel import com.intellij.util.ui.FormBuilder -import nl.deschepers.laraveltinker.Strings import javax.swing.JPanel +import nl.deschepers.laraveltinker.Strings class ProjectSettingsComponent { private var settingsPanel: JPanel @@ -21,25 +21,28 @@ class ProjectSettingsComponent { init { laravelRootTextField.addBrowseFolderListener( - TextBrowseFolderListener( - FileChooserDescriptorFactory - .createSingleFolderDescriptor() - ) + TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFolderDescriptor()) ) - val projectSettingsPanel = FormBuilder.createFormBuilder() - .addLabeledComponent(JBLabel(Strings.get("lt.setting.laravel_root")), laravelRootTextField) - .addTooltip(Strings.get("lt.setting.laravel_root.tooltip1")) - .addTooltip(Strings.get("lt.setting.laravel_root.tooltip2")) - .addTooltip(Strings.get("lt.setting.laravel_root.tooltip3")) - .addComponentFillVertically(JPanel(), 0) - .panel - projectSettingsPanel.border = IdeBorderFactory.createTitledBorder(Strings.get("lt.settings.project_settings")) + val projectSettingsPanel = + FormBuilder.createFormBuilder() + .addLabeledComponent( + JBLabel(Strings.get("lt.setting.laravel_root")), + laravelRootTextField + ) + .addTooltip(Strings.get("lt.setting.laravel_root.tooltip1")) + .addTooltip(Strings.get("lt.setting.laravel_root.tooltip2")) + .addTooltip(Strings.get("lt.setting.laravel_root.tooltip3")) + .addComponentFillVertically(JPanel(), 0) + .panel + projectSettingsPanel.border = + IdeBorderFactory.createTitledBorder(Strings.get("lt.settings.project_settings")) - settingsPanel = FormBuilder.createFormBuilder() - .addComponent(projectSettingsPanel) - .addComponentFillVertically(JPanel(), 0) - .panel + settingsPanel = + FormBuilder.createFormBuilder() + .addComponent(projectSettingsPanel) + .addComponentFillVertically(JPanel(), 0) + .panel } fun getPanel(): JPanel { diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/settings/ProjectSettingsConfigurable.kt b/src/main/kotlin/nl/deschepers/laraveltinker/settings/ProjectSettingsConfigurable.kt index 381c26f..0efda5d 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/settings/ProjectSettingsConfigurable.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/settings/ProjectSettingsConfigurable.kt @@ -2,8 +2,8 @@ package nl.deschepers.laraveltinker.settings import com.intellij.openapi.options.Configurable import com.intellij.openapi.project.Project -import nl.deschepers.laraveltinker.Strings import javax.swing.JComponent +import nl.deschepers.laraveltinker.Strings class ProjectSettingsConfigurable(private var project: Project) : Configurable { private var projectSettingsComponent: ProjectSettingsComponent? = null diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/startup/Migrations.kt b/src/main/kotlin/nl/deschepers/laraveltinker/startup/Migrations.kt index 54e970c..83fb555 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/startup/Migrations.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/startup/Migrations.kt @@ -10,11 +10,16 @@ import nl.deschepers.laraveltinker.startup.migrations.MakeSureConsolesHaveExtens class Migrations : StartupActivity { override fun runActivity(project: Project) { - val currentMigrateVersion = Version.parseVersion(PersistentApplicationCache.instance.state.migrateVersion) - val currentPluginVersion = Version.parseVersion(PluginManagerCore.getPlugin(PluginId.getId("nl.deschepers.laraveltinker"))!!.version) + val currentMigrateVersion = + Version.parseVersion(PersistentApplicationCache.instance.state.migrateVersion) + val currentPluginVersion = + Version.parseVersion( + PluginManagerCore.getPlugin(PluginId.getId("nl.deschepers.laraveltinker"))!!.version + ) if (currentMigrateVersion == currentPluginVersion) return - if (currentMigrateVersion < Version.parseVersion("2.2.2-beta.3")) MakeSureConsolesHaveExtensions().up() + if (currentMigrateVersion < Version.parseVersion("2.2.2-beta.3")) + MakeSureConsolesHaveExtensions().up() PersistentApplicationCache.instance.state.migrateVersion = currentPluginVersion.toString() } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/startup/migrations/MakeSureConsolesHaveExtensions.kt b/src/main/kotlin/nl/deschepers/laraveltinker/startup/migrations/MakeSureConsolesHaveExtensions.kt index c95f3b6..2514a83 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/startup/migrations/MakeSureConsolesHaveExtensions.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/startup/migrations/MakeSureConsolesHaveExtensions.kt @@ -1,17 +1,20 @@ package nl.deschepers.laraveltinker.startup.migrations import com.intellij.ide.scratch.ScratchFileService -import nl.deschepers.laraveltinker.util.LaravelTinkerConsolesRootType import java.io.File +import nl.deschepers.laraveltinker.util.LaravelTinkerConsolesRootType class MakeSureConsolesHaveExtensions { fun up() { - val consoleDirectory = ScratchFileService.getInstance().getRootPath(LaravelTinkerConsolesRootType.getInstance()) - File(consoleDirectory).listFiles()?.forEachIndexed { i, file -> - file.renameTo( - File("${consoleDirectory}/LaravelTinkerConsole${if (i > 0) "_$i" else ""}.php") - ) - } + val consoleDirectory = + ScratchFileService.getInstance() + .getRootPath(LaravelTinkerConsolesRootType.getInstance()) + File(consoleDirectory).listFiles() + ?.forEachIndexed { i, file -> + file.renameTo( + File("${consoleDirectory}/LaravelTinkerConsole${if (i > 0) "_$i" else ""}.php") + ) + } } } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/toolwindow/TinkerOutputToolWindowFactory.kt b/src/main/kotlin/nl/deschepers/laraveltinker/toolwindow/TinkerOutputToolWindowFactory.kt index 54e4845..00d5cb6 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/toolwindow/TinkerOutputToolWindowFactory.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/toolwindow/TinkerOutputToolWindowFactory.kt @@ -24,8 +24,7 @@ class TinkerOutputToolWindowFactory : ToolWindowFactory { val instance = TinkerOutputToolwindow(toolWindow) tinkerOutputToolWindow[project] = instance val contentFactory = ContentFactory.SERVICE.getInstance() - val content: Content = - contentFactory.createContent(instance.getContent(), "", false) + val content: Content = contentFactory.createContent(instance.getContent(), "", false) toolWindow.contentManager.addContent(content) } } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/toolwindow/TinkerOutputToolwindow.kt b/src/main/kotlin/nl/deschepers/laraveltinker/toolwindow/TinkerOutputToolwindow.kt index 4249307..897cf92 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/toolwindow/TinkerOutputToolwindow.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/toolwindow/TinkerOutputToolwindow.kt @@ -2,10 +2,7 @@ package nl.deschepers.laraveltinker.toolwindow import com.intellij.openapi.editor.DefaultLanguageHighlighterColors import com.intellij.openapi.editor.HighlighterColors -import com.intellij.openapi.editor.colors.EditorColorsManager import com.intellij.openapi.wm.ToolWindow -import nl.deschepers.laraveltinker.Strings -import nl.deschepers.laraveltinker.settings.GlobalSettingsState import java.awt.Color import java.awt.Desktop import java.awt.Dimension @@ -24,6 +21,8 @@ import javax.swing.text.html.InlineView import javax.swing.text.html.ParagraphView import kotlin.concurrent.schedule import kotlin.math.max +import nl.deschepers.laraveltinker.Strings +import nl.deschepers.laraveltinker.settings.GlobalSettingsState class TinkerOutputToolwindow(private val toolWindow: ToolWindow) { private var tinkerOutputToolWindowContent: JPanel? = null @@ -36,14 +35,14 @@ class TinkerOutputToolwindow(private val toolWindow: ToolWindow) { private val pluginSettings = GlobalSettingsState.getInstance() init { - tinkerOutput!!.addHyperlinkListener { e -> - if ( - e.eventType == HyperlinkEvent.EventType.ACTIVATED && - Desktop.isDesktopSupported() - ) { - Desktop.getDesktop().browse(e.url.toURI()) + tinkerOutput!! + .addHyperlinkListener { e -> + if (e.eventType == HyperlinkEvent.EventType.ACTIVATED && + Desktop.isDesktopSupported() + ) { + Desktop.getDesktop().browse(e.url.toURI()) + } } - } tinkerOutput!!.background = null tinkerOutput!!.foreground = null @@ -66,11 +65,12 @@ class TinkerOutputToolwindow(private val toolWindow: ToolWindow) { if (!timer) { timer = true - Timer("UpdateTinkerOutput", false).schedule(250) { - outputText = outputText.replace("%%EOT%%", "") - updateView() - timer = false - } + Timer("UpdateTinkerOutput", false) + .schedule(250) { + outputText = outputText.replace("%%EOT%%", "") + updateView() + timer = false + } } } @@ -79,14 +79,16 @@ class TinkerOutputToolwindow(private val toolWindow: ToolWindow) { } private fun sanitizeOutput(str: String): String { - return str.replace("", "") - .replace("<", "<") - .replace(">", ">") + return str.replace("", "").replace("<", "<").replace(">", ">") } private fun updateView() { val color = toHex(HighlighterColors.TEXT.defaultAttributes.foregroundColor ?: Color.BLACK) - val timeString = if (pluginSettings.showExecutionStarted) Strings.get("lt.started.at", outputTime) else "" + val timeString = + if (pluginSettings.showExecutionStarted) + Strings.get("lt.started.at", outputTime) + else + "" val highlightedOutput = highlightSyntax("\n" + sanitizeOutput(outputText)) if (pluginSettings.useWordWrapping) { @@ -140,10 +142,13 @@ class TinkerOutputToolwindow(private val toolWindow: ToolWindow) { } private fun highlightSyntax(text: String): String { - val stringColor = DefaultLanguageHighlighterColors.STRING.defaultAttributes.foregroundColor ?: Color.BLACK - val numberColor = DefaultLanguageHighlighterColors.NUMBER.defaultAttributes.foregroundColor ?: Color.BLACK - val propColor = DefaultLanguageHighlighterColors.INSTANCE_FIELD.defaultAttributes - .foregroundColor ?: Color.BLACK + val stringColor = + DefaultLanguageHighlighterColors.STRING.defaultAttributes.foregroundColor ?: Color.BLACK + val numberColor = + DefaultLanguageHighlighterColors.NUMBER.defaultAttributes.foregroundColor ?: Color.BLACK + val propColor = + DefaultLanguageHighlighterColors.INSTANCE_FIELD.defaultAttributes.foregroundColor + ?: Color.BLACK val regex = Regex("(.*\n=>)(.*)", RegexOption.DOT_MATCHES_ALL) @@ -155,8 +160,7 @@ class TinkerOutputToolwindow(private val toolWindow: ToolWindow) { text.replace(regex, "$2") .replace( // Strings in array before => Regex("\"((?:[^\"\\\\]|\\\\.)*)\"\\s=>"), - ""$1"" + - " =>" + ""$1"" + " =>" ) .replace( // Ints in array before => Regex("([0-9]+)\\s=>"), @@ -203,7 +207,8 @@ class TinkerOutputToolwindow(private val toolWindow: ToolWindow) { val p1 = glyphPainter.getBoundedPosition(this, p0, pos, len) return if (p0 == startOffset && p1 == endOffset) { this - } else createFragment(p0, p1) + } else + createFragment(p0, p1) } return this } @@ -222,7 +227,8 @@ class TinkerOutputToolwindow(private val toolWindow: ToolWindow) { val min = layoutPool.getMinimumSpan(axis) // Don't include insets, Box.getXXXSpan will include them. sizeRequirements.minimum = min.toInt() - sizeRequirements.preferred = max(sizeRequirements.minimum, pref.toInt()) + sizeRequirements.preferred = + max(sizeRequirements.minimum, pref.toInt()) sizeRequirements.maximum = Int.MAX_VALUE sizeRequirements.alignment = 0.5f return sizeRequirements diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/util/LaravelTinkerConsolesRootType.kt b/src/main/kotlin/nl/deschepers/laraveltinker/util/LaravelTinkerConsolesRootType.kt index da07150..f8b2413 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/util/LaravelTinkerConsolesRootType.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/util/LaravelTinkerConsolesRootType.kt @@ -12,15 +12,18 @@ import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VirtualFile import com.intellij.ui.UIBundle import com.jetbrains.php.lang.PhpLanguage -import nl.deschepers.laraveltinker.Strings import java.io.IOException import javax.swing.Icon +import nl.deschepers.laraveltinker.Strings /** * Most content is copied from ScratchRootType - but that class is final so I can't extend it. + * * @see com.intellij.ide.scratch.ScratchRootType */ -class LaravelTinkerConsolesRootType : RootType("laravel-tinker", Strings.get("lt.console.menu_title")) { +class LaravelTinkerConsolesRootType : + RootType("laravel-tinker", Strings.get("lt.console.menu_title")) { + companion object { fun getInstance(): LaravelTinkerConsolesRootType { return findByClass(LaravelTinkerConsolesRootType::class.java) @@ -42,12 +45,19 @@ class LaravelTinkerConsolesRootType : RootType("laravel-tinker", Strings.get("lt } @Suppress("SwallowedException") - fun createScratchFile(project: Project?, text: String?, option: ScratchFileService.Option): VirtualFile? { + fun createScratchFile( + project: Project?, + text: String?, + option: ScratchFileService.Option + ): VirtualFile? { val fileName = Strings.get("lt.console.filename") return try { - WriteCommandAction.writeCommandAction(project).withName(Strings.get("lt.menu.action.open_new_console")) - .withGlobalUndo().shouldRecordActionForActiveDocument(false) - .withUndoConfirmationPolicy(UndoConfirmationPolicy.REQUEST_CONFIRMATION).compute { + WriteCommandAction.writeCommandAction(project) + .withName(Strings.get("lt.menu.action.open_new_console")) + .withGlobalUndo() + .shouldRecordActionForActiveDocument(false) + .withUndoConfirmationPolicy(UndoConfirmationPolicy.REQUEST_CONFIRMATION) + .compute { val fileService = ScratchFileService.getInstance() val file = fileService.findFile(this, fileName, option) // save text should go before any other manipulations that load document, @@ -58,10 +68,7 @@ class LaravelTinkerConsolesRootType : RootType("laravel-tinker", Strings.get("lt } } catch (e: IOException) { Messages.showMessageDialog( - UIBundle.message( - "create.new.file.could.not.create.file.error.message", - fileName - ), + UIBundle.message("create.new.file.could.not.create.file.error.message", fileName), UIBundle.message("error.dialog.title"), Messages.getErrorIcon() ) diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/util/PhpArtisanTinkerUtil.kt b/src/main/kotlin/nl/deschepers/laraveltinker/util/PhpArtisanTinkerUtil.kt index 3b3df5c..ec0b2f9 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/util/PhpArtisanTinkerUtil.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/util/PhpArtisanTinkerUtil.kt @@ -17,6 +17,11 @@ import com.jetbrains.php.config.commandLine.PhpCommandSettingsBuilder import com.jetbrains.php.run.PhpEditInterpreterExecutionException import com.jetbrains.php.run.script.PhpScriptRunConfiguration import com.jetbrains.php.run.script.PhpScriptRuntimeConfigurationProducer +import java.io.BufferedReader +import java.io.File +import java.io.InputStreamReader +import java.nio.charset.StandardCharsets +import java.util.stream.Collectors import nl.deschepers.laraveltinker.Strings import nl.deschepers.laraveltinker.balloon.LaravelRootDoesNotExistBalloon import nl.deschepers.laraveltinker.balloon.LaravelRootDoesNotHaveVendorBalloon @@ -25,22 +30,18 @@ import nl.deschepers.laraveltinker.balloon.PhpInterpreterErrorBalloon import nl.deschepers.laraveltinker.listener.PhpProcessListener import nl.deschepers.laraveltinker.settings.ProjectSettingsState import nl.deschepers.laraveltinker.toolwindow.TinkerOutputToolWindowFactory -import java.io.BufferedReader -import java.io.File -import java.io.InputStreamReader -import java.nio.charset.StandardCharsets -import java.util.stream.Collectors class PhpArtisanTinkerUtil(private val project: Project, private val phpCode: String) { fun run() { val projectSettings = ProjectSettingsState.getInstance(project) FileDocumentManager.getInstance().saveAllDocuments() - val runConfiguration = PhpScriptRunConfiguration( - project, - PhpScriptRuntimeConfigurationProducer().configurationFactory, - "Laravel Tinker" - ) + val runConfiguration = + PhpScriptRunConfiguration( + project, + PhpScriptRuntimeConfigurationProducer().configurationFactory, + "Laravel Tinker" + ) val phpInterpreter = PhpProjectConfigurationFacade.getInstance(project).interpreter if (phpInterpreter == null) { @@ -48,10 +49,10 @@ class PhpArtisanTinkerUtil(private val project: Project, private val phpCode: St return } - var laravelRoot = ComposerUtils.findFileInProject( - project, - ComposerUtils.CONFIG_DEFAULT_FILENAME - ).parent.path + var laravelRoot = + ComposerUtils.findFileInProject(project, ComposerUtils.CONFIG_DEFAULT_FILENAME) + .parent + .path if (projectSettings.laravelRoot.isNotEmpty()) { val customLaravelRoot = File(projectSettings.laravelRoot) @@ -68,35 +69,24 @@ class PhpArtisanTinkerUtil(private val project: Project, private val phpCode: St } val inputStream = javaClass.classLoader.getResourceAsStream("scripts/tinker_run.php") - val phpTinkerCodeRunnerCode = BufferedReader( - InputStreamReader(inputStream!!, StandardCharsets.UTF_8) - ).lines().collect(Collectors.joining("\n")) + val phpTinkerCodeRunnerCode = + BufferedReader(InputStreamReader(inputStream!!, StandardCharsets.UTF_8)).lines() + .collect(Collectors.joining("\n")) val phpCommandSettings: PhpCommandSettings val processHandler: ProcessHandler try { - phpCommandSettings = PhpCommandSettingsBuilder(project, phpInterpreter) - .loadAndStartDebug() - .build() + phpCommandSettings = + PhpCommandSettingsBuilder(project, phpInterpreter).loadAndStartDebug().build() phpCommandSettings.setWorkingDir(laravelRoot) phpCommandSettings.importCommandLineSettings( runConfiguration.settings.commandLineSettings, laravelRoot ) - phpCommandSettings.addArguments( - listOf( - "-r", - phpTinkerCodeRunnerCode, - phpCode - ) - ) + phpCommandSettings.addArguments(listOf("-r", phpTinkerCodeRunnerCode, phpCode)) processHandler = runConfiguration.createProcessHandler(project, phpCommandSettings) - ProcessTerminatedListener.attach( - processHandler, - project, - "" - ) + ProcessTerminatedListener.attach(processHandler, project, "") } catch (ex: ExecutionException) { PhpInterpreterErrorBalloon( project, @@ -119,25 +109,23 @@ class PhpArtisanTinkerUtil(private val project: Project, private val phpCode: St ToolWindowManager.getInstance(project).getToolWindow("Laravel Tinker")?.activate(null) TinkerOutputToolWindowFactory.tinkerOutputToolWindow[project]?.resetOutput() - ProgressManager.getInstance().run( - object : Backgroundable( - project, - Strings.get("lt.running") - ) { - override fun run(progressIndicator: ProgressIndicator) { - processHandler.startNotify() - processHandler.processInput?.writer()?.write("\u0004") - while (!processHandler.isProcessTerminated) { - Thread.sleep(250) - try { - progressIndicator.checkCanceled() - } catch (ex: ProcessCanceledException) { - processHandler.destroyProcess() - throw ex + ProgressManager.getInstance() + .run( + object : Backgroundable(project, Strings.get("lt.running")) { + override fun run(progressIndicator: ProgressIndicator) { + processHandler.startNotify() + processHandler.processInput?.writer()?.write("\u0004") + while (!processHandler.isProcessTerminated) { + Thread.sleep(250) + try { + progressIndicator.checkCanceled() + } catch (ex: ProcessCanceledException) { + processHandler.destroyProcess() + throw ex + } } } } - } - ) + ) } } diff --git a/src/main/kotlin/nl/deschepers/laraveltinker/util/TinkerConsoleUtil.kt b/src/main/kotlin/nl/deschepers/laraveltinker/util/TinkerConsoleUtil.kt index bea688c..e76bf0c 100644 --- a/src/main/kotlin/nl/deschepers/laraveltinker/util/TinkerConsoleUtil.kt +++ b/src/main/kotlin/nl/deschepers/laraveltinker/util/TinkerConsoleUtil.kt @@ -30,10 +30,7 @@ class TinkerConsoleUtil(val project: Project) { fun runTinkerWithFile(file: VirtualFile): Boolean { val document = FileDocumentManager.getInstance().getDocument(file) if (document !== null) { - PhpArtisanTinkerUtil( - project, - document.text - ).run() + PhpArtisanTinkerUtil(project, document.text).run() return true } @@ -42,7 +39,9 @@ class TinkerConsoleUtil(val project: Project) { } private fun getTinkerConsoleFiles(): List? { - val consolesPath = ScratchFileServiceImpl.getInstance().getRootPath(LaravelTinkerConsolesRootType.getInstance()) + val consolesPath = + ScratchFileServiceImpl.getInstance() + .getRootPath(LaravelTinkerConsolesRootType.getInstance()) val consolesDir = LocalFileSystem.getInstance().findFileByPath(consolesPath) return consolesDir?.children?.asList() @@ -51,18 +50,20 @@ class TinkerConsoleUtil(val project: Project) { fun initializeExistingTinkerConsoles() { val files = getTinkerConsoleFiles() val fileService = ScratchFileService.getInstance() - files?.forEach { - fileService.scratchesMapping.setMapping(it, PhpLanguage.INSTANCE) - } + files?.forEach { fileService.scratchesMapping.setMapping(it, PhpLanguage.INSTANCE) } } - private fun getTinkerConsole(option: ScratchFileService.Option, startingText: String = ""): VirtualFile? { + private fun getTinkerConsole( + option: ScratchFileService.Option, + startingText: String = "" + ): VirtualFile? { getTinkerConsoleFiles() - return LaravelTinkerConsolesRootType.getInstance().createScratchFile( - project, - Strings.get("lt.console.default_content") + startingText, - option - ) + return LaravelTinkerConsolesRootType.getInstance() + .createScratchFile( + project, + Strings.get("lt.console.default_content") + startingText, + option + ) } }