Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version 1.2.10 for PhpStorm 2023.3 #52

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ jobs:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3
uses: actions/checkout@v4

# Validate wrapper
- name: Gradle Wrapper Validation
uses: gradle/[email protected]

# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17

# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2.8.0
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

Expand Down Expand Up @@ -76,22 +76,18 @@ jobs:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3

# Validate wrapper
- name: Gradle Wrapper Validation
uses: gradle/[email protected]
uses: actions/checkout@v4

# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17

# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2.8.0
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

Expand All @@ -116,18 +112,18 @@ jobs:

# Check out current repository
- name: Fetch Sources
uses: actions/checkout@v3
uses: actions/checkout@v4

# Set up Java environment for the next steps
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17

# Setup Gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2.8.0
uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## [Unreleased]

## [1.2.10] - 14.02.2024

- adapt code for 2023.3
- new inspection `KphpStrictTypesEnableInspection`

## [1.2.9] - 21.08.2023

- adapt code for 2023.2
Expand Down
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ repositories {

// Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
kotlin {
jvmToolchain(17)
@Suppress("UnstableApiUsage")
jvmToolchain {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.JETBRAINS
}
}

// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ pluginName = kphpstorm
pluginRepositoryUrl = https://github.com/VKCOM/kphpstorm

# SemVer format -> https://semver.org
pluginVersion = 1.2.9
pluginVersion = 1.2.10

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 232
pluginUntilBuild = 232.*
pluginSinceBuild = 233
pluginUntilBuild = 233.*

# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = IU
platformVersion = 2023.2
platformVersion = 2023.3

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
# PHP Plugin - https://plugins.jetbrains.com/plugin/6610-php/versions
platformPlugins = com.jetbrains.php:232.8660.205
platformPlugins = com.jetbrains.php:233.11799.232

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 8.3
gradleVersion = 8.5

# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
kotlin.stdlib.default.dependency = false
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# libraries

# plugins
kotlin = "1.9.0"
changelog = "2.1.2"
gradleIntelliJPlugin = "1.15.0"
kotlin = "1.9.21"
changelog = "2.2.0"
gradleIntelliJPlugin = "1.16.1"

[libraries]

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 7 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -202,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.6.0"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
}

rootProject.name = "kphpstorm"
14 changes: 1 addition & 13 deletions src/main/kotlin/com/vk/kphpstorm/KphpStormParserDefinition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,15 @@ package com.vk.kphpstorm

import com.intellij.lang.ASTNode
import com.intellij.psi.PsiElement
import com.jetbrains.php.lang.documentation.phpdoc.parser.tags.PhpDocTagParserRegistry
import com.jetbrains.php.lang.parser.PhpParserDefinition
import com.jetbrains.php.lang.parser.PhpPsiElementCreator
import com.vk.kphpstorm.exphptype.psi.*
import com.vk.kphpstorm.kphptags.ALL_KPHPDOC_TAGS
import com.vk.kphpstorm.kphptags.psi.*

