Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fun getResultFromScan(psiFile: PsiFile,
baseDir: VirtualFile,
file: VirtualFile): List<ErrorMessage> {
ApplicationManager.getApplication()!!.invokeAndWait(object : Runnable {
override fun run() {
FileDocumentManager.getInstance()!!.saveAllDocuments()
}
}, 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 = matcher.group(1)!!
val line = Integer.parseInt(matcher.group(2)!!)
val col = Integer.parseInt(matcher.group(3)!!)
val msg = matcher.group(4)!!.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
You can’t perform that action at this time.