Skip to content
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

Incremental compilation: getNewFiles does not pick up newly generated files on Windows #887

Closed
dioxic opened this issue Mar 6, 2022 · 0 comments · Fixed by #937
Closed
Assignees
Milestone

Comments

@dioxic
Copy link

dioxic commented Mar 6, 2022

Using KSP 1.6.10-1.0.4

Newly generated sources are not picked up by resolver.getNewFiles() and, consequently, resolver.getSymbolsWithAnnotation().

This is identical to #820 but on Windows.

class MyProcessor(
    private val environment: SymbolProcessorEnvironment
) : SymbolProcessor {
    var i = 0
   
    override fun process(resolver: Resolver): List<KSAnnotated> {
        println("[$i] Handling NEW: ${resolver.getNewFiles().joinToString { it.toString() }}")
        println("[$i] Handling ALL: ${resolver.getAllFiles().joinToString { it.toString() }}")
        i++

        resolver.getNewFiles()
            .forEachIndexed { idx, file ->  
                // logic approximately boils down to
                // if i == 0 generate new file with name `NewFile_idx.kt` 
            }
            
        return emptyList()
    }
}

Output on Linux (RHEL derivative):

[0] Handling NEW: File: MyFile.kt
[0] Handling ALL: File: MyFile.kt
[1] Handling NEW: File: NewFile_0.kt
[1] Handling ALL: File: MyFile.kt, File: NewFile_0.kt
[2] Handling NEW: 
[2] Handling ALL: File: MyFile.kt, File: NewFile_0.kt

Output on Windows (Windows 10 Pro):

[0] Handling NEW: File: MyFile.kt
[0] Handling ALL: File: MyFile.kt
[1] Handling NEW: File: 
[1] Handling ALL: File: MyFile.kt, File: NewFile_0.kt
@ting-yuan ting-yuan added this to the 1.0.5 milestone Mar 28, 2022
@ting-yuan ting-yuan self-assigned this Apr 5, 2022
@ting-yuan ting-yuan linked a pull request Apr 6, 2022 that will close this issue
Olivki added a commit to Olivki/kommando that referenced this issue Apr 12, 2022
The problem was due to the file we created being picked up by `autoSearch` from `getNewFiles()`, we now filter away all auto searched files that do not actually contain any nodes. This might just be a band-aid fix tho, as I don't fully understand how KSP handles all this stuff.

This wasn't caught until now due to this bug google/ksp#887
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants