File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
server/src/main/kotlin/org/javacs/kt/index Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import org.jetbrains.exposed.sql.insert
14
14
15
15
private object Symbols : Table() {
16
16
val fqName = varchar(" fqname" , length = 255 ).autoIncrement().primaryKey()
17
+ val shortName = varchar(" shortname" , length = 127 )
17
18
val kind = integer(" kind" )
18
19
}
19
20
@@ -36,8 +37,11 @@ class SymbolIndex {
36
37
try {
37
38
transaction(db) {
38
39
for (descriptor in allDescriptors(module)) {
40
+ val fqn = descriptor.fqNameSafe
41
+
39
42
Symbols .insert {
40
- it[fqName] = descriptor.fqNameSafe.toString()
43
+ it[fqName] = fqn.toString()
44
+ it[shortName] = fqn.shortName().toString()
41
45
it[kind] = descriptor.accept(ExtractSymbolKind , Unit ).rawValue
42
46
}
43
47
}
@@ -52,6 +56,13 @@ class SymbolIndex {
52
56
}
53
57
}
54
58
59
+ fun query (prefix : String , limit : Int = 20): List <Symbol > = transaction(db) {
60
+ Symbols
61
+ .selectAll()
62
+ .limit(limit)
63
+ .map { Symbol (FqName (it[Symbols .fqName]), Symbol .Kind .fromRaw(it[Symbols .kind])) }
64
+ }
65
+
55
66
private fun allDescriptors (module : ModuleDescriptor ): Collection <DeclarationDescriptor > = allPackages(module)
56
67
.map(module::getPackage)
57
68
.flatMap {
You can’t perform that action at this time.
0 commit comments