Skip to content

Commit

Permalink
Merge pull request #57 from bobi/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bobi committed Sep 7, 2022
2 parents 6d9bdc9 + b34d10e commit 2548de4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.intellij.openapi.project.Project

@State(name = "AemScriptRoots")
class RootFoldersService : PersistentStateComponent<RootFoldersService.State> {
var myState: State = State()
private var myState: State = State()

override fun getState(): State {
return myState
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<extensions defaultExtensionNs="com.intellij">
<fileType name="AemConsole"
extensions="aemconsole"
language="Groovy"
implementationClass="com.github.bobi.aemgroovyconsoleplugin.lang.AemConsoleLanguageFileType"
fieldName="INSTANCE"
/>
Expand Down

0 comments on commit 2548de4

Please sign in to comment.