Repository: ktorio/ktor
File: ktor-server/ktor-server-core/common/src/io/ktor/server/application/Application.kt (Kotlin)

Code before:
}

/**
 * Creates an [ServerConfig] instance.
 *
 * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.application.serverConfig)
 */
public fun serverConfig(
    environment: ApplicationEnvironment = applicationEnvironment {},
    block: ServerConfigBuilder.() -> Unit = {}
): ServerConfig {
    return ServerConfigBuilder(environment).apply(block).build()
}

/**
 * Creates an [ServerConfig] instance.
 *
 * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.application.serverConfig)
 */
public fun serverConfig(
    environment: ApplicationEnvironment = applicationEnvironment {},
    watchPaths: List<String>,
    block: ServerConfigBuilder.() -> Unit = {}
): ServerConfig {
    return ServerConfigBuilder(environment, watchPaths).apply(block).build()
}

/**
 * Represents configured and running web application, capable of handling requests.
 * It is also the application coroutine scope that is cancelled immediately at application stop so useful
 * for launching background coroutines.
 *
 * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.application.Application)
 */
@KtorDsl
public class Application internal constructor(
    environment: ApplicationEnvironment,
    developmentMode: Boolean,
    public var rootPath: String,
    public val monitor: Events,
    public val parentCoroutineContext: CoroutineContext,
    private val engineProvider: () -> ApplicationEngine
) : ApplicationCallPipeline(developmentMode, environment), CoroutineScope {

    private val applicationJob = SupervisorJob(parentCoroutineContext[Job])

    public val engine: ApplicationEngine get() = engineProvider()

    override val coroutineContext: CoroutineContext = parentCoroutineContext + applicationJob

    /**

Review comment (suggestion):
It might be not obvious that users should call this function with manually specified `watchPaths` if es2015 is enabled. I've noticed that `watchPaths` are used only on JVM. Let's introduce a function `defaultWatchPaths()` which would be defined only on JVM and would return `emptyList()` on non-JVM platforms

Code after:
}

/**
 * Creates an [ServerConfig] instance.
 *
 * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.application.serverConfig)
 */
public fun serverConfig(
    environment: ApplicationEnvironment = applicationEnvironment {},
    block: ServerConfigBuilder.() -> Unit = {}
): ServerConfig {
    return ServerConfigBuilder(environment).apply(block).build()
}

/**
 * Represents configured and running web application, capable of handling requests.
 * It is also the application coroutine scope that is cancelled immediately at application stop so useful
 * for launching background coroutines.
 *
 * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.application.Application)
 */
@KtorDsl
public class Application internal constructor(
    environment: ApplicationEnvironment,
    developmentMode: Boolean,
    public var rootPath: String,
    public val monitor: Events,
    public val parentCoroutineContext: CoroutineContext,
    private val engineProvider: () -> ApplicationEngine
) : ApplicationCallPipeline(developmentMode, environment), CoroutineScope {

    private val applicationJob = SupervisorJob(parentCoroutineContext[Job])

    public val engine: ApplicationEngine get() = engineProvider()

    override val coroutineContext: CoroutineContext = parentCoroutineContext + applicationJob

    /**
     * Cancels the application job without waiting for join.
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.application.Application.dispose)
     */
    @Deprecated(
        replaceWith = ReplaceWith("disposeAndJoin()"),
        level = DeprecationLevel.WARNING,
        message = "Use disposeAndJoin() instead."
    )
    @Suppress("DEPRECATION_ERROR")
    public fun dispose() {
        applicationJob.cancel()
        uninstallAllPlugins()