@@ -15,8 +15,11 @@ import org.jetbrains.exposed.sql.Database
15
15
import org.jetbrains.exposed.sql.SqlExpressionBuilder.like
16
16
import org.jetbrains.exposed.sql.insert
17
17
18
+ private val MAX_FQNAME_LENGTH = 255
19
+ private val MAX_SHORT_NAME_LENGTH = 80
20
+
18
21
private object Symbols : Table() {
19
- val fqName = varchar(" fqname" , length = 255 ) references FqNames .fqName
22
+ val fqName = varchar(" fqname" , length = MAX_FQNAME_LENGTH ) references FqNames .fqName
20
23
val kind = integer(" kind" )
21
24
val visibility = integer(" visibility" )
22
25
val extensionReceiverType = varchar(" extensionreceivertype" , length = 255 ).nullable()
@@ -25,8 +28,8 @@ private object Symbols : Table() {
25
28
}
26
29
27
30
private object FqNames : Table() {
28
- val fqName = varchar(" fqname" , length = 255 )
29
- val shortName = varchar(" shortname" , length = 80 )
31
+ val fqName = varchar(" fqname" , length = MAX_FQNAME_LENGTH )
32
+ val shortName = varchar(" shortname" , length = MAX_SHORT_NAME_LENGTH )
30
33
31
34
override val primaryKey = PrimaryKey (fqName)
32
35
}
@@ -62,18 +65,20 @@ class SymbolIndex {
62
65
val descriptorFqn = descriptor.fqNameSafe
63
66
val extensionReceiverFqn = descriptor.accept(ExtractSymbolExtensionReceiverType , Unit )?.takeIf { ! it.isRoot }
64
67
65
- for (fqn in listOf (descriptorFqn, extensionReceiverFqn).filterNotNull()) {
66
- FqNames .replace {
67
- it[fqName] = fqn.toString()
68
- it[shortName] = fqn.shortName().toString()
68
+ if (canStoreFqName(descriptorFqn) && (extensionReceiverFqn?.let { canStoreFqName(it) } ? : true )) {
69
+ for (fqn in listOf (descriptorFqn, extensionReceiverFqn).filterNotNull()) {
70
+ FqNames .replace {
71
+ it[fqName] = fqn.toString()
72
+ it[shortName] = fqn.shortName().toString()
73
+ }
69
74
}
70
- }
71
75
72
- Symbols .replace {
73
- it[fqName] = descriptorFqn.toString()
74
- it[kind] = descriptor.accept(ExtractSymbolKind , Unit ).rawValue
75
- it[visibility] = descriptor.accept(ExtractSymbolVisibility , Unit ).rawValue
76
- it[extensionReceiverType] = extensionReceiverFqn?.toString()
76
+ Symbols .replace {
77
+ it[fqName] = descriptorFqn.toString()
78
+ it[kind] = descriptor.accept(ExtractSymbolKind , Unit ).rawValue
79
+ it[visibility] = descriptor.accept(ExtractSymbolVisibility , Unit ).rawValue
80
+ it[extensionReceiverType] = extensionReceiverFqn?.toString()
81
+ }
77
82
}
78
83
}
79
84
@@ -90,6 +95,10 @@ class SymbolIndex {
90
95
}
91
96
}
92
97
98
+ private fun canStoreFqName (fqName : FqName ) =
99
+ fqName.toString().length <= MAX_FQNAME_LENGTH
100
+ && fqName.shortName().toString().length <= MAX_SHORT_NAME_LENGTH
101
+
93
102
fun query (prefix : String , receiverType : FqName ? = null, limit : Int = 20): List <Symbol > = transaction(db) {
94
103
// TODO: Extension completion currently only works if the receiver matches exactly,
95
104
// ideally this should work with subtypes as well
0 commit comments