From 1d7e66d16ad8185eaf29a92e484321c1f955da8e Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Tue, 18 Oct 2022 23:46:51 +0200 Subject: [PATCH 1/4] update setup for PS-2022.3 --- build.gradle.kts | 18 ++++++++++-------- changelog.md | 1 + gradle.properties | 9 +-------- settings.gradle.kts | 8 ++++++++ src/main/resources/META-INF/plugin.xml | 2 +- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ce0a4b2..5e8ef7f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,13 +1,12 @@ import org.jetbrains.changelog.markdownToHTML -import org.jetbrains.intellij.ideaDir import org.jetbrains.kotlin.gradle.tasks.KotlinCompile fun properties(key: String) = project.findProperty(key).toString() plugins { - id("org.jetbrains.kotlin.jvm") version "1.7.20" - id("org.jetbrains.intellij") version "1.9.0" - id("org.jetbrains.changelog") version "1.3.1" + id("org.jetbrains.kotlin.jvm") version "1.7.21" + id("org.jetbrains.intellij") version "1.10.0" + id("org.jetbrains.changelog") version "2.0.0" } group = properties("pluginGroup") @@ -22,11 +21,10 @@ dependencies { } intellij { + type.set("PS") + version.set("223-EAP-SNAPSHOT") + plugins.set(listOf("com.jetbrains.php:223.7571.15")) // 2022.3 beta 2 pluginName.set(properties("pluginName")) - version.set(properties("platformVersion")) - type.set(properties("platformType")) - downloadSources.set(properties("platformDownloadSources").toBoolean()) - plugins.set(properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)) updateSinceUntilBuild.set(false) } @@ -37,6 +35,10 @@ changelog { } tasks { + buildSearchableOptions { + enabled = false + } + withType { sourceCompatibility = "1.8" targetCompatibility = "1.8" diff --git a/changelog.md b/changelog.md index 8038c1c..28c6635 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## [Unreleased] ### Changed - Added support for marking entity getters/setters as implicitly used; closes #12 +- Fixed support for PHPStorm 2022.3 EAP, minimal version is PHPStorm 2022.3. ## [0.8.3] ### Changed diff --git a/gradle.properties b/gradle.properties index 1513609..ca6f4bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,11 +4,4 @@ pluginVersion = 0.9.0 # Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl # See https://jb.gg/intellij-platform-builds-list for available build versions. -pluginVerifierIdeVersions = PS-2021.3 - -platformType = IU -platformVersion = 2021.3.1 -platformDownloadSources = true -# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html -# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22 -platformPlugins = com.jetbrains.php:213.6461.83 +pluginVerifierIdeVersions = PS-2022.3 diff --git a/settings.gradle.kts b/settings.gradle.kts index a169ce7..0f81fd8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1,9 @@ rootProject.name = "orm-intellij" + +pluginManagement { + repositories { + maven("https://oss.sonatype.org/content/repositories/snapshots/") + mavenCentral() + gradlePluginPortal() + } +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 401625b..b1e903e 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -6,7 +6,7 @@ com.intellij.modules.platform com.jetbrains.php - + Date: Tue, 18 Oct 2022 23:47:09 +0200 Subject: [PATCH 2/4] fix parsing modifiers with 2022.3 PSI structure --- .../reference/ModifierClassNameProvider.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/org/nextras/orm/intellij/reference/ModifierClassNameProvider.kt b/src/main/kotlin/org/nextras/orm/intellij/reference/ModifierClassNameProvider.kt index bd1cc3a..714ece0 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/reference/ModifierClassNameProvider.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/reference/ModifierClassNameProvider.kt @@ -26,13 +26,21 @@ class ModifierClassNameProvider : PsiReferenceProvider() { PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER).withText("m") ) ), + PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER).withText("1").afterLeaf( + PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_TEXT).withText(":").afterLeaf( + PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER).withText("m") + ) + ), PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER).withText("m").afterLeaf( - PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_TEXT).withText("1:") + PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_TEXT).withText(":").afterLeaf( + PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER).withText("1") + ) ), - PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_TEXT).withText(":1").afterLeaf( - PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER).withText("m") + PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER).withText("1").afterLeaf( + PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_TEXT).withText(":").afterLeaf( + PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER).withText("1") + ) ), - PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_TEXT).withText("1:1") ) ) .withLanguage(PhpLanguage.INSTANCE) From 79de985ca51f84d4708a911e7a7b41d5f2ab91f6 Mon Sep 17 00:00:00 2001 From: Jan Skrasek Date: Tue, 18 Oct 2022 23:56:22 +0200 Subject: [PATCH 3/4] fix PHP icon references in PS-2022.3 --- .../orm/intellij/completion/EntityPropertiesProvider.kt | 6 +++--- .../intellij/completion/PropertyNameCompletionProvider.kt | 2 +- .../completion/SetReadOnlyValueCompletionProvider.kt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/org/nextras/orm/intellij/completion/EntityPropertiesProvider.kt b/src/main/kotlin/org/nextras/orm/intellij/completion/EntityPropertiesProvider.kt index 07da457..a933e2c 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/completion/EntityPropertiesProvider.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/completion/EntityPropertiesProvider.kt @@ -76,7 +76,7 @@ class EntityPropertiesProvider { result.addElement( LookupElementBuilder.create(strPath + sep) .withPresentableText(fieldName) - .withIcon(PhpIcons.FIELD_ICON) + .withIcon(PhpIcons.FIELD) .withTypeText(types.joinToString("|")) ) } @@ -85,7 +85,7 @@ class EntityPropertiesProvider { result.addElement( LookupElementBuilder.create("this->") .withPresentableText("this") - .withIcon(PhpIcons.CLASS_ICON) + .withIcon(PhpIcons.CLASS) .withTypeText(cls.type.toString()) ) } @@ -93,7 +93,7 @@ class EntityPropertiesProvider { result.addElement( LookupElementBuilder.create(cls.fqn + classSuffix) .withPresentableText(cls.fqn) - .withIcon(PhpIcons.CLASS_ICON) + .withIcon(PhpIcons.CLASS) .withTypeText(cls.type.toString()) ) } diff --git a/src/main/kotlin/org/nextras/orm/intellij/completion/PropertyNameCompletionProvider.kt b/src/main/kotlin/org/nextras/orm/intellij/completion/PropertyNameCompletionProvider.kt index 0ebc97c..aaaa23e 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/completion/PropertyNameCompletionProvider.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/completion/PropertyNameCompletionProvider.kt @@ -40,7 +40,7 @@ class PropertyNameCompletionProvider : CompletionProvider( .forEach { result.addElement( LookupElementBuilder.create(it.name) - .withIcon(PhpIcons.FIELD_ICON) + .withIcon(PhpIcons.FIELD) .withTypeText(it.type.toString()) ) } diff --git a/src/main/kotlin/org/nextras/orm/intellij/completion/SetReadOnlyValueCompletionProvider.kt b/src/main/kotlin/org/nextras/orm/intellij/completion/SetReadOnlyValueCompletionProvider.kt index 79b6b7c..37e3272 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/completion/SetReadOnlyValueCompletionProvider.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/completion/SetReadOnlyValueCompletionProvider.kt @@ -35,7 +35,7 @@ class SetReadOnlyValueCompletionProvider : CompletionProvider Date: Wed, 19 Oct 2022 00:03:49 +0200 Subject: [PATCH 4/4] remove deprecations/warnings --- .../annotator/highlighter/ModifierHighlighterSettings.kt | 2 +- .../completion/SetReadOnlyValueCompletionProvider.kt | 9 +++++++-- .../orm/intellij/reference/CollectionClassReference.kt | 2 +- .../intellij/reference/CollectionPropertyReference.kt | 2 +- .../orm/intellij/reference/EntityPropertyReference.kt | 2 +- .../nextras/orm/intellij/reference/ModifierClassName.kt | 2 +- .../orm/intellij/reference/ModifierClassProperty.kt | 2 +- .../orm/intellij/typeProvider/CollectionTypeProvider.kt | 1 - 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/org/nextras/orm/intellij/annotator/highlighter/ModifierHighlighterSettings.kt b/src/main/kotlin/org/nextras/orm/intellij/annotator/highlighter/ModifierHighlighterSettings.kt index 8d53ef9..8c7c15a 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/annotator/highlighter/ModifierHighlighterSettings.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/annotator/highlighter/ModifierHighlighterSettings.kt @@ -18,7 +18,7 @@ class ModifierHighlighterSettings : ColorSettingsPage { } override fun getDemoText(): String { - return "? { diff --git a/src/main/kotlin/org/nextras/orm/intellij/completion/SetReadOnlyValueCompletionProvider.kt b/src/main/kotlin/org/nextras/orm/intellij/completion/SetReadOnlyValueCompletionProvider.kt index 37e3272..b6f291c 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/completion/SetReadOnlyValueCompletionProvider.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/completion/SetReadOnlyValueCompletionProvider.kt @@ -11,12 +11,17 @@ import com.jetbrains.php.PhpIndex import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocProperty import com.jetbrains.php.lang.psi.PhpPsiUtil import com.jetbrains.php.lang.psi.elements.PhpClass +import com.jetbrains.php.lang.psi.elements.PhpNamespace import org.nextras.orm.intellij.utils.OrmUtils class SetReadOnlyValueCompletionProvider : CompletionProvider() { - override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) { + override fun addCompletions( + parameters: CompletionParameters, + context: ProcessingContext, + result: CompletionResultSet + ) { val el = parameters.position - val cls = PhpPsiUtil.getParentByCondition(el, PhpClass.INSTANCEOF) ?: return + val cls = PhpPsiUtil.getParentByCondition(el, PhpClass.INSTANCEOF, PhpNamespace.INSTANCEOF) ?: return val phpIndex = PhpIndex.getInstance(el.project) if (!OrmUtils.OrmClass.ENTITY.`is`(cls, phpIndex)) { diff --git a/src/main/kotlin/org/nextras/orm/intellij/reference/CollectionClassReference.kt b/src/main/kotlin/org/nextras/orm/intellij/reference/CollectionClassReference.kt index e8682ef..9e91d6d 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/reference/CollectionClassReference.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/reference/CollectionClassReference.kt @@ -17,7 +17,7 @@ class CollectionClassReference constructor( val classes = OrmUtils.findQueriedEntities(methodReference, name, arrayOf()) return classes.map { object : ResolveResult { - override fun getElement(): PsiElement? { + override fun getElement(): PsiElement { return it } diff --git a/src/main/kotlin/org/nextras/orm/intellij/reference/CollectionPropertyReference.kt b/src/main/kotlin/org/nextras/orm/intellij/reference/CollectionPropertyReference.kt index 9a50f49..c08819b 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/reference/CollectionPropertyReference.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/reference/CollectionPropertyReference.kt @@ -34,7 +34,7 @@ class CollectionPropertyReference constructor( .toSet() .map { object : ResolveResult { - override fun getElement(): PsiElement? { + override fun getElement(): PsiElement { return it } diff --git a/src/main/kotlin/org/nextras/orm/intellij/reference/EntityPropertyReference.kt b/src/main/kotlin/org/nextras/orm/intellij/reference/EntityPropertyReference.kt index a652791..d6c48c2 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/reference/EntityPropertyReference.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/reference/EntityPropertyReference.kt @@ -24,7 +24,7 @@ class EntityPropertyReference(psiElement: StringLiteralExpression) : PsiPolyVari .filterIsInstance() .map { object : ResolveResult { - override fun getElement(): PsiElement? { + override fun getElement(): PsiElement { return it } diff --git a/src/main/kotlin/org/nextras/orm/intellij/reference/ModifierClassName.kt b/src/main/kotlin/org/nextras/orm/intellij/reference/ModifierClassName.kt index bdc5540..fc0ead2 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/reference/ModifierClassName.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/reference/ModifierClassName.kt @@ -20,7 +20,7 @@ class ModifierClassName( .filter { OrmUtils.OrmClass.ENTITY.`is`(it, phpIndex) } .map { object : ResolveResult { - override fun getElement(): PsiElement? { + override fun getElement(): PsiElement { return it } diff --git a/src/main/kotlin/org/nextras/orm/intellij/reference/ModifierClassProperty.kt b/src/main/kotlin/org/nextras/orm/intellij/reference/ModifierClassProperty.kt index b147d78..0a1f6e3 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/reference/ModifierClassProperty.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/reference/ModifierClassProperty.kt @@ -24,7 +24,7 @@ class ModifierClassProperty( .filterIsInstance() .map { object : ResolveResult { - override fun getElement(): PsiElement? { + override fun getElement(): PsiElement { return it } diff --git a/src/main/kotlin/org/nextras/orm/intellij/typeProvider/CollectionTypeProvider.kt b/src/main/kotlin/org/nextras/orm/intellij/typeProvider/CollectionTypeProvider.kt index 58fc4a0..88cef02 100644 --- a/src/main/kotlin/org/nextras/orm/intellij/typeProvider/CollectionTypeProvider.kt +++ b/src/main/kotlin/org/nextras/orm/intellij/typeProvider/CollectionTypeProvider.kt @@ -31,7 +31,6 @@ class CollectionTypeProvider : PhpTypeProvider4 { val isPluralMethod = pluralMethods.contains(methodName) val arraySuffix = if (isPluralMethod) "[]" else "" - @Suppress("MoveVariableDeclarationIntoWhen") val parent = element.classReference!! when (parent) { is MethodReference -> {