Skip to content
Snippets Groups Projects
Commit fcd2cc48 authored by sebastian's avatar sebastian
Browse files

fixed bug when a Windows system has multiple roots

parent f017bc5f
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ import org.eclipse.lsp4j.Diagnostic
import org.eclipse.lsp4j.DiagnosticSeverity
import org.eclipse.lsp4j.Position
import org.eclipse.lsp4j.Range
import java.io.File
fun convertErrorItems(errorItems: List<ErrorItem>, currentLoadedFile : String) : List<Diagnostic>{
return errorItems.map { errorItem ->
......@@ -15,7 +16,7 @@ fun convertErrorItems(errorItems: List<ErrorItem>, currentLoadedFile : String) :
Position(location.endLine - 1, location.endColumn)),
errorItem.message,
getErrorItemType(errorItem.type),
location.filename)
separatorToSystems(location.filename))
}.ifEmpty { //Fallback when errors from prob do not have position infos
listOf(Diagnostic(Range(
......@@ -23,11 +24,28 @@ fun convertErrorItems(errorItems: List<ErrorItem>, currentLoadedFile : String) :
Position(0,0)),
errorItem.message,
getErrorItemType(errorItem.type),
currentLoadedFile))
separatorToSystems(currentLoadedFile)))
}
}.flatten()
}
/**
* ProB spits path out in linux writing which is okay, if we have only one root. However, in windows we can have multiple
* roots. The path needs then to be normalized for the given OS
*
* @param path the path to normalize
*/
fun separatorToSystems(path : String) : String{
return if (File.separatorChar=='\\') {
// From Windows to Linux/Mac
path.replace('/', File.separatorChar);
} else {
// From Linux/Mac to Windows
path.replace('\\', File.separatorChar);
}
}
fun getErrorItemType(errorItem: ErrorItem.Type) : DiagnosticSeverity{
return when(errorItem){
ErrorItem.Type.ERROR -> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment