Skip to content
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.github.tempest.framework

object TempestFrameworkClasses {
const val ConsoleCommand = "\\Tempest\\Console\\ConsoleCommand"

Check notice on line 4 in src/main/kotlin/com/github/tempest/framework/TempestFrameworkClasses.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Const property naming convention

Const property name `ConsoleCommand` should not contain lowercase letters
}
Original file line number Diff line number Diff line change
@@ -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<T : Any> : FileBasedIndexExtension<String, T>() {
abstract override fun getName(): ID<String, T>

abstract override fun getInputFilter(): FileBasedIndex.InputFilter

override fun dependsOnFileContent() = true

abstract override fun getIndexer(): DataIndexer<String, T, FileContent>

override fun getKeyDescriptor() = EnumeratorStringDescriptor.INSTANCE

Check notice on line 19 in src/main/kotlin/com/github/tempest/framework/common/index/AbstractIndex.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.

override fun getVersion() = 1
}
Original file line number Diff line number Diff line change
@@ -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<ConsoleCommandsIndexType>() {
companion object {
val key = ID.create<String, ConsoleCommandsIndexType>("Tempest.ConsoleCommands")
}

override fun getVersion() = 1

override fun getName() = key

override fun getValueExternalizer() = EnumeratorStringDescriptor.INSTANCE

Check notice on line 27 in src/main/kotlin/com/github/tempest/framework/console/index/ConsoleCommandsIndex.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Function or property has platform type

Declaration has type inferred from a platform call, which can lead to unchecked nullability issues. Specify type explicitly as nullable or non-nullable.

override fun getInputFilter() = FileBasedIndex.InputFilter {
it.fileType == PhpFileType.INSTANCE &&
!it.name.endsWith(TempestFrameworkUtil.TEMPLATE_SUFFIX)
}

override fun getIndexer() = DataIndexer<String, ConsoleCommandsIndexType, FileContent> { 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") }
}
}
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<lang.inspectionSuppressor
language="HTML"
implementationClass="com.github.tempest.framework.views.TempestComponentsInspectionSuppressor"/>

<fileBasedIndex
implementation="com.github.tempest.framework.console.index.ConsoleCommandsIndex" />
</extensions>
<extensions defaultExtensionNs="com.jetbrains.php">

Expand Down
Loading