Skip to content

Commit 6e1a7d6

Browse files
committed
minor changes
1 parent 001cd30 commit 6e1a7d6

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ intellijPlatform {
4040

4141
tasks.test { useJUnit() }
4242

43+
// Copy README.md to resources so it can be served via GET endpoint
44+
tasks.processResources {
45+
from(layout.projectDirectory.file("README.md")) {
46+
into("hot-reload")
47+
}
48+
}
49+
4350
// Deploy plugin to local IntelliJ 253 installation
4451
val deployPluginLocallyTo253 by tasks.registering(Sync::class) {
4552
dependsOn(tasks.buildPlugin)

src/main/kotlin/com/jonnyzzz/intellij/hotreload/HotReloadHttpHandler.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,13 @@ class HotReloadHttpHandler : HttpRequestHandler() {
4141
}
4242

4343
private fun handleGet(request: FullHttpRequest, context: ChannelHandlerContext): Boolean {
44-
val json = """{"status":"ok","pid":${ProcessHandle.current().pid()}}"""
45-
val content = Unpooled.copiedBuffer(json, Charsets.UTF_8)
44+
val readme = javaClass.getResourceAsStream("/hot-reload/README.md")
45+
?.bufferedReader()?.readText()
46+
?: "README.md not found in resources"
47+
48+
val content = Unpooled.copiedBuffer(readme, Charsets.UTF_8)
4649
val response = DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, content)
47-
response.headers().set(HttpHeaderNames.CONTENT_TYPE, "application/json")
50+
response.headers().set(HttpHeaderNames.CONTENT_TYPE, "text/markdown; charset=utf-8")
4851
response.addCommonHeaders()
4952
response.send(context.channel(), request)
5053
return true
@@ -76,7 +79,15 @@ class HotReloadHttpHandler : HttpRequestHandler() {
7679
channel.write(response)
7780

7881
fun writeLine(line: String) {
79-
channel.writeAndFlush(DefaultHttpContent(Unpooled.copiedBuffer("$line\n", Charsets.UTF_8)))
82+
log.info("Hot reload progress: $line")
83+
// Execute write on the channel's event loop for thread safety
84+
if (channel.eventLoop().inEventLoop()) {
85+
channel.writeAndFlush(DefaultHttpContent(Unpooled.copiedBuffer("$line\n", Charsets.UTF_8)))
86+
} else {
87+
channel.eventLoop().execute {
88+
channel.writeAndFlush(DefaultHttpContent(Unpooled.copiedBuffer("$line\n", Charsets.UTF_8)))
89+
}
90+
}
8091
}
8192

8293
val progressReporter = object : PluginHotReloadService.ProgressReporter {

src/main/resources/META-INF/plugin.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
<idea-plugin>
22
<id>com.jonnyzzz.intellij.hot-reload</id>
3-
<name>Plugin Hot Reload</name>
4-
<vendor>jonnyzzz.com</vendor>
3+
<name>Hot Reload</name>
4+
<vendor email="intellij@jonnyzzz.com" url="https://jonnyzzz.com">jonnyzzz.com</vendor>
55

66
<description><![CDATA[
7-
Provides an HTTP REST endpoint for plugin hot reload functionality.
8-
Creates a marker file under user home directory for process discovery.
7+
Provides an HTTP REST endpoint for plugin hot reload functionality.
8+
Creates a marker file under user home directory for process discovery.
9+
Enables dynamic plugin installation and unloading without IDE restart.
910
]]></description>
1011

12+
<change-notes><![CDATA[
13+
Initial release with HTTP-based plugin hot reload support.
14+
]]></change-notes>
15+
1116
<depends>com.intellij.modules.platform</depends>
1217

1318
<extensions defaultExtensionNs="com.intellij">

0 commit comments

Comments
 (0)