diff --git a/gradle.properties b/gradle.properties index 5729e0d..d0b2d1a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,7 @@ platformVersion = 2025.1.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:251.25410.129,com.jetbrains.hackathon.indices.viewer:1.30 # Example: platformBundledPlugins = com.intellij.java platformBundledPlugins = # Example: platformBundledModules = intellij.spellchecker diff --git a/src/main/kotlin/com/github/tempest/framework/TempestFrameworkClasses.kt b/src/main/kotlin/com/github/tempest/framework/TempestFrameworkClasses.kt new file mode 100644 index 0000000..5202dd7 --- /dev/null +++ b/src/main/kotlin/com/github/tempest/framework/TempestFrameworkClasses.kt @@ -0,0 +1,5 @@ +package com.github.tempest.framework + +object TempestFrameworkClasses { + const val ConsoleCommand = "\\Tempest\\Console\\ConsoleCommand" +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/tempest/framework/common/index/AbstractIndex.kt b/src/main/kotlin/com/github/tempest/framework/common/index/AbstractIndex.kt new file mode 100644 index 0000000..f9eb9f3 --- /dev/null +++ b/src/main/kotlin/com/github/tempest/framework/common/index/AbstractIndex.kt @@ -0,0 +1,22 @@ +package com.github.tempest.framework.common.index + +import com.intellij.util.indexing.DataIndexer +import com.intellij.util.indexing.FileBasedIndex +import com.intellij.util.indexing.FileBasedIndexExtension +import com.intellij.util.indexing.FileContent +import com.intellij.util.indexing.ID +import com.intellij.util.io.EnumeratorStringDescriptor + +abstract class AbstractIndex : FileBasedIndexExtension() { + abstract override fun getName(): ID + + abstract override fun getInputFilter(): FileBasedIndex.InputFilter + + override fun dependsOnFileContent() = true + + abstract override fun getIndexer(): DataIndexer + + override fun getKeyDescriptor() = EnumeratorStringDescriptor.INSTANCE + + override fun getVersion() = 1 +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/tempest/framework/console/index/ConsoleCommandsIndex.kt b/src/main/kotlin/com/github/tempest/framework/console/index/ConsoleCommandsIndex.kt new file mode 100644 index 0000000..c5f5639 --- /dev/null +++ b/src/main/kotlin/com/github/tempest/framework/console/index/ConsoleCommandsIndex.kt @@ -0,0 +1,49 @@ +package com.github.tempest.framework.console.index + +import com.github.tempest.framework.TempestFrameworkClasses +import com.github.tempest.framework.TempestFrameworkUtil +import com.github.tempest.framework.common.index.AbstractIndex +import com.intellij.openapi.util.text.StringUtil +import com.intellij.psi.util.PsiTreeUtil +import com.intellij.util.indexing.DataIndexer +import com.intellij.util.indexing.FileBasedIndex +import com.intellij.util.indexing.FileContent +import com.intellij.util.indexing.ID +import com.intellij.util.io.EnumeratorStringDescriptor +import com.jetbrains.php.lang.PhpFileType +import com.jetbrains.php.lang.psi.elements.PhpAttribute + +private typealias ConsoleCommandsIndexType = String + +class ConsoleCommandsIndex : AbstractIndex() { + companion object { + val key = ID.create("Tempest.ConsoleCommands") + } + + override fun getVersion() = 1 + + override fun getName() = key + + override fun getValueExternalizer() = EnumeratorStringDescriptor.INSTANCE + + override fun getInputFilter() = FileBasedIndex.InputFilter { + it.fileType == PhpFileType.INSTANCE && + !it.name.endsWith(TempestFrameworkUtil.TEMPLATE_SUFFIX) + } + + override fun getIndexer() = DataIndexer { inputData -> + inputData + .psiFile + .let { PsiTreeUtil.findChildrenOfType(it, PhpAttribute::class.java) } + .filter { it.fqn == TempestFrameworkClasses.ConsoleCommand } + .mapNotNull { attribute -> + attribute.arguments + .firstOrNull { it.name == "name" || it.name.isEmpty() } + ?.argument + ?.value + } + .map { StringUtil.unquoteString(it) } + .associateBy { it } +// .apply { println("file: ${inputData.file}, result: $this") } + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 48e0a1d..e4c2b08 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -26,6 +26,9 @@ + +