Skip to content

Commit

Permalink
chore: update baseDir deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinHerber committed Jul 8, 2023
1 parent e6a72da commit 56f803c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ intellij {
plugins = ['JavaScript']
}

version '1.1.2'
version '1.1.3'

patchPluginXml {
sinceBuild = "231.0"
sinceBuild = "232.0"
untilBuild = "233.*"
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AttributesProvider : XmlAttributeDescriptorsProvider {
for (attr in Aurelia.INJECTABLE) {
if (name.endsWith(".$attr")) {
val attrName = name.substring(0, name.length - attr.length - 1)
if ("if" == attrName || "show" == attrName || "switch" == attrName) {
if ("if" == attrName || "show" == attrName || "switch" == attrName || Aurelia.ELSE == attrName) {
return AttributeDescriptor(name)
}
val descriptor = xmlTag.descriptor
Expand All @@ -32,9 +32,13 @@ class AttributesProvider : XmlAttributeDescriptorsProvider {
}
}
}
return if (Aurelia.REPEAT_FOR == name || Aurelia.VIRTUAL_REPEAT_FOR == name || Aurelia.AURELIA_APP == name || Aurelia.CASE == name || Aurelia.REF == name) AttributeDescriptor(
name
) else null
return if (containsAureliaAttribute(name)) {
AttributeDescriptor(name)
} else null
}

private fun containsAureliaAttribute(name: String): Boolean {
return Aurelia.REPEAT_FOR == name || Aurelia.VIRTUAL_REPEAT_FOR == name || Aurelia.AURELIA_APP == name || Aurelia.CASE == name || Aurelia.REF == name
}

private class AttributeDescriptor(private val name: String) : BasicXmlAttributeDescriptor(),
Expand Down
32 changes: 18 additions & 14 deletions src/main/kotlin/com/github/denofevil/aurelia/Aurelia.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValuesManager
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.json.psi.JsonObject
import com.intellij.openapi.project.guessProjectDir
import com.intellij.psi.PsiManager

/**
Expand All @@ -23,6 +24,7 @@ object Aurelia {
const val AURELIA_APP = "aurelia-app"
const val CASE = "case"
const val REF = "ref"
const val ELSE = "else"

fun present(project: Project) = CachedValuesManager.getManager(project).getCachedValue(project) {
val aureliaLoaded = hasDependency(project)
Expand All @@ -33,23 +35,25 @@ object Aurelia {
private fun hasDependency(project: Project): Boolean {
var hasDependency = false

VfsUtilCore.iterateChildrenRecursively(project.baseDir, null) { virtualFile ->
if (!virtualFile.isDirectory && virtualFile.name == "package.json") {
val jsonFile = PsiManager.getInstance(project).findFile(virtualFile)
val jsonObject = (jsonFile as? JsonFile)?.topLevelValue as? JsonObject

jsonObject?.findProperty("dependencies")?.let { dependenciesProp ->
val dependenciesObject = dependenciesProp.value as? JsonObject
val aureliaDependency = dependenciesObject?.findProperty("aurelia")
val aureliaCliDependency = dependenciesObject?.findProperty("aurelia-cli")
if (aureliaCliDependency != null || aureliaDependency != null) {
hasDependency = true
return@iterateChildrenRecursively false
project.guessProjectDir()?.let {
VfsUtilCore.iterateChildrenRecursively(it, null) { virtualFile ->
if (!virtualFile.isDirectory && virtualFile.name == "package.json") {
val jsonFile = PsiManager.getInstance(project).findFile(virtualFile)
val jsonObject = (jsonFile as? JsonFile)?.topLevelValue as? JsonObject

jsonObject?.findProperty("dependencies")?.let { dependenciesProp ->
val dependenciesObject = dependenciesProp.value as? JsonObject
val aureliaDependency = dependenciesObject?.findProperty("aurelia")
val aureliaCliDependency = dependenciesObject?.findProperty("aurelia-cli")
if (aureliaCliDependency != null || aureliaDependency != null) {
hasDependency = true
return@iterateChildrenRecursively false
}
}
}
}

true
true
}
}

return hasDependency
Expand Down

0 comments on commit 56f803c

Please sign in to comment.