New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse implicit imports provided by Gradle and add Kotlin specifics #347

Merged
merged 1 commit into from May 2, 2017

Conversation

@eskatos
Member

eskatos commented Apr 29, 2017

Confirmed that it works by removing imports in samples.
Once this is in, we'll be able to remove imports for Gradle public types from our samples and the GSK build script.

@bamboo

Nice work!

Show outdated Hide outdated .../org/gradle/script/lang/kotlin/resolver/KotlinBuildScriptModelBuilder.kt
@@ -35,6 +36,7 @@ import java.io.Serializable
interface KotlinBuildScriptModel {
val classPath: List<File>
val implicitImports: List<String>

This comment has been minimized.

@bamboo

bamboo May 2, 2017

Member

I'd move it after sourcePath.

@bamboo

bamboo May 2, 2017

Member

I'd move it after sourcePath.

Show outdated Hide outdated src/main/kotlin/org/gradle/script/lang/kotlin/support/ImplicitImports.kt
}
class ImplicitImports(
importsReader: ImportsReader,
val list: List<String> = importsReader.importPackages.map { "$it.*" }.plus(listOf(

This comment has been minimized.

@bamboo

bamboo May 2, 2017

Member

I'd keep the list of imports as a lazy field and introduce two explaining functions.

class ImplicitImports(private val importsReader: ImportsReader) {

    val list by lazy {
        gradleImports() + gradleScriptKotlinImports()
    }

    fun gradleImports() = importsReader.importPackages.map { "$it.*" }

    fun gradleScriptKotlinImports() = listOf("org.gradle.script.lang.kotlin.*", "java.io.File")
}
@bamboo

bamboo May 2, 2017

Member

I'd keep the list of imports as a lazy field and introduce two explaining functions.

class ImplicitImports(private val importsReader: ImportsReader) {

    val list by lazy {
        gradleImports() + gradleScriptKotlinImports()
    }

    fun gradleImports() = importsReader.importPackages.map { "$it.*" }

    fun gradleScriptKotlinImports() = listOf("org.gradle.script.lang.kotlin.*", "java.io.File")
}
@bamboo

bamboo approved these changes May 2, 2017

💯

@eskatos eskatos merged commit 160b9b7 into master May 2, 2017

0 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/travis-ci/push The Travis CI build failed
Details

@eskatos eskatos deleted the pm-implicit-imports branch May 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment