mirror of
https://github.com/chylex/IntelliJ-AceJump.git
synced 2025-04-09 17:15:43 +02:00
routine maintenance and refactoring
This commit is contained in:
parent
4c8ee2a03b
commit
f6a79f7063
gradle/wrapper
src
main
kotlin/org/acejump
resources
test/kotlin
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-5.7-20190721220031+0000-bin.zip
|
@ -6,7 +6,6 @@ import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.actionSystem.*
|
||||
import com.intellij.openapi.editor.colors.EditorColors
|
||||
import com.intellij.openapi.editor.colors.EditorColors.*
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager
|
||||
import org.acejump.control.Scroller.restoreScroll
|
||||
@ -15,7 +14,6 @@ import org.acejump.label.Pattern
|
||||
import org.acejump.label.Pattern.*
|
||||
import org.acejump.label.Tagger
|
||||
import org.acejump.search.*
|
||||
import org.acejump.search.Finder.search
|
||||
import org.acejump.view.*
|
||||
import org.acejump.view.Boundary.FULL_FILE_BOUNDARY
|
||||
import org.acejump.view.Canvas.bindCanvas
|
||||
@ -52,7 +50,7 @@ object Handler : TypedActionHandler, Resettable {
|
||||
}
|
||||
|
||||
fun regexSearch(regex: Pattern, bounds: Boundary = FULL_FILE_BOUNDARY) =
|
||||
Canvas.reset().also { search(regex, bounds) }
|
||||
Canvas.reset().also { Finder.search(regex, bounds) }
|
||||
|
||||
fun activate() = if (!enabled) configureEditor() else {
|
||||
}
|
||||
|
@ -27,12 +27,12 @@ enum class Pattern(val string: String) {
|
||||
val NUM_TAGS: Int
|
||||
get() = NUM_CHARS * NUM_CHARS
|
||||
|
||||
var NUM_CHARS: Int = 36
|
||||
val NUM_CHARS: Int
|
||||
get() = AceConfig.settings.allowedChars.length
|
||||
|
||||
val defaultTagOrder: Comparator<String> = compareBy(
|
||||
{ it[0].isDigit() || it[1].isDigit() },
|
||||
{ Pattern.distance(it[0], it.last()) },
|
||||
{ distance(it[0], it.last()) },
|
||||
AceConfig.settings.layout.priority { it[0] })
|
||||
|
||||
fun filterTags(query: String) = allBigrams.filter { !query.endsWith(it[0]) }
|
||||
|
@ -9,7 +9,7 @@ import org.acejump.view.Marker
|
||||
import org.acejump.view.Model.editor
|
||||
import org.acejump.view.Model.editorText
|
||||
import org.acejump.view.Model.viewBounds
|
||||
import java.util.SortedSet
|
||||
import java.util.*
|
||||
import kotlin.collections.HashMap
|
||||
import kotlin.collections.component1
|
||||
import kotlin.collections.component2
|
||||
@ -41,7 +41,7 @@ object Tagger : Resettable {
|
||||
var query = ""
|
||||
private set
|
||||
var full = false // Tracks whether all search results were successfully tagged
|
||||
var textMatches: SortedSet<Int> = sortedSetOf<Int>()
|
||||
var textMatches: SortedSet<Int> = sortedSetOf()
|
||||
private var tagMap: Map<String, Int> = emptyMap()
|
||||
private val logger = Logger.getInstance(Tagger::class.java)
|
||||
|
||||
|
@ -88,7 +88,7 @@ fun defaultEditor(): Editor =
|
||||
fun Editor.getPoint(idx: Int) = visualPositionToXY(offsetToVisualPosition(idx))
|
||||
|
||||
fun Editor.getPointRelative(index: Int, relativeToComponent: JComponent) =
|
||||
RelativePoint(relativeToComponent, getPoint(index)).originalPoint!!
|
||||
RelativePoint(relativeToComponent, getPoint(index)).originalPoint
|
||||
|
||||
fun Editor.isFirstCharacterOfLine(index: Int) =
|
||||
index == getLineStartOffset(offsetToLogicalPosition(index).line)
|
||||
|
@ -90,4 +90,4 @@ object Jumper: Resettable {
|
||||
}
|
||||
|
||||
override fun reset() = JumpMode.reset()
|
||||
}
|
||||
}
|
@ -35,11 +35,11 @@ object Canvas: JComponent(), Resettable {
|
||||
reset()
|
||||
storeBounds()
|
||||
contentComponent.add(Canvas)
|
||||
Canvas.setBounds(0, 0, contentComponent.width, contentComponent.height)
|
||||
setBounds(0, 0, contentComponent.width, contentComponent.height)
|
||||
|
||||
if (ApplicationInfo.getInstance().build.components.first() < 173) {
|
||||
val loc = convertPoint(Canvas, location, component.rootPane)
|
||||
Canvas.setLocation(-loc.x, -loc.y)
|
||||
setLocation(-loc.x, -loc.y)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ tagCharsToBeUsedLabel=Allowed characters:
|
||||
colorsToBeUsedHeading=Colors to be used when tagging
|
||||
jumpModeColorLabel=Jump mode color:
|
||||
tagBackgroundColorLabel=Tag background color:
|
||||
defaultCharacters=abcdefghijklmnopqrstuvwxyz1234567890
|
||||
tagForegroundColorLabel=Tag foreground color:
|
||||
targetModeColorLabel=Target mode color:
|
||||
textHighlightColorLabel=Text highlight color:
|
||||
|
@ -1,6 +1,6 @@
|
||||
import com.intellij.openapi.actionSystem.IdeActions.*
|
||||
import com.intellij.openapi.fileTypes.PlainTextFileType
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import com.intellij.testFramework.fixtures.BasePlatformTestCase
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import org.acejump.control.AceAction
|
||||
import org.acejump.view.Canvas
|
||||
@ -12,7 +12,7 @@ import kotlin.system.measureTimeMillis
|
||||
* TODO: Add more structure to test cases, use test resources to define files.
|
||||
*/
|
||||
|
||||
class AceTest : LightCodeInsightFixtureTestCase() {
|
||||
class AceTest : BasePlatformTestCase() {
|
||||
fun `test that scanner finds all occurrences of single character`() =
|
||||
assertEquals("test test test".search("t"), setOf(0, 3, 5, 8, 10, 13))
|
||||
|
||||
@ -86,7 +86,7 @@ class AceTest : LightCodeInsightFixtureTestCase() {
|
||||
private fun String.assertCorrectNumberOfTags(query: String) =
|
||||
assertEquals(split(query.fold("") { prefix, char ->
|
||||
if ((prefix + char) in this) prefix + char else return
|
||||
}).size - 1, editor.markupModel.allHighlighters.size)
|
||||
}).size - 1, myFixture.editor.markupModel.allHighlighters.size)
|
||||
|
||||
private var shouldWarmup = true
|
||||
// Should be run exactly once to warm up the JVM
|
||||
@ -112,7 +112,7 @@ class AceTest : LightCodeInsightFixtureTestCase() {
|
||||
override fun tearDown() {
|
||||
myFixture.performEditorAction(ACTION_EDITOR_ESCAPE)
|
||||
UIUtil.dispatchAllInvocationEvents()
|
||||
assertEmpty(editor.markupModel.allHighlighters)
|
||||
assertEmpty(myFixture.editor.markupModel.allHighlighters)
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user