From ad2749744e82e2460fca44ebd8f580d5f8155a0f Mon Sep 17 00:00:00 2001 From: bobi Date: Wed, 7 Sep 2022 02:59:20 +0300 Subject: [PATCH 1/2] fixed notice --- .../bobi/aemgroovyconsoleplugin/services/RootFoldersService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From b34d10e86d56d789b72cce70d917623dc4879419 Mon Sep 17 00:00:00 2001 From: bobi Date: Wed, 7 Sep 2022 12:42:53 +0300 Subject: [PATCH 2/2] - Improved detection of AEM scripts --- CHANGELOG.md | 10 ++++++---- gradle.properties | 2 +- .../lang/AemConsoleLanguageFileType.kt | 2 +- .../utils/AemFileTypeUtils.kt | 17 ++++++++++++----- src/main/resources/META-INF/plugin.xml | 1 - 5 files changed, 20 insertions(+), 12 deletions(-) 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/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 @@