Created
October 4, 2014 18:04
-
-
Save ysnrkdm/f949058d9039de56b121 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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