From 0195ef348f8c1cffd6aa391ecd36e8a63582abb5 Mon Sep 17 00:00:00 2001 From: David Meybohm Date: Fri, 11 Dec 2020 20:25:41 -0500 Subject: [PATCH 1/2] Fix PHPStorm 2020.3 - Add characters to the `getKey` in the TypeProvider4 classes - Fix icon loading --- src/main/kotlin/CakeIcons.kt | 3 ++- .../controller/ControllerFieldTypeProvider.kt | 2 +- .../kotlin/controller/ControllerMethodLineMarker.kt | 10 +++++++--- .../kotlin/view/ThisVariableInViewTypeProvider.kt | 2 +- .../view/ViewHelperInViewHelperTypeProvider.kt | 2 +- .../kotlin/view/ViewHelperInViewTypeProvider.kt | 2 +- src/main/resources/{ => icon}/cake-logo.png | Bin src/main/resources/{ => icon}/cake.icon.png | Bin src/main/resources/{ => icon}/cake.logo.svg | 0 9 files changed, 13 insertions(+), 8 deletions(-) rename src/main/resources/{ => icon}/cake-logo.png (100%) rename src/main/resources/{ => icon}/cake.icon.png (100%) rename src/main/resources/{ => icon}/cake.logo.svg (100%) diff --git a/src/main/kotlin/CakeIcons.kt b/src/main/kotlin/CakeIcons.kt index 7db40d09..bca11351 100644 --- a/src/main/kotlin/CakeIcons.kt +++ b/src/main/kotlin/CakeIcons.kt @@ -3,5 +3,6 @@ package com.daveme.chocolateCakePHP import com.intellij.openapi.util.IconLoader object CakeIcons { - val LOGO = IconLoader.getIcon("../../../../cake.icon.png") + @JvmField + val LOGO = IconLoader.getIcon("/icon/cake.icon.png", CakeIcons::class.java) } diff --git a/src/main/kotlin/controller/ControllerFieldTypeProvider.kt b/src/main/kotlin/controller/ControllerFieldTypeProvider.kt index 9a310238..30a42110 100644 --- a/src/main/kotlin/controller/ControllerFieldTypeProvider.kt +++ b/src/main/kotlin/controller/ControllerFieldTypeProvider.kt @@ -14,7 +14,7 @@ import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider4 class ControllerFieldTypeProvider : PhpTypeProvider4 { override fun getKey(): Char { - return 0.toChar() + return '\u8312' } override fun complete(str: String?, project: Project?): PhpType? = null diff --git a/src/main/kotlin/controller/ControllerMethodLineMarker.kt b/src/main/kotlin/controller/ControllerMethodLineMarker.kt index 46fa9723..84b719ec 100644 --- a/src/main/kotlin/controller/ControllerMethodLineMarker.kt +++ b/src/main/kotlin/controller/ControllerMethodLineMarker.kt @@ -36,12 +36,13 @@ class ControllerMethodLineMarker : LineMarkerProvider { .createLineMarkerInfo(nameIdentifier) } - private fun addLineMarkerUnique(collection: MutableCollection>, newMarker: LineMarkerInfo<*>?) { + private fun addLineMarkerUnique(collection: MutableCollection>, newMarker: LineMarkerInfo<*>?) { if (newMarker == null) { return } for (lineMarkerInfo in collection) { - val element = lineMarkerInfo.element ?: return + val markerElement = lineMarkerInfo as? LineMarkerInfo<*> ?: continue + val element = markerElement.element ?: return val otherElement = newMarker.element if (element == otherElement) { return @@ -50,7 +51,10 @@ class ControllerMethodLineMarker : LineMarkerProvider { collection.add(newMarker) } - override fun collectSlowLineMarkers(list: List, collection: MutableCollection>) { + override fun collectSlowLineMarkers( + list: MutableList, + collection: MutableCollection> + ) { for (element in list) { val settings = Settings.getInstance(element.project) if (!settings.enabled) { diff --git a/src/main/kotlin/view/ThisVariableInViewTypeProvider.kt b/src/main/kotlin/view/ThisVariableInViewTypeProvider.kt index 909d11a9..3178b9ff 100644 --- a/src/main/kotlin/view/ThisVariableInViewTypeProvider.kt +++ b/src/main/kotlin/view/ThisVariableInViewTypeProvider.kt @@ -13,7 +13,7 @@ import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider4 class ThisVariableInViewTypeProvider : PhpTypeProvider4 { override fun getKey(): Char { - return 0.toChar() + return '\u8313' } override fun complete(p0: String?, p1: Project?): PhpType? = null diff --git a/src/main/kotlin/view/ViewHelperInViewHelperTypeProvider.kt b/src/main/kotlin/view/ViewHelperInViewHelperTypeProvider.kt index 1e7670c5..ab554f4a 100644 --- a/src/main/kotlin/view/ViewHelperInViewHelperTypeProvider.kt +++ b/src/main/kotlin/view/ViewHelperInViewHelperTypeProvider.kt @@ -13,7 +13,7 @@ import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider4 class ViewHelperInViewHelperTypeProvider : PhpTypeProvider4 { override fun getKey(): Char { - return 0.toChar() + return '\u8314' } override fun complete(p0: String?, p1: Project?): PhpType? = null diff --git a/src/main/kotlin/view/ViewHelperInViewTypeProvider.kt b/src/main/kotlin/view/ViewHelperInViewTypeProvider.kt index 8060a57f..58426b63 100644 --- a/src/main/kotlin/view/ViewHelperInViewTypeProvider.kt +++ b/src/main/kotlin/view/ViewHelperInViewTypeProvider.kt @@ -14,7 +14,7 @@ import com.jetbrains.php.lang.psi.resolve.types.PhpTypeProvider4 class ViewHelperInViewTypeProvider : PhpTypeProvider4 { override fun getKey(): Char { - return 0.toChar() + return '\u8315' } override fun complete(p0: String?, p1: Project?): PhpType? = null diff --git a/src/main/resources/cake-logo.png b/src/main/resources/icon/cake-logo.png similarity index 100% rename from src/main/resources/cake-logo.png rename to src/main/resources/icon/cake-logo.png diff --git a/src/main/resources/cake.icon.png b/src/main/resources/icon/cake.icon.png similarity index 100% rename from src/main/resources/cake.icon.png rename to src/main/resources/icon/cake.icon.png diff --git a/src/main/resources/cake.logo.svg b/src/main/resources/icon/cake.logo.svg similarity index 100% rename from src/main/resources/cake.logo.svg rename to src/main/resources/icon/cake.logo.svg From 4ec258e1315e1341e643493b1072d9ea7bf8b836 Mon Sep 17 00:00:00 2001 From: David Meybohm Date: Fri, 11 Dec 2020 23:03:58 -0500 Subject: [PATCH 2/2] Handle running on event dispatcher thread in config form --- .../daveme/chocolateCakePHP/ConfigForm.java | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/daveme/chocolateCakePHP/ConfigForm.java b/src/main/java/com/daveme/chocolateCakePHP/ConfigForm.java index fd913f99..e5032da7 100644 --- a/src/main/java/com/daveme/chocolateCakePHP/ConfigForm.java +++ b/src/main/java/com/daveme/chocolateCakePHP/ConfigForm.java @@ -141,22 +141,29 @@ public void apply() { private void createUIComponents() { FullyQualifiedNameInsertHandler insertHandler = new FullyQualifiedNameInsertHandler(); try { - SwingUtilities.invokeAndWait(() -> { - PhpCompletionUtil.PhpFullyQualifiedNameTextFieldCompletionProvider completionProvider = - new FullyQualifiedNameTextFieldCompletionProvider(project, insertHandler); - appNamespaceTextField = new TextFieldWithCompletion( - project, - completionProvider, - "", - true, - true, - true, - true - ); - }); + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeAndWait(() -> { + setupHandler(insertHandler); + }); + } else { + setupHandler(insertHandler); + } } catch (InterruptedException | InvocationTargetException e) { e.printStackTrace(); } } + private void setupHandler(FullyQualifiedNameInsertHandler insertHandler) { + PhpCompletionUtil.PhpFullyQualifiedNameTextFieldCompletionProvider completionProvider = + new FullyQualifiedNameTextFieldCompletionProvider(project, insertHandler); + appNamespaceTextField = new TextFieldWithCompletion( + project, + completionProvider, + "", + true, + true, + true, + true + ); + } }