1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-13 21:34:06 +02:00

Remove unnecessary libraries from the distribution

This commit is contained in:
Alex Plate 2022-07-08 10:29:51 +03:00
parent aa6f49c9b1
commit d3c3b71e3e
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
5 changed files with 41 additions and 38 deletions
config/ktlint
vim-engine
build.gradle.kts
src/main/kotlin/com/maddyhome/idea/vim

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<baseline version="1.0">
<file name="src/main/java/com/maddyhome/idea/vim/listener/RiderSpecifics.kt">
<error line="1" column="1" source="filename" />
</file>
</baseline>

View File

@ -12,11 +12,6 @@ repositories {
}
dependencies {
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
implementation("org.apache.commons:commons-lang3:3.12.0")
// https://mvnrepository.com/artifact/com.google.guava/guava
implementation("com.google.guava:guava:11.0.2")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21")

View File

@ -17,8 +17,6 @@
*/
package com.maddyhome.idea.vim.key
import com.google.common.collect.HashMultiset
import com.google.common.collect.Multiset
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.extension.ExtensionHandler
import com.maddyhome.idea.vim.vimscript.model.expressions.Expression
@ -43,7 +41,7 @@ class KeyMapping : Iterable<List<KeyStroke?>?>, KeyMappingLayer {
* E.g. if there is mapping for "hello", this set will contain "h", "he", "hel", etc.
* Multiset is used to correctly remove the mappings.
*/
private val myPrefixes: Multiset<List<KeyStroke>> = HashMultiset.create()
private val myPrefixes: MutableMap<List<KeyStroke>, Int> = HashMap()
override fun iterator(): MutableIterator<List<KeyStroke>> {
return ArrayList(myKeys.keys).iterator()
}
@ -104,7 +102,7 @@ class KeyMapping : Iterable<List<KeyStroke?>?>, KeyMappingLayer {
val prefixLength = fromKeys.size - 1
for (i in 0 until prefixLength) {
prefix.add(fromKeys[i])
myPrefixes.add(ArrayList(prefix))
myPrefixes[ArrayList(prefix)] = (myPrefixes[ArrayList(prefix)] ?: 0) + 1
}
}
@ -137,7 +135,12 @@ class KeyMapping : Iterable<List<KeyStroke?>?>, KeyMappingLayer {
val prefixLength = keys.size - 1
for (i in 0 until prefixLength) {
prefix.add(keys[i])
myPrefixes.remove(prefix)
val existingCount = myPrefixes[prefix]
if (existingCount == 1 || existingCount == null) {
myPrefixes.remove(prefix)
} else {
myPrefixes[prefix] = existingCount - 1
}
}
}

View File

@ -17,7 +17,6 @@
*/
package com.maddyhome.idea.vim.key
import com.google.common.collect.HashMultimap
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.command.VimStateMachine
import com.maddyhome.idea.vim.helper.mode
@ -33,36 +32,40 @@ sealed class ShortcutOwnerInfo {
val select: ShortcutOwner,
) : ShortcutOwnerInfo() {
fun toNotation(): String {
val owners = HashMultimap.create<ShortcutOwner, String>()
owners.put(normal, "n")
owners.put(insert, "i")
owners.put(visual, "x")
owners.put(select, "s")
val owners = HashMap<ShortcutOwner, MutableList<String>>()
owners.put(normal, mutableListOf("n"))
owners.put(insert, mutableListOf("i"))
owners.put(visual, mutableListOf("x"))
owners.put(select, mutableListOf("s"))
if ("x" in owners[ShortcutOwner.VIM] && "s" in owners[ShortcutOwner.VIM]) {
owners.remove(ShortcutOwner.VIM, "x")
owners.remove(ShortcutOwner.VIM, "s")
owners.put(ShortcutOwner.VIM, "v")
if ("x" in (owners[ShortcutOwner.VIM] ?: emptyList()) && "s" in (owners[ShortcutOwner.VIM] ?: emptyList())) {
val existing = owners[ShortcutOwner.VIM] ?: mutableListOf()
existing.remove("x")
existing.remove("s")
existing.add("v")
owners[ShortcutOwner.VIM] = existing
}
if ("x" in owners[ShortcutOwner.IDE] && "s" in owners[ShortcutOwner.IDE]) {
owners.remove(ShortcutOwner.IDE, "x")
owners.remove(ShortcutOwner.IDE, "s")
owners.put(ShortcutOwner.IDE, "v")
if ("x" in (owners[ShortcutOwner.IDE] ?: emptyList()) && "s" in (owners[ShortcutOwner.IDE] ?: emptyList())) {
val existing = owners[ShortcutOwner.IDE] ?: mutableListOf()
existing.remove("x")
existing.remove("s")
existing.add("v")
owners[ShortcutOwner.IDE] = existing
}
if (owners[ShortcutOwner.IDE].isEmpty()) {
owners.removeAll(ShortcutOwner.VIM)
owners.put(ShortcutOwner.VIM, "a")
if ((owners[ShortcutOwner.IDE] ?: emptyList()).isEmpty()) {
owners.remove(ShortcutOwner.VIM)
owners[ShortcutOwner.VIM] = mutableListOf("a")
}
if (owners[ShortcutOwner.VIM].isEmpty()) {
owners.removeAll(ShortcutOwner.IDE)
owners.put(ShortcutOwner.IDE, "a")
if ((owners[ShortcutOwner.VIM] ?: emptyList()).isEmpty()) {
owners.remove(ShortcutOwner.IDE)
owners[ShortcutOwner.IDE] = mutableListOf("a")
}
val ideOwners = owners[ShortcutOwner.IDE].sortedBy { wights[it] ?: 1000 }.joinToString(separator = "-")
val vimOwners = owners[ShortcutOwner.VIM].sortedBy { wights[it] ?: 1000 }.joinToString(separator = "-")
val ideOwners = (owners[ShortcutOwner.IDE] ?: emptyList()).sortedBy { wights[it] ?: 1000 }.joinToString(separator = "-")
val vimOwners = (owners[ShortcutOwner.VIM] ?: emptyList()).sortedBy { wights[it] ?: 1000 }.joinToString(separator = "-")
return if (ideOwners.isNotEmpty() && vimOwners.isNotEmpty()) {
ideOwners + ":" + ShortcutOwner.IDE.ownerName + " " + vimOwners + ":" + ShortcutOwner.VIM.ownerName

View File

@ -24,7 +24,6 @@ import com.maddyhome.idea.vim.options.OptionConstants
import com.maddyhome.idea.vim.options.OptionScope
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
import org.apache.commons.lang3.math.NumberUtils
import java.util.regex.Pattern
object KeywordOptionHelper {
@ -169,11 +168,8 @@ object KeywordOptionHelper {
}
private fun toUnicode(str: String): Int {
return if (NumberUtils.isNumber(str)) {
str.toInt() // If we have a number, it represents the Unicode code point of a letter
} else {
str[0].code // If it's not a number we should only have strings consisting of one char
}
return str.toIntOrNull() // If we have a number, it represents the Unicode code point of a letter
?: str[0].code // If it's not a number we should only have strings consisting of one char
}
override fun equals(other: Any?): Boolean {