1
1
package cc.unitmesh.idea.context
2
2
3
3
import cc.unitmesh.devti.context.SimpleClassStructure
4
- import cc.unitmesh.devti.context.builder.ClassContextBuilder
5
4
import com.intellij.openapi.diagnostic.logger
6
- import com.intellij.openapi.util.NlsSafe
7
5
import com.intellij.psi.*
8
6
import com.intellij.psi.impl.source.PsiClassReferenceType
9
- import com.intellij.psi.search.GlobalSearchScope
10
- import com.intellij.psi.search.SearchScope
11
- import com.intellij.psi.search.searches.MethodReferencesSearch
12
- import com.intellij.psi.search.searches.ReferencesSearch
13
7
14
8
object JavaContextCollection {
15
9
private val logger = logger<JavaContextCollection >()
@@ -55,7 +49,7 @@ object JavaContextCollection {
55
49
return psiStructureCache[clazz]!!
56
50
}
57
51
58
- if (isJavaBuiltin(qualifiedName) == true || isPopularFrameworks (qualifiedName) == true ) {
52
+ if (isJavaBuiltin(qualifiedName) == true || isPopularFramework (qualifiedName) == true ) {
59
53
return null
60
54
}
61
55
@@ -85,7 +79,7 @@ object JavaContextCollection {
85
79
val resolve = (field.type as PsiClassType ).resolve() ? : return @mapNotNull null
86
80
if (resolve.qualifiedName == qualifiedName) return @mapNotNull null
87
81
88
- if (isJavaBuiltin(resolve.qualifiedName) == true || isPopularFrameworks (resolve.qualifiedName) == true ) {
82
+ if (isJavaBuiltin(resolve.qualifiedName) == true || isPopularFramework (resolve.qualifiedName) == true ) {
89
83
return @mapNotNull null
90
84
}
91
85
@@ -109,14 +103,17 @@ object JavaContextCollection {
109
103
return simpleClassStructure
110
104
}
111
105
112
- private fun isPopularFrameworks (qualifiedName : @NlsSafe String? ): Boolean? {
113
- return qualifiedName?.startsWith(" org.springframework" ) == true ||
114
- qualifiedName?.startsWith(" org.apache" ) == true ||
115
- qualifiedName?.startsWith(" org.hibernate" ) == true ||
116
- qualifiedName?.startsWith(" org.slf4j" ) == true ||
117
- qualifiedName?.startsWith(" org.apache" ) == true ||
118
- qualifiedName?.startsWith(" org.junit" ) == true ||
119
- qualifiedName?.startsWith(" org.mockito" ) == true
106
+ private val popularFrameworks = listOf (
107
+ " org.springframework" ,
108
+ " org.apache" ,
109
+ " org.hibernate" ,
110
+ " org.slf4j" ,
111
+ " org.junit" ,
112
+ " org.mockito"
113
+ )
114
+
115
+ private fun isPopularFramework (qualifiedName : String? ): Boolean {
116
+ return popularFrameworks.any { qualifiedName?.startsWith(it) == true }
120
117
}
121
118
122
119
/* *
0 commit comments