The auto-completion feature in the Kotlin Compiler Server does not support type-safe builders when used in a standalone context outside of a function, which is the scenario for *.kts files. This is particularly noticeable with DSLs.
Expected Behavior
Auto-completion should work consistently for type-safe builders, e.g. HTML builders, both within functions and in standalone usage. This would significantly improve the development experience, especially when working with DSLs.
Current Behavior
While auto-completion works correctly within a function scope, it fails to provide proper suggestions or hints for standalone type-safe builders without a main function.
Steps to Reproduce
Use a type-safe HTML builder within a function and observe the functioning auto-completion.
Use the same builder in a standalone context. Notice the lack of auto-completion hints.
Example
package html
// Inside a function - auto-completion works
fun main() {
html {
head {
title { +"HTML encoding with Kotlin" }
}
}
}
// Standalone - auto-completion does not work
html {
head {
title { +"HTML encoding with Kotlin" }
}
}
class HTML() : TagWithText("html") {
fun head(init: Head.() -> Unit) = initTag(Head(), init)
val sampleValue = 222
}
// [Rest of the provided code for Element, TextElement, Tag, etc.]
In the above example, the auto-completion feature assists with the html builder when used inside the main function but does not provide assistance for the standalone html builder.
Description
The auto-completion feature in the Kotlin Compiler Server does not support type-safe builders when used in a standalone context outside of a function, which is the scenario for *.kts files. This is particularly noticeable with DSLs.
Expected Behavior
Auto-completion should work consistently for type-safe builders, e.g. HTML builders, both within functions and in standalone usage. This would significantly improve the development experience, especially when working with DSLs.
Current Behavior
While auto-completion works correctly within a function scope, it fails to provide proper suggestions or hints for standalone type-safe builders without a main function.
Steps to Reproduce
Use a type-safe HTML builder within a function and observe the functioning auto-completion. Use the same builder in a standalone context. Notice the lack of auto-completion hints.
Example
In the above example, the auto-completion feature assists with the html builder when used inside the main function but does not provide assistance for the standalone html builder.