Skip to content

Commit

Permalink
feat: add support for ref, switch, case binding
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinHerber committed May 22, 2023
1 parent e9965c1 commit a8b5405
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Features:
* Syntax highlighting in `${}` interpolations
* Controller properties completion and navigation
* New project generation via aurelia-cli
* Supports Aurelia 1 and 2

Either `aurelia` (v2), or `aurelia-cli` (v1) must be present in the project npm dependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@ import com.intellij.xml.impl.BasicXmlAttributeDescriptor
*/
class AttributesProvider : XmlAttributeDescriptorsProvider {
override fun getAttributeDescriptors(xmlTag: XmlTag): Array<XmlAttributeDescriptor> = arrayOf(
AttributeDescriptor(Aurelia.REPEAT_FOR),
AttributeDescriptor(Aurelia.VIRTUAL_REPEAT_FOR),
AttributeDescriptor(Aurelia.AURELIA_APP),
AttributeDescriptor("if.bind"),
AttributeDescriptor("show.bind")
AttributeDescriptor(Aurelia.REPEAT_FOR),
AttributeDescriptor(Aurelia.VIRTUAL_REPEAT_FOR),
AttributeDescriptor(Aurelia.AURELIA_APP)
)

override fun getAttributeDescriptor(name: String, xmlTag: XmlTag): XmlAttributeDescriptor? {
for (attr in Aurelia.INJECTABLE) {
if (name.endsWith(".$attr")) {
val attrName = name.substring(0, name.length - attr.length - 1)
if ("if" == attrName || "show" == attrName) {
if ("if" == attrName || "show" == attrName || "switch" == attrName) {
return AttributeDescriptor(name)
}
val descriptor = xmlTag.descriptor
Expand All @@ -34,10 +32,13 @@ class AttributesProvider : XmlAttributeDescriptorsProvider {
}
}
}
return if (Aurelia.REPEAT_FOR == name || Aurelia.VIRTUAL_REPEAT_FOR == name || Aurelia.AURELIA_APP == name) AttributeDescriptor(name) else null
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
}

private class AttributeDescriptor(private val name: String) : BasicXmlAttributeDescriptor(), PsiPresentableMetaData {
private class AttributeDescriptor(private val name: String) : BasicXmlAttributeDescriptor(),
PsiPresentableMetaData {
override fun getIcon() = Aurelia.ICON

override fun getTypeName(): String? = null
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/com/github/denofevil/aurelia/Aurelia.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ object Aurelia {
const val REPEAT_FOR = "repeat.for"
const val VIRTUAL_REPEAT_FOR = "virtual-repeat.for"
const val AURELIA_APP = "aurelia-app"
const val CASE = "case"
const val REF = "ref"

fun present(project: Project) = CachedValuesManager.getManager(project).getCachedValue(project) {
val aureliaLoaded = hasDependency(project)
Expand Down

0 comments on commit a8b5405

Please sign in to comment.