Skip to content

Commit

Permalink
routine maintenance and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
breandan committed Jul 23, 2019
1 parent 4c8ee2a commit f6a79f7
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions src/main/kotlin/org/acejump/control/Handler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/acejump/label/Pattern.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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]) }
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/acejump/label/Tagger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/acejump/search/AceUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/acejump/search/Jumper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ object Jumper: Resettable {
}

override fun reset() = JumpMode.reset()
}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/org/acejump/view/Canvas.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
1 change: 0 additions & 1 deletion src/main/resources/AceResources.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions src/test/kotlin/AceTest.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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))

Expand Down Expand Up @@ -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
Expand All @@ -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()
}

Expand Down

0 comments on commit f6a79f7

Please sign in to comment.