@@ -7,8 +7,10 @@ import com.intellij.codeInsight.completion.util.ParenthesesInsertHandler
7
7
import com.intellij.codeInsight.lookup.LookupElement
8
8
import com.intellij.codeInsight.lookup.LookupElementBuilder
9
9
import com.intellij.icons.AllIcons
10
+ import com.intellij.openapi.project.Project
10
11
import com.intellij.openapi.util.text.StringUtil
11
12
import com.intellij.psi.*
13
+ import com.intellij.psi.search.GlobalSearchScope
12
14
import com.intellij.psi.search.searches.SuperMethodsSearch
13
15
import com.intellij.psi.util.PropertyUtil
14
16
import com.intellij.psi.util.PsiTreeUtil
@@ -17,7 +19,7 @@ object PebbleReferencesHelper {
17
19
private fun isOverride (method : PsiMethod )
18
20
= SuperMethodsSearch .search(method, null , true , false ).findFirst() != null
19
21
20
- fun buildPsiTypeLookups (type : PsiType ? ): Array <Any > {
22
+ fun buildPsiTypeLookups (type : PsiType ? , project : Project ): Array <Any > {
21
23
if (type is PsiClassType ) {
22
24
val clazz = type.resolve() ? : return emptyArray()
23
25
val resolveResult = type.resolveGenerics()
@@ -52,6 +54,20 @@ object PebbleReferencesHelper {
52
54
)
53
55
54
56
return lookups.toTypedArray()
57
+ } else if (type is PsiArrayType ) {
58
+ val objectType = PsiType .getJavaLangObject(
59
+ PsiManager .getInstance(project),
60
+ GlobalSearchScope .allScope(project)
61
+ )
62
+
63
+ val objectLookups = arrayListOf (* buildPsiTypeLookups(objectType, project))
64
+ objectLookups.add(
65
+ LookupElementBuilder .create(" length" )
66
+ .withTypeText(" int" )
67
+ .withIcon(AllIcons .Nodes .Property )
68
+ )
69
+
70
+ return objectLookups.toTypedArray()
55
71
}
56
72
57
73
return emptyArray()
@@ -65,7 +81,7 @@ object PebbleReferencesHelper {
65
81
for (prefix in listOf (" get" , " is" , " has" )) {
66
82
for (method in clazz.findMethodsByName(prefix + capitalizedName, true )) {
67
83
if (method.parameterList.parametersCount == 0 ) {
68
- return listOf (method);
84
+ return listOf (method)
69
85
}
70
86
}
71
87
}
@@ -108,12 +124,13 @@ object PebbleReferencesHelper {
108
124
val prevLeaf = PsiTreeUtil .prevVisibleLeaf(psi)
109
125
110
126
if (prevLeaf != null && prevLeaf.node.elementType == PebbleParserDefinition .tokens[PebbleLexer .OP_MEMBER ]) {
111
- val qualifier = prevLeaf.prevSibling
127
+ val qualifier = prevLeaf.prevSibling?.lastChild
112
128
113
129
if (qualifier != null ) {
114
130
val identifier = when (qualifier.node.elementType) {
115
131
PebbleParserDefinition .rules[PebbleParser .RULE_function_call_expression ] -> qualifier.firstChild
116
132
PebbleParserDefinition .rules[PebbleParser .RULE_term ] -> qualifier.firstChild
133
+ PebbleParserDefinition .rules[PebbleParser .RULE_parenthesized_expression ] -> qualifier.firstChild
117
134
else -> qualifier
118
135
}
119
136
0 commit comments