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
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.idea.util.requireNode
import org.jetbrains.kotlin.lexer.KtTokens
import java.util.*
import kotlin.math.max
fun CommonCodeStyleSettings.createSpaceBeforeRBrace(numSpacesOtherwise: Int, textRange: TextRange): Spacing? {
return Spacing.createDependentLFSpacing(numSpacesOtherwise, numSpacesOtherwise, textRange,
@@ -107,7 +108,7 @@ class KotlinSpacingBuilder(val commonCodeStyleSettings: CommonCodeStyleSettings,
val dependentSpacingRule = DependentSpacingRule(Trigger.HAS_LINE_FEEDS).registerData(Anchor.MIN_LINE_FEEDS, emptyLines + 1)
spacingBuilderUtil.createLineFeedDependentSpacing(numSpacesOtherwise,
numSpacesOtherwise,
if (leftEndsWithComment) Math.max(1, numberOfLineFeedsOtherwise) else numberOfLineFeedsOtherwise,
if (leftEndsWithComment) max(1, numberOfLineFeedsOtherwise) else numberOfLineFeedsOtherwise,
commonCodeStyleSettings.KEEP_LINE_BREAKS,
commonCodeStyleSettings.KEEP_BLANK_LINES_IN_DECLARATIONS,
left.textRange,
@@ -38,7 +38,7 @@ object JsLibraryStdDetectionUtil {
if (library !is LibraryEx || library.isDisposed) return false
if (!ignoreKind && library.effectiveKind(project) !is JSLibraryKind) return false
val classes = Arrays.asList(*library.getFiles(OrderRootType.CLASSES))
val classes = listOf(*library.getFiles(OrderRootType.CLASSES))
return getJsStdLibJar(classes) != null
}
@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.psi.psiUtil.*
import org.jetbrains.kotlin.resolve.bindingContextUtil.getReferenceTargets
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
import kotlin.math.max
var KtFile.doNotComplete: Boolean? by UserDataProperty(Key.create("DO_NOT_COMPLETE"))
@@ -71,7 +72,7 @@ class KotlinCompletionContributor : CompletionContributor() {
context.replacementOffset = context.replacementOffset
val offset = context.startOffset
val tokenBefore = psiFile.findElementAt(Math.max(0, offset - 1))
val tokenBefore = psiFile.findElementAt(max(0, offset - 1))
if (offset > 0 && tokenBefore!!.node.elementType == KtTokens.REGULAR_STRING_PART && tokenBefore.text.startsWith(".")) {
val prev = tokenBefore.parent.prevSibling
@@ -104,7 +105,7 @@ class KotlinCompletionContributor : CompletionContributor() {
?: DEFAULT_DUMMY_IDENTIFIER
}
val tokenAt = psiFile.findElementAt(Math.max(0, offset))
val tokenAt = psiFile.findElementAt(max(0, offset))
if (tokenAt != null) {
if (context.completionType == CompletionType.SMART && !isAtEndOfLine(offset, context.editor.document) /* do not use parent expression if we are at the end of line - it's probably parsed incorrectly */) {
var parent = tokenAt.parent
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.idea.completion.handlers.WithExpressionPrefixInsertH
import org.jetbrains.kotlin.idea.completion.handlers.WithTailInsertHandler
import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject
import java.util.*
import kotlin.math.max
class LookupElementsCollector(
private val onFlush: () -> Unit,
@@ -157,7 +158,7 @@ class LookupElementsCollector(
}
val matchingDegree = RealPrefixMatchingWeigher.getBestMatchingDegree(result, prefixMatcher)
bestMatchingDegree = Math.max(bestMatchingDegree, matchingDegree)
bestMatchingDegree = max(bestMatchingDegree, matchingDegree)
}
// used to avoid insertion of spaces before/after ',', '=' on just typing
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.psiUtil.startOffset
import kotlin.math.min
class ToFromOriginalFileMapper private constructor(
val originalFile: KtFile,
@@ -49,7 +50,7 @@ class ToFromOriginalFileMapper private constructor(
syntheticLength = syntheticText.length
originalLength = originalText.length
val minLength = Math.min(originalLength, syntheticLength)
val minLength = min(originalLength, syntheticLength)
tailLength = (0..minLength-1).firstOrNull {
syntheticText[syntheticLength - it - 1] != originalText[originalLength - it - 1]
} ?: minLength
@@ -22,6 +22,7 @@ import com.intellij.codeInsight.lookup.WeighingContext
import com.intellij.openapi.util.Key
import com.intellij.psi.codeStyle.NameUtil
import org.jetbrains.kotlin.idea.core.ExpectedInfo
import kotlin.math.min
val NAME_SIMILARITY_KEY = Key<Int>("NAME_SIMILARITY_KEY")
@@ -49,7 +50,7 @@ private fun calcNameSimilarity(name: String, expectedName: String): Int {
val nonNumberWords2 = words2.filter(::isNonNumber)
// count number of words matched at the end (but ignore number words - they are less important)
val minWords = Math.min(nonNumberWords1.size, nonNumberWords2.size)
val minWords = min(nonNumberWords1.size, nonNumberWords2.size)
val matchedTailLength = (0..minWords-1).firstOrNull {
i -> nonNumberWords1[nonNumberWords1.size - i - 1] != nonNumberWords2[nonNumberWords2.size - i - 1]
} ?: minWords
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset
import org.jetbrains.kotlin.psi.psiUtil.siblings
import org.jetbrains.kotlin.psi.psiUtil.startOffset
import org.jetbrains.kotlin.utils.ifEmpty
import kotlin.math.min
fun moveCaretIntoGeneratedElement(editor: Editor, element: PsiElement) {
val project = element.project
@@ -120,7 +121,7 @@ private fun moveCaretIntoGeneratedElementDocumentUnblocked(editor: Editor, eleme
val start = firstInBlock.textRange!!.startOffset
val end = lastInBlock.textRange!!.endOffset
editor.moveCaret(Math.min(start, end))
editor.moveCaret(min(start, end))
if (start < end) {
editor.selectionModel.setSelection(start, end)
@@ -261,7 +261,7 @@ abstract class AbstractGradleMultiplatformWizardTest : ProjectWizardTestCase<Abs
addSdk(SimpleJavaSdkType().createJdk("_other", javaHome))
println("ProjectWizardTestCase.configureJdk:")
println(Arrays.asList(*ProjectJdkTable.getInstance().allJdks))
println(listOf(*ProjectJdkTable.getInstance().allJdks))
FileTypeManager.getInstance().associateExtension(GroovyFileType.GROOVY_FILE_TYPE, "gradle")
}
@@ -278,7 +278,7 @@ abstract class GradleImportingTestCase : ExternalSystemImportingTestCase() {
@JvmStatic
@Parameterized.Parameters(name = "{index}: with Gradle-{0}")
fun data(): Collection<Array<Any>> {
return Arrays.asList(*AbstractModelBuilderTest.SUPPORTED_GRADLE_VERSIONS)
return listOf(*AbstractModelBuilderTest.SUPPORTED_GRADLE_VERSIONS)
}
fun wrapperJar(): File {
@@ -67,7 +67,7 @@ abstract class KotlinWithLibraryConfigurator protected constructor() : KotlinPro
var nonConfiguredModules = if (!ApplicationManager.getApplication().isUnitTestMode)
getCanBeConfiguredModules(project, this)
else
Arrays.asList(*ModuleManager.getInstance(project).modules)
listOf(*ModuleManager.getInstance(project).modules)
nonConfiguredModules -= excludeModules
var modulesToConfigure = nonConfiguredModules
@@ -40,6 +40,8 @@ import org.jetbrains.kotlin.idea.util.application.runReadAction
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import java.util.*
import kotlin.math.max
import kotlin.math.min
class KotlinFrameExtraVariablesProvider : FrameExtraVariablesProvider {
override fun isAvailable(sourcePosition: SourcePosition, evalContext: EvaluationContext): Boolean {
@@ -70,12 +72,12 @@ private fun findAdditionalExpressions(position: SourcePosition): Set<TextWithImp
val limit = getLineRangeForElement(containingElement, doc)
var startLine = Math.max(limit.startOffset, line)
var startLine = max(limit.startOffset, line)
while (startLine - 1 > limit.startOffset && shouldSkipLine(file, doc, startLine - 1)) {
startLine--
}
var endLine = Math.min(limit.endOffset, line)
var endLine = min(limit.endOffset, line)
while (endLine + 1 < limit.endOffset && shouldSkipLine(file, doc, endLine + 1)) {
endLine++
}
@@ -59,6 +59,8 @@ import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCallIm
import org.jetbrains.kotlin.resolve.inline.InlineUtil
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.utils.keysToMap
import kotlin.math.max
import kotlin.math.min
class KotlinSteppingCommandProvider : JvmSteppingCommandProvider() {
override fun getStepOverCommand(
@@ -268,7 +270,7 @@ private fun findCallsOnPosition(sourcePosition: SourcePosition, filter: (KtCallE
return allFilteredCalls.filter {
val shouldInclude = it.getLineNumber() in linesRange
if (shouldInclude) {
linesRange = Math.min(linesRange.start, it.getLineNumber())..Math.max(linesRange.endInclusive, it.getLineNumber(false))
linesRange = min(linesRange.start, it.getLineNumber())..max(linesRange.endInclusive, it.getLineNumber(false))
}
shouldInclude
}
@@ -53,6 +53,7 @@ import java.util.*
import javax.swing.JButton
import javax.swing.JCheckBox
import javax.swing.JPanel
import kotlin.math.min
sealed class BytecodeGenerationResult {
data class Bytecode(val text: String) : BytecodeGenerationResult()
@@ -154,10 +155,10 @@ class KotlinBytecodeToolWindow(private val myProject: Project, private val toolW
val byteCodeDocument = myEditor.document
val linesRange = mapLines(byteCodeDocument.text, startLine, endLine)
val endSelectionLineIndex = Math.min(linesRange.second + 1, byteCodeDocument.lineCount)
val endSelectionLineIndex = min(linesRange.second + 1, byteCodeDocument.lineCount)
val startOffset = byteCodeDocument.getLineStartOffset(linesRange.first)
val endOffset = Math.min(byteCodeDocument.getLineStartOffset(endSelectionLineIndex), byteCodeDocument.textLength)
val endOffset = min(byteCodeDocument.getLineStartOffset(endSelectionLineIndex), byteCodeDocument.textLength)
myEditor.caretModel.moveToOffset(endOffset)
myEditor.scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE)
@@ -308,7 +308,7 @@ class LiveTemplatesTest : KotlinLightCodeInsightFixtureTestCase() {
}
private fun assertStringItems(@NonNls vararg items: String) {
TestCase.assertEquals(Arrays.asList(*items), Arrays.asList(*itemStringsSorted))
TestCase.assertEquals(listOf(*items), listOf(*itemStringsSorted))
}
private val itemStrings: Array<String>
@@ -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(
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtCatchClause
import org.jetbrains.kotlin.psi.psiUtil.endOffset
import org.jetbrains.kotlin.psi.psiUtil.startOffset
import kotlin.math.min
class KotlinCatchParameterFixer : SmartEnterProcessorWithFixers.Fixer<KotlinSmartEnterHandler>() {
override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, psiElement: PsiElement) {
@@ -33,7 +34,7 @@ class KotlinCatchParameterFixer : SmartEnterProcessorWithFixers.Fixer<KotlinSmar
val parameterList = psiElement.parameterList
if (parameterList == null || parameterList.node.findChildByType(KtTokens.RPAR) == null) {
val endOffset = Math.min(psiElement.endOffset, psiElement.catchBody?.startOffset ?: Int.MAX_VALUE)
val endOffset = min(psiElement.endOffset, psiElement.catchBody?.startOffset ?: Int.MAX_VALUE)
val parameter = parameterList?.parameters?.firstOrNull()?.text ?: ""
editor.document.replaceString(catchEnd, endOffset, "($parameter)")
processor.registerUnresolvedError(endOffset - 1)
@@ -21,6 +21,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.idea.editor.KotlinSmartEnterHandler
import org.jetbrains.kotlin.psi.KtNamedFunction
import kotlin.math.max
class KotlinFunctionParametersFixer : SmartEnterProcessorWithFixers.Fixer<KotlinSmartEnterHandler>() {
@@ -32,7 +33,7 @@ class KotlinFunctionParametersFixer : SmartEnterProcessorWithFixers.Fixer<Kotlin
val identifier = psiElement.nameIdentifier ?: return
// Insert () after name or after type parameters list when it placed after name
val offset = Math.max(identifier.range.end, psiElement.typeParameterList?.range?.end ?: psiElement.range.start)
val offset = max(identifier.range.end, psiElement.typeParameterList?.range?.end ?: psiElement.range.start)
editor.document.insertString(offset, "()")
processor.registerUnresolvedError(offset + 1)
} else {
@@ -20,6 +20,7 @@ import com.intellij.lang.SmartEnterProcessorWithFixers
import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.idea.editor.KotlinSmartEnterHandler
import kotlin.math.min
abstract class MissingConditionFixer<T : PsiElement> : SmartEnterProcessorWithFixers.Fixer<KotlinSmartEnterHandler>() {
override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, element: PsiElement) {
@@ -35,10 +36,10 @@ abstract class MissingConditionFixer<T : PsiElement> : SmartEnterProcessorWithFi
var stopOffset = doc.getLineEndOffset(doc.getLineNumber(workElement.range.start))
val then = getBody(workElement)
if (then != null) {
stopOffset = Math.min(stopOffset, then.range.start)
stopOffset = min(stopOffset, then.range.start)
}
stopOffset = Math.min(stopOffset, workElement.range.end)
stopOffset = min(stopOffset, workElement.range.end)
doc.replaceString(workElement.range.start, stopOffset, "$keyword ()")
processor.registerUnresolvedError(workElement.range.start + "$keyword (".length)
@@ -30,6 +30,7 @@ import javax.swing.*
import javax.swing.table.AbstractTableModel
import javax.swing.table.TableCellEditor
import javax.swing.table.TableCellRenderer
import kotlin.math.max
class KotlinFacetCompilerPluginsTab(
private val configuration: KotlinFacetConfiguration,
@@ -154,7 +155,7 @@ class KotlinFacetCompilerPluginsTab(
val component = super.prepareRenderer(renderer, row, column)
val rendererWidth = component.preferredSize.width
with(getColumnModel().getColumn(column)) {
preferredWidth = Math.max(rendererWidth + intercellSpacing.width, preferredWidth)
preferredWidth = max(rendererWidth + intercellSpacing.width, preferredWidth)
}
return component
}
@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
import org.jetbrains.kotlin.utils.ifEmpty
import java.util.*
import kotlin.math.min
object RenameUnresolvedReferenceActionFactory : KotlinSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
@@ -134,7 +135,7 @@ class RenameUnresolvedReferenceFix(element: KtNameReferenceExpression): KotlinQu
private class HammingComparator<T>(private val referenceString: String, private val asString: T.() -> String) : Comparator<T> {
private fun countDifference(s1: String): Int {
return (0..Math.min(s1.lastIndex, referenceString.lastIndex)).count { s1[it] != referenceString[it] }
return (0..min(s1.lastIndex, referenceString.lastIndex)).count { s1[it] != referenceString[it] }
}
override fun compare(lookupItem1: T, lookupItem2: T): Int {
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.isUnsignedNumberType
import kotlin.math.floor
private val valueRanges = mapOf(
KotlinBuiltIns.FQ_NAMES._byte to Byte.MIN_VALUE.toLong()..Byte.MAX_VALUE.toLong(),
@@ -85,7 +86,7 @@ class WrongPrimitiveLiteralFix(element: KtConstantExpression, type: KotlinType)
if (constValue is Float || constValue is Double) {
val value = constValue.toDouble()
if (value != Math.floor(value)) return false
if (value != floor(value)) return false
if (value !in Long.MIN_VALUE.toDouble()..Long.MAX_VALUE.toDouble()) return false
}
@@ -79,6 +79,7 @@ import org.jetbrains.kotlin.types.typeUtil.isAnyOrNullableAny
import org.jetbrains.kotlin.types.typeUtil.isUnit
import org.jetbrains.kotlin.types.typeUtil.makeNullable
import java.util.*
import kotlin.math.max
/**
* Represents a single choice for a type (e.g. parameter type or return type).
@@ -1062,7 +1063,7 @@ internal fun <D : KtNamedDeclaration> placeDeclarationInContainer(
else -> 1
}
return Math.max(lineBreaksNeeded - lineBreaksPresent, 0)
return max(lineBreaksNeeded - lineBreaksPresent, 0)
}
val actualContainer = (container as? KtClassOrObject)?.getOrCreateBody() ?: container
@@ -98,7 +98,7 @@ object CreateClassFromReferenceExpressionActionFactory : CreateClassFromUsageFac
val targetParents = getTargetParentsByCall(call, context).ifEmpty { return emptyList() }
if (isInnerClassExpected(call)) return Collections.emptyList()
val allKinds = Arrays.asList(ClassKind.OBJECT, ClassKind.ENUM_ENTRY)
val allKinds = listOf(ClassKind.OBJECT, ClassKind.ENUM_ENTRY)
val expectedType = fullCallExpr.guessTypeForClass(context, moduleDescriptor)
@@ -49,6 +49,7 @@ import java.awt.Font
import javax.swing.JComponent
import javax.swing.JLabel
import javax.swing.JPanel
import kotlin.math.max
// Based on com.intellij.refactoring.copy.CopyClassDialog
class CopyKotlinDeclarationDialog(
@@ -97,7 +98,7 @@ class CopyKotlinDeclarationDialog(
override fun createNorthPanel(): JComponent? {
val qualifiedName = qualifiedName
packageNameField = PackageNameReferenceEditorCombo(qualifiedName, project, RECENTS_KEY, RefactoringBundle.message("choose.destination.package"))
packageNameField.setTextFieldPreferredWidth(Math.max(qualifiedName.length + 5, 40))
packageNameField.setTextFieldPreferredWidth(max(qualifiedName.length + 5, 40))
packageLabel.text = RefactoringBundle.message("destination.package")
packageLabel.labelFor = packageNameField
@@ -42,6 +42,7 @@ import java.util.*
import javax.swing.DefaultListCellRenderer
import javax.swing.DefaultListModel
import javax.swing.JList
import kotlin.math.min
@Throws(IntroduceRefactoringException::class)
fun selectElement(
@@ -237,7 +238,7 @@ private fun smartSelectElement(
fun getExpressionShortText(element: KtElement): String {
val text = element.renderTrimmed()
val firstNewLinePos = text.indexOf('\n')
var trimmedText = text.substring(0, if (firstNewLinePos != -1) firstNewLinePos else Math.min(100, text.length))
var trimmedText = text.substring(0, if (firstNewLinePos != -1) firstNewLinePos else min(100, text.length))
if (trimmedText.length != text.length) trimmedText += " ..."
return trimmedText
}
@@ -74,6 +74,7 @@ import org.jetbrains.kotlin.utils.addIfNotNull
import org.jetbrains.kotlin.utils.ifEmpty
import org.jetbrains.kotlin.utils.sure
import java.util.*
import kotlin.math.min
object KotlinIntroduceVariableHandler : RefactoringActionHandler {
val INTRODUCE_VARIABLE = KotlinRefactoringBundle.message("introduce.variable")
@@ -331,7 +332,7 @@ object KotlinIntroduceVariableHandler : RefactoringActionHandler {
private fun calculateAnchor(commonParent: PsiElement, commonContainer: PsiElement, allReplaces: List<KtExpression>): PsiElement? {
if (commonParent != commonContainer) return commonParent.parentsWithSelf.firstOrNull { it.parent == commonContainer }
val startOffset = allReplaces.fold(commonContainer.endOffset) { offset, expr -> Math.min(offset, expr.substringContextOrThis.startOffset) }
val startOffset = allReplaces.fold(commonContainer.endOffset) { offset, expr -> min(offset, expr.substringContextOrThis.startOffset) }
return commonContainer.allChildren.lastOrNull { it.textRange.contains(startOffset) } ?: return null
}
@@ -30,6 +30,8 @@ import java.awt.event.ActionEvent
import java.awt.event.KeyEvent
import javax.swing.*
import javax.swing.table.AbstractTableModel
import kotlin.math.max
import kotlin.math.min
abstract class AbstractParameterTablePanel<Param, UIParam : AbstractParameterTablePanel.AbstractParameterInfo<Param>> : JPanel(BorderLayout()) {
companion object {
@@ -165,7 +167,7 @@ abstract class AbstractParameterTablePanel<Param, UIParam : AbstractParameterTab
parameterInfos[oldIndex] = parameterInfos[newIndex]
parameterInfos[newIndex] = old
fireTableRowsUpdated(Math.min(oldIndex, newIndex), Math.max(oldIndex, newIndex))
fireTableRowsUpdated(min(oldIndex, newIndex), max(oldIndex, newIndex))
updateSignature()
}
@@ -100,6 +100,7 @@ import java.io.File
import java.lang.annotation.Retention
import java.util.*
import javax.swing.Icon
import kotlin.math.min
const val CHECK_SUPER_METHODS_YES_NO_DIALOG = "CHECK_SUPER_METHODS_YES_NO_DIALOG"
@@ -776,7 +777,7 @@ fun <ListType : KtElement> replaceListPsiAndKeepDelimiters(
val oldCount = oldParameters.size
val newCount = newParameters.size
val commonCount = Math.min(oldCount, newCount)
val commonCount = min(oldCount, newCount)
for (i in 0 until commonCount) {
oldParameters[i] = oldParameters[i].replace(newParameters[i]) as KtElement
}
@@ -92,7 +92,7 @@ enum class LibraryJarDescriptor(
RUNTIME_JAR(PathUtil.KOTLIN_JAVA_STDLIB_JAR, OrderRootType.CLASSES, true, { it.stdlibPath }) {
override fun findExistingJar(library: Library): VirtualFile? {
if (isExternalLibrary(library)) return null
return JavaRuntimeDetectionUtil.getRuntimeJar(Arrays.asList(*library.getFiles(OrderRootType.CLASSES)))
return JavaRuntimeDetectionUtil.getRuntimeJar(listOf(*library.getFiles(OrderRootType.CLASSES)))
}
},
@@ -132,7 +132,7 @@ enum class LibraryJarDescriptor(
open fun findExistingJar(library: Library): VirtualFile? {
if (isExternalLibrary(library)) return null
return LibraryUtils.getJarFile(Arrays.asList(*library.getFiles(orderRootType)), jarName)
return LibraryUtils.getJarFile(listOf(*library.getFiles(orderRootType)), jarName)
}
fun getPathInPlugin() = getPath(PathUtil.kotlinPathsForIdeaPlugin)
@@ -16,6 +16,7 @@ import com.intellij.openapi.util.text.StringUtilRt
import com.intellij.openapi.vfs.CharsetToolkit
import org.junit.Assert
import java.io.File
import kotlin.math.min
internal class KotlinOutputChecker(
private val testDir: String,
@@ -79,7 +80,7 @@ internal class KotlinOutputChecker(
println("actual:")
println(actual)
val len = Math.min(expected.length, actual.length)
val len = min(expected.length, actual.length)
if (expected.length != actual.length) {
println("Text sizes differ: expected " + expected.length + " but actual: " + actual.length)
}
@@ -67,7 +67,7 @@ abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() {
val outputDir = createTempDir(dirName)
if (javaFiles.isNotEmpty()) {
val options = Arrays.asList("-d", outputDir.path)
val options = listOf("-d", outputDir.path)
KotlinTestUtils.compileJavaFiles(javaFiles, options)
}