Function/API for Retrieving File Errors and Warnings

Hi, I would like to ask which function/API I should use to retrieve file errors or warnings and quickFixes. And do not need to open editor?

Hi,

I’m not sure, but com.intellij.analysis.problemsView.ProblemsListener and/or ProblemsCollector could help.

I tried the example code below. My project has files with problems, but the code doesn’t show any of them.

    // List all files with problems
    val problemFiles = problemsCollector.getProblemFiles()
    println("\n=== Files with Problems ===")
    
    for (file in problemFiles) {
        val count = problemsCollector.getFileProblemCount(file)
        println("\n${file.path} - $count problems")
        
        // Get problems for this file
        val problems = problemsCollector.getFileProblems(file)
        
        for (problem in problems) {
            printProblemDetails(problem)
        }
    }
}

private fun printProblemDetails(problem: Problem) {
    val problemInfo = buildString {
        append("\n=== Problem ===")
        append("\nText: ${problem.text}")
        append("\nGroup: ${problem.group ?: "N/A"}")
        append("\nDescription: ${problem.description ?: "N/A"}")
        append("\nProvider: ${problem.provider.javaClass.simpleName}")
        append("\nIcon: ${problem.icon.javaClass.simpleName}")
    }
    
    println(problemInfo)
}