Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
java-version: 21

# Setup Gradle
- name: Setup Gradle
Expand Down
27 changes: 3 additions & 24 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,8 @@ dependencies {

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

// Auto-detect local PhpStorm installation if possible
val localPhpStorm = file("${System.getProperty("user.home")}/Applications/PhpStorm.app/Contents")
if (localPhpStorm.exists()) {
val infoPlist = file("${localPhpStorm}/Info.plist")
if (infoPlist.exists()) {
try {
val plistContent = infoPlist.readText()
val versionMatch = Regex("<key>CFBundleShortVersionString</key>\\s*<string>([^<]+)</string>").find(plistContent)
if (versionMatch != null) {
val detectedVersion = versionMatch.groupValues[1]
// Convert version like "2025.1.3" to "2025.1"
platformVersion = detectedVersion.split(".").take(2).joinToString(".")
platformType = "PS"
}
} catch (e: Exception) {
println("Unable to parse PhpStorm version number: ${e.message} (will not use local IDE)")
}
}
}
val platformType = providers.gradleProperty("platformType").get()
val platformVersion = providers.gradleProperty("platformVersion").get()

println("Using $platformType $platformVersion for testing")
create(platformType, platformVersion)
Expand Down Expand Up @@ -131,8 +111,7 @@ intellijPlatform {

pluginVerification {
ides {
// Only verify against the current version to speed up CI
ide("IU-2025.1")
recommended()
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ org.gradle.caching = true

# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
systemProp.org.gradle.unsafe.kotlin.assignment = true

# Increase heap for building against large local IDE installations
org.gradle.jvmargs = -Xmx2g
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ opentest4j = "1.3.0"

# plugins
changelog = "2.2.1"
intelliJPlatform = "2.6.0"
intelliJPlatform = "2.11.0"
kotlin = "2.1.21"
kover = "0.9.1"
qodana = "2025.1.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class AlpineAttributeDescriptor(
return info.typeText
}

override fun init(psiElement: PsiElement) {}
@Suppress("WRONG_NULLABILITY_FOR_JAVA_OVERRIDE")
override fun init(psiElement: PsiElement?) {}

override fun isRequired(): Boolean = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.github.inxilpro.intellijalpine.attributes.AttributeInfo
import com.github.inxilpro.intellijalpine.completion.AutoCompleteSuggestions
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.project.Project
import org.apache.commons.lang3.tuple.MutablePair

interface AlpinePlugin {
companion object {
Expand All @@ -20,7 +19,7 @@ interface AlpinePlugin {

fun getTypeText(info: AttributeInfo): String? = null

fun injectJsContext(context: MutablePair<String, String>): MutablePair<String, String> = context
fun injectJsContext(context: JsContext): JsContext = context

fun directiveSupportJavaScript(directive: String): Boolean = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import com.github.inxilpro.intellijalpine.core.detection.PluginDetector
import com.github.inxilpro.intellijalpine.settings.AlpineProjectSettingsState
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.Service
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.openapi.vfs.newvfs.BulkFileListener
import com.intellij.openapi.vfs.newvfs.events.VFileEvent
import com.intellij.util.messages.MessageBusConnection
import org.apache.commons.lang3.tuple.MutablePair
import java.util.concurrent.ConcurrentHashMap

private val LOG = logger<AlpinePluginRegistry>()

@Service(Service.Level.APP)
class AlpinePluginRegistry {
private val listeners = ConcurrentHashMap<String, MessageBusConnection>()
Expand Down Expand Up @@ -61,7 +64,7 @@ class AlpinePluginRegistry {
return getRegisteredPlugins().firstNotNullOfOrNull { it.getTypeText(info) }
}

fun injectAllJsContext(project: Project, context: MutablePair<String, String>): MutablePair<String, String> {
fun injectAllJsContext(project: Project, context: JsContext): JsContext {
return getEnabledPlugins(project).fold(context) { acc, plugin ->
plugin.injectJsContext(acc)
}
Expand All @@ -72,8 +75,11 @@ class AlpinePluginRegistry {
}

fun checkAndAutoEnablePlugins(project: Project) {
if (DumbService.isDumb(project)) return

getRegisteredPlugins().forEach { plugin ->
if (!isPluginEnabled(project, plugin.getPluginName()) && detector.detect(project, plugin)) {
LOG.info("Auto-enabling Alpine plugin '${plugin.getPluginName()}' for project '${project.name}'")
enablePlugin(project, plugin.getPluginName())
}
}
Expand All @@ -84,12 +90,11 @@ class AlpinePluginRegistry {
private fun setupPackageJsonListener(project: Project) {
val projectPath = project.basePath ?: project.name

// Don't set up listener if already exists
if (listeners.containsKey(projectPath)) {
return
}

val connection = project.messageBus.connect()
val connection = project.messageBus.connect(project)
listeners[projectPath] = connection

connection.subscribe(VirtualFileManager.VFS_CHANGES, object : BulkFileListener {
Expand All @@ -101,10 +106,13 @@ class AlpinePluginRegistry {

if (hasPackageJsonChanges) {
ApplicationManager.getApplication().executeOnPooledThread {
ApplicationManager.getApplication().runReadAction {
getRegisteredPlugins().forEach { plugin ->
if (!isPluginEnabled(project, plugin.getPluginName()) && detector.detect(project, plugin)) {
enablePlugin(project, plugin.getPluginName())
DumbService.getInstance(project).runWhenSmart {
ApplicationManager.getApplication().runReadAction {
getRegisteredPlugins().forEach { plugin ->
if (!isPluginEnabled(project, plugin.getPluginName()) && detector.detect(project, plugin)) {
LOG.info("Auto-enabling Alpine plugin '${plugin.getPluginName()}' after package.json change")
enablePlugin(project, plugin.getPluginName())
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.github.inxilpro.intellijalpine.core

data class JsContext(var prefix: String, var suffix: String)
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package com.github.inxilpro.intellijalpine.core.detection
import com.github.inxilpro.intellijalpine.core.AlpinePlugin
import com.intellij.json.psi.JsonFile
import com.intellij.json.psi.JsonObject
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiManager
import com.intellij.psi.search.FilenameIndex
import com.intellij.psi.search.GlobalSearchScope

class PackageJsonDetector : DetectionStrategy {
override fun detect(project: Project, plugin: AlpinePlugin): Boolean {
if (DumbService.isDumb(project)) return false
val packageJsonFiles = FilenameIndex.getVirtualFilesByName(
"package.json",
GlobalSearchScope.projectScope(project)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.github.inxilpro.intellijalpine.core.detection

import com.github.inxilpro.intellijalpine.core.AlpinePlugin
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.search.FilenameIndex
import com.intellij.psi.search.GlobalSearchScope

class ScriptReferenceDetector : DetectionStrategy {
override fun detect(project: Project, plugin: AlpinePlugin): Boolean {
if (DumbService.isDumb(project)) return false
return hasScriptTagReferences(project, plugin) || hasImportReferences(project, plugin)
}

Expand Down
Loading
Loading