Skip to content

Commit

Permalink
Merge pull request #61 from nextras/fix-223
Browse files Browse the repository at this point in the history
Fixes for PS-223
  • Loading branch information
hrach committed Nov 17, 2022
2 parents bf537ba + 366e2cc commit 25e34ed
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 35 deletions.
18 changes: 10 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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)
}

Expand All @@ -37,6 +35,10 @@ changelog {
}

tasks {
buildSearchableOptions {
enabled = false
}

withType<JavaCompile> {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
rootProject.name = "orm-intellij"

pluginManagement {
repositories {
maven("https://oss.sonatype.org/content/repositories/snapshots/")
mavenCentral()
gradlePluginPortal()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ModifierHighlighterSettings : ColorSettingsPage {
}

override fun getDemoText(): String {
return "<?php\n// Sadly, there is no way how to preview your color settings in here."
return "<?php\n// IntelliJ IDEs do not support previewing custom highlighter here."
}

override fun getAdditionalHighlightingTagToDescriptorMap(): Map<String, TextAttributesKey>? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class EntityPropertiesProvider {
result.addElement(
LookupElementBuilder.create(strPath + sep)
.withPresentableText(fieldName)
.withIcon(PhpIcons.FIELD_ICON)
.withIcon(PhpIcons.FIELD)
.withTypeText(types.joinToString("|"))
)
}
Expand All @@ -85,15 +85,15 @@ class EntityPropertiesProvider {
result.addElement(
LookupElementBuilder.create("this->")
.withPresentableText("this")
.withIcon(PhpIcons.CLASS_ICON)
.withIcon(PhpIcons.CLASS)
.withTypeText(cls.type.toString())
)
}
if (path.size == 1 && sourceCls == null)
result.addElement(
LookupElementBuilder.create(cls.fqn + classSuffix)
.withPresentableText(cls.fqn)
.withIcon(PhpIcons.CLASS_ICON)
.withIcon(PhpIcons.CLASS)
.withTypeText(cls.type.toString())
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PropertyNameCompletionProvider : CompletionProvider<CompletionParameters>(
.forEach {
result.addElement(
LookupElementBuilder.create(it.name)
.withIcon(PhpIcons.FIELD_ICON)
.withIcon(PhpIcons.FIELD)
.withTypeText(it.type.toString())
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CompletionParameters>() {
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<PhpClass>(el, PhpClass.INSTANCEOF) ?: return
val cls = PhpPsiUtil.getParentByCondition<PhpClass>(el, PhpClass.INSTANCEOF, PhpNamespace.INSTANCEOF) ?: return

val phpIndex = PhpIndex.getInstance(el.project)
if (!OrmUtils.OrmClass.ENTITY.`is`(cls, phpIndex)) {
Expand All @@ -35,7 +40,7 @@ class SetReadOnlyValueCompletionProvider : CompletionProvider<CompletionParamete
insertionContext.editor.caretModel.moveToOffset(insertionContext.startOffset + phpCode.length - 2)
}
.withTypeText(it.type.toString())
.withIcon(PhpIcons.VARIABLE_WRITE_ACCESS)
.withIcon(PhpIcons.READONLY_FIELD)
.withPresentableText(it.name + " = ...")
}
.forEach { result.addElement(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CollectionPropertyReference constructor(
.toSet()
.map {
object : ResolveResult {
override fun getElement(): PsiElement? {
override fun getElement(): PsiElement {
return it
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class EntityPropertyReference(psiElement: StringLiteralExpression) : PsiPolyVari
.filterIsInstance<PhpDocProperty>()
.map {
object : ResolveResult {
override fun getElement(): PsiElement? {
override fun getElement(): PsiElement {
return it
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ModifierClassProperty(
.filterIsInstance<PhpDocProperty>()
.map {
object : ResolveResult {
override fun getElement(): PsiElement? {
override fun getElement(): PsiElement {
return it
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<depends>com.intellij.modules.platform</depends>
<depends>com.jetbrains.php</depends>

<idea-version since-build="201.3119"/>
<idea-version since-build="223.7401"/>

<extensions defaultExtensionNs="com.intellij">
<psi.referenceContributor
Expand Down

0 comments on commit 25e34ed

Please sign in to comment.