Skip to content

Commit 1f28087

Browse files
authored
Merge pull request fwcd#56 from fwcd/cleanup-and-actions
Migrate to GitHub Actions and update to Kotlin 1.4.20, LSP4J 0.10.0 and Gradle 6.6
2 parents 5b9b638 + 19f55dd commit 1f28087

File tree

22 files changed

+114
-107
lines changed

22 files changed

+114
-107
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Build
2+
on: [push]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
java: ['11']
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Setup JDK
13+
uses: actions/setup-java@v1
14+
with:
15+
java-version: ${{ matrix.java }}
16+
- name: Build
17+
run: ./gradlew :adapter:build

.github/workflows/deploy.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Deploy
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Setup JDK
13+
uses: actions/setup-java@v1
14+
with:
15+
java-version: 11
16+
- name: Build distribution
17+
run: ./gradlew :adapter:distZip
18+
- name: Create release
19+
uses: actions/create-release@v1
20+
id: create_release
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
with:
24+
tag_name: ${{ github.ref }}
25+
release_name: Version ${{ github.ref }}
26+
draft: false
27+
prerelease: false
28+
- name: Upload asset
29+
uses: actions/upload-release-asset@v1
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
with:
33+
upload_url: ${{ steps.create_release.outputs.upload_url }}
34+
asset_path: ./adapter/build/distributions/adapter.zip
35+
asset_name: adapter.zip
36+
asset_content_type: application/zip

.travis.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Kotlin Debug Adapter
22

