Fix compatibility with AS 2.0

#KT-10153 Fixed
This commit is contained in:
Natalia Ukhorskaya
2015-11-24 19:05:37 +03:00
parent ca4bdd23e0
commit 48027f5fb5
@@ -88,7 +88,19 @@ private fun String.amendNextLinesIfNeeded(reader: OutputLineReader): String {
nextLine = reader.readLine()
}
if (nextLine != null) reader.pushBack(nextLine)
if (nextLine != null) {
// This code is needed for compatibility with AS 2.0 and IDEA 15.0, because of difference in android plugins
val positionField = try {
reader.javaClass.getDeclaredField("myPosition")
}
catch(e: Throwable) {
null
}
if (positionField != null) {
positionField.isAccessible = true
positionField.setInt(reader, positionField.getInt(reader) - 1)
}
}
return builder.toString()
}