/**
* Main class that overrides php parsing PSI creation
*/
class KphpStormParserDefinition() : PhpParserDefinition() {
init {
// PhpDocTagParserRegistry.register() became deprecated in 2020.3
// (the current suggestion is to use <docTagParserExtension> in plugin.xml)
// custom @var/@param/@return handling is already done via xml description
// but still use this for @kphp-tags: it's more handy, because we don't need to duplicate tag names to xml
// when register() method is dropped, it won't compile and should be rewritten :(
@Suppress("DEPRECATION")
for (kphpDocTag in ALL_KPHPDOC_TAGS)
PhpDocTagParserRegistry.register(kphpDocTag.nameWithAt, kphpDocTag.elementType.getTagParser())
}
class KphpStormParserDefinition : PhpParserDefinition() {

/**
* We have custom elementTypes, PhpStorm doesn't know how to create them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment
import com.jetbrains.php.lang.documentation.phpdoc.psi.tags.PhpDocTag
import com.jetbrains.php.lang.psi.elements.Function
import com.vk.kphpstorm.helpers.parentDocComment
import com.vk.kphpstorm.kphptags.psi.KphpDocElementTypes
import com.vk.kphpstorm.kphptags.psi.KphpDocTagElementType

object KphpAnalyzePerformanceDocTag : KphpDocTag("@kphp-analyze-performance") {
override val description: String
get() = "Generates a report with potential optimizations, such as computing a constant value outside a loop or implicit arrays casting."

override val elementType: KphpDocTagElementType
get() = KphpDocElementTypes.kphpDocTagWarnPerformance

override fun isApplicableFor(owner: PsiElement): Boolean {
return owner is Function
}
Expand Down
5 changes: 0 additions & 5 deletions src/main/kotlin/com/vk/kphpstorm/kphptags/KphpDocTag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import com.jetbrains.php.lang.documentation.phpdoc.PhpDocUtil
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment
import com.jetbrains.php.lang.documentation.phpdoc.psi.tags.PhpDocTag
import com.jetbrains.php.lang.psi.elements.PhpNamedElement
import com.vk.kphpstorm.kphptags.psi.KphpDocElementTypes
import com.vk.kphpstorm.kphptags.psi.KphpDocTagElementType

/**
* All '@kphp-...' tags instances are objects extending this class.
Expand All @@ -22,9 +20,6 @@ abstract class KphpDocTag(
val nameWithoutAt
get() = nameWithAt.substring(1)

open val elementType: KphpDocTagElementType
get() = KphpDocElementTypes.kphpDocTagSimple

abstract val description: String

/**
Expand Down
3 changes: 0 additions & 3 deletions src/main/kotlin/com/vk/kphpstorm/kphptags/KphpJsonTag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ object KphpJsonTag : KphpDocTag("@kphp-json") {
override val description: String
get() = "Used to change the decoding and encoding behavior of JSON"

override val elementType: KphpDocTagElementType
get() = KphpDocElementTypes.kphpDocTagJson

override fun isApplicableFor(owner: PsiElement): Boolean {
return owner is Field || owner is PhpClass
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@ import com.intellij.psi.PsiElement
import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment
import com.jetbrains.php.lang.documentation.phpdoc.psi.tags.PhpDocTag
import com.jetbrains.php.lang.psi.elements.PhpClass
import com.vk.kphpstorm.kphptags.psi.KphpDocElementTypes
import com.vk.kphpstorm.kphptags.psi.KphpDocTagElementType

object KphpTemplateClassDocTag : KphpDocTag("@kphp-template-class") {
override val description: String
get() = "Experiments for future, try to implement concept of template classes in php"

override val elementType: KphpDocTagElementType
get() = KphpDocElementTypes.kphpDocTagTemplateClass

override fun isApplicableFor(owner: PsiElement): Boolean {
return owner is PhpClass
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment
import com.jetbrains.php.lang.documentation.phpdoc.psi.tags.PhpDocTag
import com.jetbrains.php.lang.psi.elements.Function
import com.vk.kphpstorm.inspections.quickfixes.RemoveWarnPerformanceItemQuickFix
import com.vk.kphpstorm.kphptags.psi.KphpDocElementTypes
import com.vk.kphpstorm.kphptags.psi.KphpDocTagElementType
import com.vk.kphpstorm.kphptags.psi.KphpDocWarnPerformanceItemPsiImpl

object KphpWarnPerformanceDocTag : KphpDocTag("@kphp-warn-performance") {
Expand All @@ -23,9 +21,6 @@ object KphpWarnPerformanceDocTag : KphpDocTag("@kphp-warn-performance") {
override val description: String
get() = "Same as @kphp-analyze-performance, but it doesn't generate a report: instead, it gives a compilation error if potential optimizations are available."

override val elementType: KphpDocTagElementType
get() = KphpDocElementTypes.kphpDocTagWarnPerformance

override fun isApplicableFor(owner: PsiElement): Boolean {
return owner is Function
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.vk.kphpstorm.kphptags.parser

import com.jetbrains.php.lang.documentation.phpdoc.parser.tags.PhpDocParamTagParser
import com.jetbrains.php.lang.documentation.phpdoc.parser.tags.PhpDocTagParser
import com.jetbrains.php.lang.parser.PhpParserErrors
import com.jetbrains.php.lang.parser.PhpPsiBuilder
import com.vk.kphpstorm.exphptype.psi.TokensToExPhpTypePsiParsing
import com.vk.kphpstorm.kphptags.psi.KphpDocJsonAttributePsiImpl
import com.vk.kphpstorm.kphptags.psi.KphpDocJsonForEncoderPsiImpl
import com.vk.kphpstorm.kphptags.psi.KphpDocTagJsonElementType

class KphpDocTagJsonParser : PhpDocTagParser() {
override fun getElementType() = KphpDocTagJsonElementType

override fun parseContents(builder: PhpPsiBuilder): Boolean {
val paramsTagParser = PhpDocParamTagParser()

while (true) {
val forMarker = builder.mark()
var needForIdentifier = false
if (builder.compare(DOC_IDENTIFIER) && builder.tokenText == "for") {
builder.advanceLexer()

if (TokensToExPhpTypePsiParsing.parseTypeExpression(builder)) {
needForIdentifier = true
} else {
forMarker.drop()
builder.error(PhpParserErrors.expected("JsonEncoder name"))
break
}
}
if (needForIdentifier) {
forMarker.done(KphpDocJsonForEncoderPsiImpl.elementType)
} else {
forMarker.drop()
}

val attributeName: String?
val marker = builder.mark()
if (builder.compare(DOC_IDENTIFIER)) {
attributeName = builder.tokenText
builder.advanceLexer()
} else {
marker.drop()
builder.error(PhpParserErrors.expected("Attribute name"))
break
}

if (builder.compare(DOC_TEXT) && builder.tokenText!!.startsWith("=")) {
var needNextIdentifier = true

if (builder.tokenText == "=") {
builder.compareAndEat(DOC_TEXT)
} else {
needNextIdentifier = false
builder.advanceLexer()
}

if (needNextIdentifier) {
if (attributeName == "fields") {
while (true) {
if (!builder.compareAndEat(DOC_COMMA) && !paramsTagParser.parseContents(builder)) {
break
}
}
} else {
if (!builder.compare(DOC_IDENTIFIER) && !builder.compare(DOC_TEXT)) {
marker.drop()
builder.error(PhpParserErrors.expected("Attribute value"))
break
}

builder.advanceLexer()
}
}
}

marker.done(KphpDocJsonAttributePsiImpl.elementType)
return true

}
return true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.vk.kphpstorm.kphptags.parser

import com.jetbrains.php.lang.documentation.phpdoc.parser.tags.PhpDocTagParser
import com.jetbrains.php.lang.parser.PhpPsiBuilder
import com.vk.kphpstorm.kphptags.psi.KphpDocTagSimpleElementType

class KphpDocTagSimpleParser : PhpDocTagParser() {
override fun getElementType() = KphpDocTagSimpleElementType

override fun parseContents(builder: PhpPsiBuilder) = true
}
Loading
Loading