Compiler&plugin deprecations cleanup: length, size, indices, tail and other collection operations.
This commit is contained in:
+2
-2
@@ -38,8 +38,8 @@ class ToFromOriginalFileMapper(
|
||||
val syntheticText = syntheticFile.getText()
|
||||
assert(originalText.subSequence(0, completionOffset) == syntheticText.subSequence(0, completionOffset)) //TODO: drop it
|
||||
|
||||
syntheticLength = syntheticText.length
|
||||
originalLength = originalText.length
|
||||
syntheticLength = syntheticText.length()
|
||||
originalLength = originalText.length()
|
||||
val minLength = Math.min(originalLength, syntheticLength)
|
||||
tailLength = (0..minLength-1).firstOrNull {
|
||||
syntheticText[syntheticLength - it - 1] != originalText[originalLength - it - 1]
|
||||
|
||||
+3
-3
@@ -54,14 +54,14 @@ class WithTailInsertHandler(val tailText: String,
|
||||
|
||||
if (overwriteText) {
|
||||
fun isCharAt(offset: Int, c: Char) = offset < document.getTextLength() && document.getCharsSequence().charAt(offset) == c
|
||||
fun isTextAt(offset: Int, text: String) = offset + text.length <= document.getTextLength() && document.getText(TextRange(offset, offset + text.length)) == text
|
||||
fun isTextAt(offset: Int, text: String) = offset + text.length() <= document.getTextLength() && document.getText(TextRange(offset, offset + text.length())) == text
|
||||
|
||||
if (spaceBefore && isCharAt(tailOffset, ' ')) {
|
||||
document.deleteString(tailOffset, tailOffset + 1)
|
||||
}
|
||||
|
||||
if (isTextAt(tailOffset, tailText)) {
|
||||
document.deleteString(tailOffset, tailOffset + tailText.length)
|
||||
document.deleteString(tailOffset, tailOffset + tailText.length())
|
||||
|
||||
if (spaceAfter && isCharAt(tailOffset, ' ')) {
|
||||
document.deleteString(tailOffset, tailOffset + 1)
|
||||
@@ -77,7 +77,7 @@ class WithTailInsertHandler(val tailText: String,
|
||||
document.insertString(tailOffset, textToInsert)
|
||||
|
||||
if (moveCaret) {
|
||||
context.getEditor().getCaretModel().moveToOffset(tailOffset + textToInsert.length)
|
||||
context.getEditor().getCaretModel().moveToOffset(tailOffset + textToInsert.length())
|
||||
|
||||
if (tailText == ",") {
|
||||
AutoPopupController.getInstance(context.getProject())?.autoPopupParameterInfo(context.getEditor(), null)
|
||||
|
||||
+3
-3
@@ -50,10 +50,10 @@ 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 = Math.min(nonNumberWords1.size(), nonNumberWords2.size())
|
||||
val matchedTailLength = (0..minWords-1).firstOrNull {
|
||||
i -> nonNumberWords1[nonNumberWords1.size - i - 1] != nonNumberWords2[nonNumberWords2.size - i - 1]
|
||||
i -> nonNumberWords1[nonNumberWords1.size() - i - 1] != nonNumberWords2[nonNumberWords2.size() - i - 1]
|
||||
} ?: minWords
|
||||
|
||||
return matchedWords.size * 1000 + matchedTailLength
|
||||
return matchedWords.size() * 1000 + matchedTailLength
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user