File tree Expand file tree Collapse file tree 7 files changed +129
-3
lines changed
kotlin/com/github/tempest/framework Expand file tree Collapse file tree 7 files changed +129
-3
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,6 @@ import com.intellij.psi.search.GlobalSearchScope
1414import com.intellij.psi.xml.XmlChildRole
1515import com.intellij.util.ProcessingContext
1616
17- private const val TEMPLATE_PREFIX = " .view.php"
18-
1917class ComponentReferenceContributor : PsiReferenceContributor () {
2018 override fun registerReferenceProviders (registrar : PsiReferenceRegistrar ) {
2119 registrar.registerReferenceProvider(
@@ -35,7 +33,7 @@ class ComponentReferenceContributor : PsiReferenceContributor() {
3533 val result = mutableListOf<PsiReference >()
3634
3735 FilenameIndex .processFilesByName(
38- element.name + TEMPLATE_PREFIX ,
36+ element.name + TempestFrameworkUtil . TEMPLATE_PREFIX ,
3937 true ,
4038 GlobalSearchScope .projectScope(project),
4139 {
Original file line number Diff line number Diff line change 1+ package com.github.tempest.framework
2+
3+ import com.intellij.codeInsight.lookup.LookupElement
4+ import com.intellij.codeInsight.lookup.LookupElementBuilder
5+ import com.intellij.psi.search.FilenameIndex
6+ import com.intellij.psi.search.GlobalSearchScope
7+ import com.intellij.psi.xml.XmlTag
8+ import com.intellij.xml.XmlTagNameProvider
9+
10+ class ComponentTagNameProvider : XmlTagNameProvider {
11+ override fun addTagNameVariants (
12+ elements : MutableList <LookupElement >,
13+ tag : XmlTag ,
14+ prefix : String?
15+ ) {
16+ val project = tag.project
17+
18+ val result = mutableListOf<String >()
19+ FilenameIndex .processAllFileNames(
20+ {
21+ if (it.startsWith(" x-" ) && it.endsWith(TempestFrameworkUtil .TEMPLATE_PREFIX )) {
22+ result.add(it.removeSuffix(TempestFrameworkUtil .TEMPLATE_PREFIX ))
23+ }
24+
25+ true
26+ },
27+ GlobalSearchScope .projectScope(project),
28+ null ,
29+ )
30+
31+ result
32+ .distinct()
33+ .map {
34+ LookupElementBuilder .create(it)
35+ .withIcon(TempestIcons .TEMPEST )
36+ .withTypeText(" Tempest Component" )
37+ }
38+ .apply { elements.addAll(this ) }
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ package com.github.tempest.framework
2+
3+ object TempestFrameworkUtil {
4+ const val TEMPLATE_PREFIX = " .view.php"
5+ }
Original file line number Diff line number Diff line change 1+ package com.github.tempest.framework
2+
3+ import com.intellij.openapi.util.IconLoader
4+
5+ object TempestIcons {
6+ @JvmField
7+ val TEMPEST = IconLoader .getIcon(" /icons/tempest/icon.svg" , TempestIcons ::class .java)
8+ }
Original file line number Diff line number Diff line change 1515 <webSymbols .webTypes
1616 source =" META-INF/webTypes.json"
1717 enableByDefault =" true" />
18+ <xml .tagNameProvider implementation =" com.github.tempest.framework.ComponentTagNameProvider" />
1819 <psi .referenceContributor language =" HTML" implementation =" com.github.tempest.framework.ComponentReferenceContributor" />
1920 <spellchecker .bundledDictionaryProvider
2021 implementation =" com.github.tempest.framework.SpellcheckingDictionaryProvider" />
You can’t perform that action at this time.
0 commit comments