Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
fun getResultFromScan(psiFile: PsiFile,
baseDir: VirtualFile,
file: VirtualFile): List<ErrorMessage> {
ApplicationManager.getApplication()!!.invokeAndWait(object : Runnable {
override fun run() {
}, ModalityState.any())
val scan = psiFile.getProject().getComponent(javaClass<Scan>())!!
val absolutePath = file.getCanonicalPath()!!
val result = scan.runCommand(absolutePath)
val errors = ArrayList<ErrorMessage>()
for (resultLine in result) {
val matcher = Pattern.compile("(.*):(\\d*):(\\d*):(.*)").matcher(resultLine)
if (matcher.find()) {
val path =!!
val line = Integer.parseInt(!!)
val col = Integer.parseInt(!!)
val msg =!!.replace("\u0000", "\n")
val severity = ErrorMessage.Severity.Warning
if (absolutePath == path) {
errors.add(ErrorMessage(msg, path, severity, line, col, line, col))
return errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment