1
1
package de.shyim.shopware6.index
2
2
3
+ import com.intellij.lang.ecmascript6.psi.ES6ImportDeclaration
4
+ import com.intellij.lang.ecmascript6.psi.ES6Property
3
5
import com.intellij.lang.javascript.JSTokenTypes
4
6
import com.intellij.lang.javascript.JavaScriptFileType
5
7
import com.intellij.lang.javascript.psi.JSCallExpression
@@ -15,6 +17,7 @@ import com.intellij.util.io.EnumeratorStringDescriptor
15
17
import com.intellij.util.io.KeyDescriptor
16
18
import de.shyim.shopware6.index.dict.AdminComponent
17
19
import de.shyim.shopware6.index.externalizer.ObjectStreamDataExternalizer
20
+ import de.shyim.shopware6.util.StringUtil
18
21
import gnu.trove.THashMap
19
22
20
23
class AdminComponentIndex : FileBasedIndexExtension <String , AdminComponent >() {
@@ -25,7 +28,7 @@ class AdminComponentIndex : FileBasedIndexExtension<String, AdminComponent>() {
25
28
}
26
29
27
30
override fun getVersion (): Int {
28
- return 1
31
+ return 2
29
32
}
30
33
31
34
override fun dependsOnFileContent (): Boolean {
@@ -49,6 +52,7 @@ class AdminComponentIndex : FileBasedIndexExtension<String, AdminComponent>() {
49
52
if (element.methodExpression!! .lastChild is LeafPsiElement && (element.methodExpression!! .lastChild.text == " register" || element.methodExpression!! .lastChild.text == " extend" )) {
50
53
val arguments = element.argumentList!! .arguments
51
54
var extendsFrom: String? = null
55
+ var templatePath: String? = null
52
56
53
57
val componentName = arguments[0 ].firstChild
54
58
@@ -76,6 +80,7 @@ class AdminComponentIndex : FileBasedIndexExtension<String, AdminComponent>() {
76
80
77
81
if (visitObject != null ) {
78
82
val props = visitObject.findProperty(" props" )
83
+ val template = visitObject.findProperty(" template" )
79
84
80
85
if (props is JSProperty && props.value is JSObjectLiteralExpression ) {
81
86
val properties = (props.value as JSObjectLiteralExpression ).properties
@@ -86,11 +91,25 @@ class AdminComponentIndex : FileBasedIndexExtension<String, AdminComponent>() {
86
91
}
87
92
}
88
93
}
94
+
95
+ if (template is ES6Property ) {
96
+ inputData.psiFile.children.forEach {
97
+ if (it is ES6ImportDeclaration && it.importedBindings.size == 1 && it.importedBindings[0 ].name == " template" && it.fromClause?.referenceText != null ) {
98
+ templatePath = StringUtil .stripQuotes(it.fromClause!! .referenceText.toString())
99
+
100
+ if (templatePath!! .startsWith(" ./" )) {
101
+ val path = templatePath!! .substring(2 )
102
+ templatePath = " ${inputData.file.parent.path} /${path} "
103
+ }
104
+ }
105
+ }
106
+ }
89
107
}
90
108
91
109
val component = AdminComponent (
92
110
componentName.text.replace(" '" , " " ).replace(" \" " , " " ),
93
111
extendsFrom,
112
+ templatePath,
94
113
propsSet,
95
114
inputData.file.path
96
115
)
0 commit comments