Skip to content
Open
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
25 changes: 25 additions & 0 deletions .run/Format.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Format" type="GradleRunConfiguration" factoryName="Gradle">
<log_file alias="IDE logs" path="$PROJECT_DIR$/build/idea-sandbox/*/log/idea.log" show_all="true" />
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="ktfmtFormat" />
</list>
</option>
<option name="vmOptions" value="" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
</component>
137 changes: 67 additions & 70 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,91 +10,98 @@ plugins {
alias(libs.plugins.changelog) // Gradle Changelog Plugin
alias(libs.plugins.qodana) // Gradle Qodana Plugin
alias(libs.plugins.kover) // Gradle Kover Plugin
id("com.ncorti.ktfmt.gradle") version "0.24.0" // Gradle ktfmt Plugin
}

group = providers.gradleProperty("pluginGroup").get()

version = providers.gradleProperty("pluginVersion").get()

// Set the JVM language level used to build the project.
kotlin {
jvmToolchain(21)
}
kotlin { jvmToolchain(21) }

// Configure project's dependencies
repositories {
mavenCentral()

// IntelliJ Platform Gradle Plugin Repositories Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
intellijPlatform {
defaultRepositories()
}
// IntelliJ Platform Gradle Plugin Repositories Extension - read more:
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-repositories-extension.html
intellijPlatform { defaultRepositories() }
}

sourceSets {
main {
java {
setSrcDirs(listOf("src/main/kotlin", "src/main/gen"))
}
}
}
sourceSets { main { java { setSrcDirs(listOf("src/main/kotlin", "src/main/gen")) } } }

// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
// Dependencies are managed with Gradle version catalog - read more:
// https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog
dependencies {
testImplementation(libs.junit)
testImplementation(libs.opentest4j)

// IntelliJ Platform Gradle Plugin Dependencies Extension - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
// IntelliJ Platform Gradle Plugin Dependencies Extension - read more:
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-dependencies-extension.html
intellijPlatform {
create(providers.gradleProperty("platformType"), providers.gradleProperty("platformVersion"))
create(
providers.gradleProperty("platformType"),
providers.gradleProperty("platformVersion"),
)

// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties file for bundled IntelliJ Platform plugins.
// Plugin Dependencies. Uses `platformBundledPlugins` property from the gradle.properties
// file for bundled IntelliJ Platform plugins.
bundledPlugins(providers.gradleProperty("platformBundledPlugins").map { it.split(',') })

// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for plugin from JetBrains Marketplace.
// Plugin Dependencies. Uses `platformPlugins` property from the gradle.properties file for
// plugin from JetBrains Marketplace.
plugins(providers.gradleProperty("platformPlugins").map { it.split(',') })

// Module Dependencies. Uses `platformBundledModules` property from the gradle.properties file for bundled IntelliJ Platform modules.
// Module Dependencies. Uses `platformBundledModules` property from the gradle.properties
// file for bundled IntelliJ Platform modules.
bundledModules(providers.gradleProperty("platformBundledModules").map { it.split(',') })

testFramework(TestFrameworkType.Platform)
}
}

// Configure IntelliJ Platform Gradle Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html
// Configure IntelliJ Platform Gradle Plugin - read more:
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-extension.html
intellijPlatform {
pluginConfiguration {
name = providers.gradleProperty("pluginName")
version = providers.gradleProperty("pluginVersion")

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
description = providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

with(it.lines()) {
if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
// Extract the <!-- Plugin description --> section from README.md and provide for the
// plugin's manifest
description =
providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

with(it.lines()) {
if (!containsAll(listOf(start, end))) {
throw GradleException(
"Plugin description section not found in README.md:\n$start ... $end"
)
}
subList(indexOf(start) + 1, indexOf(end))
.joinToString("\n")
.let(::markdownToHTML)
}
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
}
}

val changelog = project.changelog // local variable for configuration cache compatibility
// Get the latest available change notes from the changelog file
changeNotes = providers.gradleProperty("pluginVersion").map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML,
)
changeNotes =
providers.gradleProperty("pluginVersion").map { pluginVersion ->
with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML,
)
}
}
}

ideaVersion {
sinceBuild = providers.gradleProperty("pluginSinceBuild")
}
ideaVersion { sinceBuild = providers.gradleProperty("pluginSinceBuild") }
}

signing {
Expand All @@ -105,44 +112,34 @@ intellijPlatform {

publishing {
token = providers.environmentVariable("PUBLISH_TOKEN")
// The 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:
// The 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 = providers.gradleProperty("pluginVersion").map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) }
channels =
providers.gradleProperty("pluginVersion").map {
listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" })
}
}

pluginVerification {
ides {
recommended()
}
}
pluginVerification { ides { recommended() } }
}

// 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 {
groups.empty()
repositoryUrl = providers.gradleProperty("pluginRepositoryUrl")
}

// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
kover {
reports {
total {
xml {
onCheck = true
}
}
}
}
kover { reports { total { xml { onCheck = true } } } }

tasks {
wrapper {
gradleVersion = providers.gradleProperty("gradleVersion").get()
}
wrapper { gradleVersion = providers.gradleProperty("gradleVersion").get() }

publishPlugin {
dependsOn(patchChangelog)
}
publishPlugin { dependsOn(patchChangelog) }
}

intellijPlatformTesting {
Expand All @@ -161,9 +158,9 @@ intellijPlatformTesting {
}
}