33
[![Release](https://img.shields.io/github/release/fwcd/kotlin-debug-adapter)](https://github.com/fwcd/kotlin-debug-adapter/releases)
4-
[![Build Status](https://travis-ci.org/fwcd/kotlin-debug-adapter.svg?branch=master)](https://travis-ci.org/fwcd/kotlin-debug-adapter)
4+
[![Build](https://github.com/fwcd/kotlin-debug-adapter/workflows/Build/badge.svg)](https://github.com/fwcd/kotlin-debug-adapter/actions)
55
[![Downloads](https://img.shields.io/github/downloads/fwcd/kotlin-debug-adapter/total)](https://github.com/fwcd/kotlin-debug-adapter/releases)
66
[![Chat](https://img.shields.io/badge/chat-on%20discord-7289da)](https://discord.gg/cNtppzN)
77

adapter/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ startScripts {
1717
}
1818

1919
repositories {
20-
mavenCentral()
2120
maven { url 'https://jitpack.io' }
2221
}
2322

2423
dependencies {
2524
// The JSON-RPC and Debug Adapter Protocol implementations
26-
implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j.debug:0.6.0'
25+
implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j.debug:0.10.0'
2726
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
2827
implementation 'org.jetbrains.kotlin:kotlin-reflect'
29-
implementation 'com.github.fwcd.kotlin-language-server:shared:229c762a4d75304d21eba6d8e1231ed949247629'
28+
implementation 'com.github.fwcd.kotlin-language-server:shared:fb2c4f58aec6738ee2b66afb583ab51e2c424ebb'
3029
// The Java Debug Interface classes (com.sun.jdi.*)
3130
implementation files("${System.properties['java.home']}/../lib/tools.jar")
3231
testImplementation 'junit:junit:4.12'

adapter/src/main/kotlin/org/javacs/ktda/adapter/DAPConverter.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,23 @@ class DAPConverter(
7272
fun toDAPBreakpoint(internalBreakpoint: InternalBreakpoint) = DAPBreakpoint().apply {
7373
source = toDAPSource(internalBreakpoint.position.source)
7474
line = lineConverter.toExternalLine(internalBreakpoint.position.lineNumber)
75-
verified = true
75+
isVerified = true
7676
}
7777

7878
fun toInternalStackFrame(frameId: Long) = stackFramePool.getByID(frameId)
7979

8080
fun toDAPStackFrame(internalFrame: InternalStackFrame, threadId: Long) = DAPStackFrame().apply {
81-
id = stackFramePool.store(threadId, internalFrame)
81+
id = stackFramePool.store(threadId, internalFrame).toInt()
8282
name = internalFrame.name
83-
line = internalFrame.position?.lineNumber?.let(lineConverter::toExternalLine) ?: 0L
83+
line = internalFrame.position?.lineNumber?.let(lineConverter::toExternalLine) ?: 0
8484
column = (internalFrame.position?.columnNumber ?: 1).let(columnConverter::toExternalLine)
8585
source = internalFrame.position?.source?.let(::toDAPSource)
8686
}
8787

8888
fun toDAPScope(variableTree: VariableTreeNode) = DAPScope().apply {
8989
name = variableTree.name
90-
variablesReference = variablesPool.store(Unit, variableTree)
91-
expensive = false
90+
variablesReference = variablesPool.store(Unit, variableTree).toInt()
91+
isExpensive = false
9292
}
9393

9494
fun toVariableTree(variablesReference: Long) = variablesPool.getByID(variablesReference)
@@ -97,12 +97,12 @@ class DAPConverter(
9797
name = variableTree.name
9898
value = variableTree.value
9999
type = variableTree.type
100-
variablesReference = variableTree.childs?.takeIf { it.isNotEmpty() }?.let { variablesPool.store(Unit, variableTree) } ?: 0
100+
variablesReference = (variableTree.childs?.takeIf { it.isNotEmpty() }?.let { variablesPool.store(Unit, variableTree) } ?: 0).toInt()
101101
}
102102

103103
fun toDAPThread(internalThread: DebuggeeThread) = DAPThread().apply {
104104
name = internalThread.name
105-
id = internalThread.id
105+
id = internalThread.id.toInt()
106106
}
107107

108108
fun toDAPCompletionItem(internalItem: InternalCompletionItem) = DAPCompletionItem().apply {

adapter/src/main/kotlin/org/javacs/ktda/adapter/KotlinDebugAdapter.kt

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ class KotlinDebugAdapter(
5555

5656
override fun initialize(args: InitializeRequestArguments): CompletableFuture<Capabilities> = async.compute {
5757
converter.lineConverter = LineNumberConverter(
58-
externalLineOffset = if (args.linesStartAt1) 0L else -1L
58+
externalLineOffset = if (args.linesStartAt1) 0 else -1
5959
)
6060
converter.columnConverter = LineNumberConverter(
61-
externalLineOffset = if (args.columnsStartAt1) 0L else -1L
61+
externalLineOffset = if (args.columnsStartAt1) 0 else -1
6262
)
6363

6464
val capabilities = Capabilities()
@@ -135,7 +135,7 @@ class KotlinDebugAdapter(
135135
val eventBus = debuggee.eventBus
136136
eventBus.exitListeners.add {
137137
// TODO: Use actual exitCode instead
138-
sendExitEvent(0L)
138+
sendExitEvent(0)
139139
}
140140
eventBus.breakpointListeners.add {
141141
sendStopEvent(it.threadID, StoppedEventArgumentsReason.BREAKPOINT)
@@ -175,20 +175,20 @@ class KotlinDebugAdapter(
175175
private fun sendThreadEvent(threadId: Long, reason: String) {
176176
client!!.thread(ThreadEventArguments().also {
177177
it.reason = reason
178-
it.threadId = threadId
178+
it.threadId = threadId.toInt()
179179
})
180180
}
181181

182182
private fun sendStopEvent(threadId: Long, reason: String) {
183183
client!!.stopped(StoppedEventArguments().also {
184184
it.reason = reason
185-
it.threadId = threadId
185+
it.threadId = threadId.toInt()
186186
})
187187
}
188188

189189
private fun sendExitEvent(exitCode: Long) {
190190
client!!.exited(ExitedEventArguments().also {
191-
it.exitCode = exitCode
191+
it.exitCode = exitCode.toInt()
192192
})
193193
client!!.terminated(TerminatedEventArguments())
194194
LOG.info("Sent exit event")
@@ -284,7 +284,7 @@ class KotlinDebugAdapter(
284284
}
285285

286286
override fun continue_(args: ContinueArguments) = async.compute {
287-
var success = debuggee!!.threadByID(args.threadId)?.resume() ?: false
287+
var success = debuggee!!.threadByID(args.threadId.toLong())?.resume() ?: false
288288
var allThreads = false
289289

290290
if (!success) {
@@ -296,7 +296,7 @@ class KotlinDebugAdapter(
296296
if (success) {
297297
exceptionsPool.clear()
298298
converter.variablesPool.clear()
299-
converter.stackFramePool.removeAllOwnedBy(args.threadId)
299+
converter.stackFramePool.removeAllOwnedBy(args.threadId.toLong())
300300
}
301301

302302
ContinueResponse().apply {
@@ -305,15 +305,15 @@ class KotlinDebugAdapter(
305305
}
306306

307307
override fun next(args: NextArguments) = async.execute {
308-
debuggee!!.threadByID(args.threadId)?.stepOver()
308+
debuggee!!.threadByID(args.threadId.toLong())?.stepOver()
309309
}
310310

311311
override fun stepIn(args: StepInArguments) = async.execute {
312-
debuggee!!.threadByID(args.threadId)?.stepInto()
312+
debuggee!!.threadByID(args.threadId.toLong())?.stepInto()
313313
}
314314

315315
override fun stepOut(args: StepOutArguments) = async.execute {
316-
debuggee!!.threadByID(args.threadId)?.stepOut()
316+
debuggee!!.threadByID(args.threadId.toLong())?.stepOut()
317317
}
318318

319319
override fun stepBack(args: StepBackArguments): CompletableFuture<Void> = notImplementedDAPMethod()
@@ -326,10 +326,10 @@ class KotlinDebugAdapter(
326326

327327
override fun pause(args: PauseArguments) = async.execute {
328328
val threadId = args.threadId
329-
val success = debuggee!!.threadByID(threadId)?.pause()
329+
val success = debuggee!!.threadByID(threadId.toLong())?.pause()
330330
if (success ?: false) {
331331
// If successful
332-
sendStopEvent(threadId,
332+
sendStopEvent(threadId.toLong(),
333333
StoppedEventArgumentsReason.PAUSE
334334
)
335335
}
@@ -344,18 +344,18 @@ class KotlinDebugAdapter(
344344
val threadId = args.threadId
345345
return completedFuture(StackTraceResponse().apply {
346346
stackFrames = debuggee!!
347-
.threadByID(threadId)
347+
.threadByID(threadId.toLong())
348348
?.stackTrace()
349349
?.frames
350-
?.map { converter.toDAPStackFrame(it, threadId) }
350+
?.map { converter.toDAPStackFrame(it, threadId.toLong()) }
351351
?.toTypedArray()
352352
.orEmpty()
353353
})
354354
}
355355

356356
override fun scopes(args: ScopesArguments) = completedFuture(
357357
ScopesResponse().apply {
358-
scopes = (converter.toInternalStackFrame(args.frameId)
358+
scopes = (converter.toInternalStackFrame(args.frameId.toLong())
359359
?: throw KotlinDAException("Could not find stackTrace with ID ${args.frameId}"))
360360
.scopes
361361
.map(converter::toDAPScope)
@@ -366,6 +366,7 @@ class KotlinDebugAdapter(
366366
override fun variables(args: VariablesArguments) = completedFuture(
367367
VariablesResponse().apply {
368368
variables = (args.variablesReference
369+
.toLong()
369370
.let(converter::toVariableTree)
370371
?: throw KotlinDAException("Could not find variablesReference with ID ${args.variablesReference}"))
371372
.childs
@@ -396,6 +397,7 @@ class KotlinDebugAdapter(
396397

397398
override fun evaluate(args: EvaluateArguments): CompletableFuture<EvaluateResponse> = async.compute {
398399
val variable = (args.frameId
400+
.toLong()
399401
.let(converter::toInternalStackFrame)
400402
?: throw KotlinDAException("Could not find stack frame with ID ${args.frameId}"))
401403
.evaluate(args.expression)
@@ -414,6 +416,7 @@ class KotlinDebugAdapter(
414416
override fun completions(args: CompletionsArguments): CompletableFuture<CompletionsResponse> = async.compute {
415417
CompletionsResponse().apply {
416418
targets = (args.frameId
419+
.toLong()
417420
.let(converter::toInternalStackFrame)
418421
?: throw KotlinDAException("Could not find stack frame with ID ${args.frameId}"))
419422
.completions(args.text)
@@ -423,7 +426,7 @@ class KotlinDebugAdapter(
423426
}
424427

425428
override fun exceptionInfo(args: ExceptionInfoArguments): CompletableFuture<ExceptionInfoResponse> = async.compute {
426-
val id = exceptionsPool.getIDsOwnedBy(args.threadId).firstOrNull()
429+
val id = exceptionsPool.getIDsOwnedBy(args.threadId.toLong()).firstOrNull()
427430
val exception = id?.let { exceptionsPool.getByID(it) }
428431
ExceptionInfoResponse().apply {
429432
exceptionId = id?.toString() ?: ""

adapter/src/main/kotlin/org/javacs/ktda/adapter/LineNumberConverter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ package org.javacs.ktda.adapter
1010
* In this case, externalLineOffset would be -1.
1111
*/
1212
class LineNumberConverter(
13-
private val externalLineOffset: Long = 0 // Internal line + externalLineOffset = External line
13+
private val externalLineOffset: Int = 0 // Internal line + externalLineOffset = External line
1414
) {
15-
fun toInternalLine(lineNumber: Long) = lineNumber - externalLineOffset
15+
fun toInternalLine(lineNumber: Int) = lineNumber - externalLineOffset
1616

17-
fun toExternalLine(lineNumber: Long) = lineNumber + externalLineOffset
17+
fun toExternalLine(lineNumber: Int) = lineNumber + externalLineOffset
1818
}

adapter/src/main/kotlin/org/javacs/ktda/core/Position.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ package org.javacs.ktda.core
33
/** A source code position. Line and column numbers are 1-indexed */
44
class Position(
55
val source: Source,
6-
val lineNumber: Long,
7-
val columnNumber: Long? = null
6+
val lineNumber: Int,
7+
val columnNumber: Int? = null
88
)

adapter/src/main/kotlin/org/javacs/ktda/jdi/JDIDebuggee.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class JDIDebuggee(
7575
breakpoints.forEach { bp ->
7676
bp.position.let { setBreakpoint(
7777
it.source.filePath.toAbsolutePath().toString(),
78-
it.lineNumber
78+
it.lineNumber.toLong()
7979
) }
8080
}
8181
}
@@ -165,7 +165,7 @@ class JDIDebuggee(
165165
}
166166

167167
override fun positionOf(location: Location): Position? = sourceOf(location)
168-
?.let { Position(it, location.lineNumber().toLong()) }
168+
?.let { Position(it, location.lineNumber()) }
169169

170170
private fun sourceOf(location: Location): Source? {
171171
val sourcePath = location.sourcePath()

0 commit comments

Comments
 (0)