diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eb5219..35cf848 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,15 @@ # aem-groovyconsole-plugin Changelog ## [Unreleased] +### Changed +- Improved detection of AEM scripts ## [0.6.0] -### Added -- Added support for regular groovy files in folders marked as AEM Scripts Source Root +### Added +- Added support for regular groovy files in folders marked as AEM Scripts Source Root -### Changed -- Improved display documentation +### Changed +- Improved display documentation - Bug fixes ## [0.5.0] diff --git a/gradle.properties b/gradle.properties index fa39446..da04dba 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ pluginGroup = com.github.bobi.aemgroovyconsoleplugin pluginName = aem-groovyconsole-plugin # SemVer format -> https://semver.org -pluginVersion = 0.6.0 +pluginVersion = 0.6.1 # See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html # for insight into build numbers and IntelliJ Platform versions. diff --git a/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/lang/AemConsoleLanguageFileType.kt b/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/lang/AemConsoleLanguageFileType.kt index e3ec047..05bfc68 100644 --- a/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/lang/AemConsoleLanguageFileType.kt +++ b/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/lang/AemConsoleLanguageFileType.kt @@ -5,7 +5,7 @@ import icons.JetgroovyIcons import org.jetbrains.plugins.groovy.GroovyLanguage import javax.swing.Icon -object AemConsoleLanguageFileType : LanguageFileType(GroovyLanguage) { +object AemConsoleLanguageFileType : LanguageFileType(GroovyLanguage, true) { override fun getIcon(): Icon = JetgroovyIcons.Groovy.GroovyFile override fun getName(): String = "AemConsole" diff --git a/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/services/RootFoldersService.kt b/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/services/RootFoldersService.kt index 244879e..4e78fad 100644 --- a/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/services/RootFoldersService.kt +++ b/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/services/RootFoldersService.kt @@ -7,7 +7,7 @@ import com.intellij.openapi.project.Project @State(name = "AemScriptRoots") class RootFoldersService : PersistentStateComponent { - var myState: State = State() + private var myState: State = State() override fun getState(): State { return myState diff --git a/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/utils/AemFileTypeUtils.kt b/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/utils/AemFileTypeUtils.kt index 45de8ba..4f452f7 100644 --- a/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/utils/AemFileTypeUtils.kt +++ b/src/main/kotlin/com/github/bobi/aemgroovyconsoleplugin/utils/AemFileTypeUtils.kt @@ -1,5 +1,6 @@ package com.github.bobi.aemgroovyconsoleplugin.utils +import com.github.bobi.aemgroovyconsoleplugin.lang.AemConsoleLanguageFileType import com.github.bobi.aemgroovyconsoleplugin.lang.AemConsoleScriptType import com.github.bobi.aemgroovyconsoleplugin.services.RootFoldersService import com.intellij.openapi.fileTypes.LanguageFileType @@ -17,15 +18,21 @@ import org.jetbrains.plugins.groovy.GroovyLanguage @Suppress("unused") object AemFileTypeUtils { - private fun VirtualFile.isGroovyEnabledFileType(): Boolean { - val ft = fileType + private fun VirtualFile.isAemFileType(project: Project): Boolean { + val fileType = this.fileType - return ft is GroovyEnabledFileType || ft is LanguageFileType && ft.language === GroovyLanguage + return if (fileType is AemConsoleLanguageFileType) { + true + } else { + val isGroovyFileType = fileType is GroovyEnabledFileType + || (fileType is LanguageFileType && fileType.language === GroovyLanguage) + + isGroovyFileType && RootFoldersService.getInstance(project).isInsideAnyRoot(path) + } } fun VirtualFile.isAemFile(project: Project): Boolean { - return extension == AemConsoleScriptType.EXTENSION - || (isGroovyEnabledFileType() && RootFoldersService.getInstance(project).isInsideAnyRoot(path)) + return extension == AemConsoleScriptType.EXTENSION || isAemFileType(project) } fun PsiElement.isAemFile(): Boolean { diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 17a0485..8354056 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -11,7 +11,6 @@