plugins {
robotServerPlugin()
}
plugins { robotServerPlugin() }
}
}
}

ktfmt { kotlinLangStyle() }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image Image

As for me it looks a bit ugly than it was

Also looks like there is a custom line length? Editor has a soft limit, but the formatter does not count it.

Image

Is it possible to configure it? It'd fix all these issues before merge or in a separate PR

Copy link
Collaborator Author

@xHeaven xHeaven Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understood, kotlinfmt has very specific, non-configurable, opinionated setups. See: https://github.com/facebook/ktfmt#ktfmt-uses-a-2-space-indent-why-not-4-any-way-to-change-that

I went with the 4 space indent variant - that's what you see right now. The other is Google's opinionated version with 2 space indenting. Shall we try that?

I also don't necessarily want to opt-out of a specific formatter, since different IDEs and IDE setups will result in different formatting styles over the project, which can get nasty. We could say that we push a .idea-based formatting to the repo, but not every contributor will use JB IDEs so it won't enforce anything for them. I'm open to different formatting solutions as well, let me know what you think.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave code style "as is", there are more cons than pros using this formatter.
I usually use "optimize imports" option from the commit dialog in my IDEA.
To format a file a do cmd+option+l from time to time and that's totally fine for me.
To share a codestyle guides I usually use https://www.jetbrains.com/help/idea/editorconfig.html. VScode does support it as well.

but not every contributor will use JB IDEs

CI? :)

Anyway, I'd leave all as is. If you want to collapse/expand lines or anything else I don't mind.

8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ pluginVersion = 2025.0.1
pluginSinceBuild = 243

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

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.jetbrains.php:203.4449.22, org.intellij.scala:2023.3.27@EAP
#platformPlugins=com.jetbrains.php:243.25659.59,com.jetbrains.hackathon.indices.viewer:1.28
platformPlugins=com.jetbrains.php:251.25410.129,com.jetbrains.hackathon.indices.viewer:1.28
platformPlugins=com.jetbrains.php:253.17525.99,com.jetbrains.hackathon.indices.viewer:1.31
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to support at least 4 previous major versions of the IDE.
2025.1 -> 2024.1, 2024.2, 2024.3, 2024.4
2025.2 -> 2024.2, 2024.3, 2024.4, 2025.1

Or as much as possible versions.

Could you please downgrade the plugin to the 242 and check if everything works great?

Copy link
Collaborator Author

@xHeaven xHeaven Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can try, though there was a bit of a mess with the webTypes, because below 252.*.*, there are webSymbols.webTypes, above 252.*.* there are polySymbols.webTypes. I'll take a look. I don't like the way I did the webTypes at all, though, I think it should be entirely dynamic - or at least as much as possible. I just couldn't make it work. Could you maybe look into it? Then I'm fine with any version of the IDE.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current web/poly types feature scope is to provide:

  • xml tag
  • xml attribute
  • description

That can be pretty done with custom references providers and description providers.

I have done a dynamic attributes provider. There should be another static provider for the default undeclared values. Like a map of tags and it's attributes.

Descriptions can be done with xml.attributeDescriptorsProvider and xml.elementDescriptorProvider extension points.
We can introduce another map, but I'd suggest to have one common map:

- tag:
-- name
-- description
-- content type empty (`<tag />`) / required (`<tag >...</tag>`) / any
-- attributes
--- name
--- description
--- required/optional
--- some helpful stuff
-- some helpful stuff

and use it across the project via several helperes

# Example: platformBundledPlugins = com.intellij.java
platformBundledPlugins =
# Example: platformBundledModules = intellij.spellchecker
platformBundledModules =
platformBundledModules = intellij.spellchecker

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 9.0.0
Expand Down
4 changes: 1 addition & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
}
plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" }

rootProject.name = "tempest-phpstorm-plugin"
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.github.tempest.framework

import com.intellij.codeInsight.navigation.actions.GotoDeclarationHandler
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.roots.ProjectFileIndex
import com.intellij.openapi.vfs.findPsiFile
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.html.HtmlTag
import com.intellij.psi.search.FilenameIndex
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.util.PsiTreeUtil

class ComponentGotoDeclarationHandler : GotoDeclarationHandler {
override fun getGotoDeclarationTargets(
element: PsiElement?,
offset: Int,
editor: Editor?,
): Array<PsiElement>? {
if (element == null) return null

val tag = PsiTreeUtil.getParentOfType(element, HtmlTag::class.java) ?: return null
if (!tag.name.startsWith("x-")) return null

val project = tag.project
val projectFileIndex = ProjectFileIndex.getInstance(project)
val projectFiles = mutableListOf<PsiFile>()
val libraryFiles = mutableListOf<PsiFile>()

FilenameIndex.processFilesByName(
tag.name + TempestFrameworkUtil.TEMPLATE_PREFIX,
true,
GlobalSearchScope.projectScope(project),
) { virtualFile ->
val psiFile = virtualFile.findPsiFile(project) ?: return@processFilesByName true

if (projectFileIndex.isInSourceContent(virtualFile)) {
projectFiles.add(psiFile)
} else {
libraryFiles.add(psiFile)
}

true
}

return when {
projectFiles.isNotEmpty() -> projectFiles.toTypedArray()
libraryFiles.isNotEmpty() -> libraryFiles.toTypedArray()
else -> null
}
}
}

This file was deleted.

Loading