Fix "Should be replaced with Kotlin function" warnings

This commit is contained in:
Dmitry Gridin
2019-04-16 12:12:06 +07:00
parent d738a12b86
commit 3bed360c98
77 changed files with 161 additions and 99 deletions
@@ -23,6 +23,8 @@ import com.intellij.openapi.editor.ex.util.EditorUtil
import com.intellij.openapi.project.Project
import java.awt.event.KeyAdapter
import java.awt.event.KeyEvent
import kotlin.math.max
import kotlin.math.min
class HistoryKeyListener(
private val project: Project, private val consoleEditor: EditorEx, private val history: CommandHistory
@@ -73,7 +75,7 @@ class HistoryKeyListener(
unfinishedCommand = document.text
}
historyPos = Math.max(historyPos - 1, 0)
historyPos = max(historyPos - 1, 0)
WriteCommandAction.runWriteCommandAction(project) {
document.setText(history[historyPos].entryText)
EditorUtil.scrollToTheEnd(consoleEditor)
@@ -89,7 +91,7 @@ class HistoryKeyListener(
return
}
historyPos = Math.min(historyPos + 1, history.size)
historyPos = min(historyPos + 1, history.size)
WriteCommandAction.runWriteCommandAction(project) {
document.setText(if (historyPos == history.size) unfinishedCommand else history[historyPos].entryText)
prevCaretOffset = document.textLength
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.console.gutter.ConsoleErrorRenderer
import org.jetbrains.kotlin.console.gutter.ConsoleIndicatorRenderer
import org.jetbrains.kotlin.console.gutter.ReplIcons
import org.jetbrains.kotlin.diagnostics.Severity
import kotlin.math.max
class ReplOutputProcessor(
private val runner: KotlinConsoleRunner
@@ -123,7 +124,7 @@ class ReplOutputProcessor(
}.values.map { messages ->
val highlighters = messages.map { message ->
val cmdStart = lastCommandStartOffset + message.range.startOffset
val cmdEnd = lastCommandStartOffset + Math.max(message.range.endOffset, message.range.startOffset + 1)
val cmdEnd = lastCommandStartOffset + max(message.range.endOffset, message.range.startOffset + 1)
val textAttributes = getAttributesForSeverity(cmdStart, cmdEnd, message.severity)
historyMarkup.addRangeHighlighter(