Skip to content

Commit 0330519

Browse files
committed
Using a property instead of a setter, as suggested.
1 parent 5e3fd96 commit 0330519

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

server/src/main/kotlin/org/javacs/kt/KotlinTextDocumentService.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,8 @@ class KotlinTextDocumentService(
303303
shutdownExecutors(awaitTermination = true)
304304
}
305305

306-
fun setTestLintRecompilationCallback(callback: () -> Unit) {
307-
sp.beforeCompileCallback = callback;
308-
}
306+
var lintRecompilationCallback: () -> Unit = {}
307+
set(callback) { sp.beforeCompileCallback = callback }
309308
}
310309

311310
private inline fun<T> reportTime(block: () -> T): T {

server/src/test/kotlin/org/javacs/kt/LintTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class LintTest : SingleFileTestFixture("lint", "LintErrors.kt") {
3434
@Test fun `linting should not be dropped if another linting is running`() {
3535
var callbackCount = 0;
3636
languageServer.textDocumentService.debounceLint.waitForPendingTask()
37-
languageServer.textDocumentService.setTestLintRecompilationCallback({
37+
languageServer.textDocumentService.lintRecompilationCallback = {
3838
if (callbackCount++ == 0) {
3939
diagnostics.clear()
4040
replace(file, 3, 9, "return 11", "")
4141
languageServer.textDocumentService.documentSymbol(DocumentSymbolParams(TextDocumentIdentifier(uri(file).toString()))).get()
4242
}
43-
})
43+
}
4444
replace(file, 3, 16, "", "1")
4545

4646
while (callbackCount < 2) {
@@ -51,6 +51,6 @@ class LintTest : SingleFileTestFixture("lint", "LintErrors.kt") {
5151

5252
languageServer.textDocumentService.debounceLint.waitForPendingTask()
5353
assertThat(diagnostics, empty<Diagnostic>())
54-
languageServer.textDocumentService.setTestLintRecompilationCallback({})
54+
languageServer.textDocumentService.lintRecompilationCallback = {}
5555
}
5656
}

0 commit comments

Comments
 (0)