Skip to content

Commit c3b9d2c

Browse files
committed
PR comments, mostly related to style and consistency.
1 parent 2303201 commit c3b9d2c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

server/src/main/kotlin/org/javacs/kt/codeaction/quickfix/AddMissingImportsQuickFix.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AddMissingImportsQuickFix: QuickFix {
2525

2626
getImportAlternatives(symbolName, file.parse, index).map { (importStr, edit) ->
2727
val codeAction = CodeAction()
28-
codeAction.title = "import ${importStr}"
28+
codeAction.title = "Import ${importStr}"
2929
codeAction.kind = CodeActionKind.QuickFix
3030
codeAction.diagnostics = listOf(diagnostic)
3131
codeAction.edit = WorkspaceEdit(mapOf(uri to listOf(edit)))
@@ -42,15 +42,15 @@ class AddMissingImportsQuickFix: QuickFix {
4242

4343
private fun getImportAlternatives(symbolName: String, file: KtFile, index: SymbolIndex): List<Pair<String, TextEdit>> {
4444
// wildcard matcher to empty string, because we only want to match exactly the symbol itself, not anything extra
45-
val queryResult = index.query(symbolName, wildcardMatcher = "")
45+
val queryResult = index.query(symbolName, suffix = "")
4646

4747
return queryResult
48-
.filter { it.kind != Symbol.Kind.MODULE }
4948
.filter {
49+
it.kind != Symbol.Kind.MODULE &&
5050
// TODO: Visibility checker should be less liberal
51-
it.visibility == Symbol.Visibility.PUBLIC
52-
|| it.visibility == Symbol.Visibility.PROTECTED
53-
|| it.visibility == Symbol.Visibility.INTERNAL
51+
(it.visibility == Symbol.Visibility.PUBLIC
52+
|| it.visibility == Symbol.Visibility.PROTECTED
53+
|| it.visibility == Symbol.Visibility.INTERNAL)
5454
}
5555
.map {
5656
Pair(it.fqName.toString(), getImportTextEditEntry(file, it.fqName))

server/src/main/kotlin/org/javacs/kt/index/SymbolIndex.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@ class SymbolIndex {
177177
fqName.toString().length <= MAX_FQNAME_LENGTH
178178
&& fqName.shortName().toString().length <= MAX_SHORT_NAME_LENGTH
179179

180-
fun query(prefix: String, receiverType: FqName? = null, limit: Int = 20, wildcardMatcher: String = "%"): List<Symbol> = transaction(db) {
180+
fun query(prefix: String, receiverType: FqName? = null, limit: Int = 20, suffix: String = "%"): List<Symbol> = transaction(db) {
181181
// TODO: Extension completion currently only works if the receiver matches exactly,
182182
// ideally this should work with subtypes as well
183183
SymbolEntity.find {
184-
(Symbols.shortName like "$prefix$wildcardMatcher") and (Symbols.extensionReceiverType eq receiverType?.toString())
184+
(Symbols.shortName like "$prefix$suffix") and (Symbols.extensionReceiverType eq receiverType?.toString())
185185
}.limit(limit)
186186
.map { Symbol(
187187
fqName = FqName(it.fqName),

0 commit comments

Comments
 (0)