From 10fdadaa0c7b4cc8f8809d22d0f33e1f2358c870 Mon Sep 17 00:00:00 2001 From: Alex Plate Date: Tue, 15 Oct 2019 11:08:54 +0300 Subject: [PATCH] Mark some functions as externally used --- src/main/kotlin/org/acejump/control/Handler.kt | 4 ++++ src/main/kotlin/org/acejump/search/AceUtil.kt | 11 ++++++++++- src/main/kotlin/org/acejump/search/Finder.kt | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/acejump/control/Handler.kt b/src/main/kotlin/org/acejump/control/Handler.kt index 06aebe8b..0b7e5bff 100755 --- a/src/main/kotlin/org/acejump/control/Handler.kt +++ b/src/main/kotlin/org/acejump/control/Handler.kt @@ -52,9 +52,11 @@ object Handler : TypedActionHandler, Resettable { override fun doExecute(e: Editor, c: Caret?, dc: DataContext?) = handle() } + @ExternalUsage fun regexSearch(regex: Pattern, bounds: Boundary = FULL_FILE_BOUNDARY) = Canvas.reset().also { Finder.search(regex, bounds) } + @ExternalUsage fun customRegexSearch(regex: String, bounds: Boundary = FULL_FILE_BOUNDARY) = Canvas.reset().also { Finder.search(regex, bounds) } @@ -123,10 +125,12 @@ object Handler : TypedActionHandler, Resettable { editor.restoreSettings() } + @ExternalUsage fun addAceJumpListener(listener: AceJumpListener) { listeners += listener } + @ExternalUsage fun removeAceJumpListener(listener: AceJumpListener) { listeners -= listener } diff --git a/src/main/kotlin/org/acejump/search/AceUtil.kt b/src/main/kotlin/org/acejump/search/AceUtil.kt index a44783c4..bacd60a1 100755 --- a/src/main/kotlin/org/acejump/search/AceUtil.kt +++ b/src/main/kotlin/org/acejump/search/AceUtil.kt @@ -275,4 +275,13 @@ fun Editor.normalizeLine(line: Int) = max(0, min(line, getLineCount() - 1)) fun Editor.normalizeOffset(line: Int, offset: Int, allowEnd: Boolean) = if (getFileSize(allowEnd) == 0) 0 else - max(min(offset, getLineEndOffset(line, allowEnd)), getLineStartOffset(line)) \ No newline at end of file + max(min(offset, getLineEndOffset(line, allowEnd)), getLineStartOffset(line)) + +/** + * This annotation is a marker which means that the annotated function is + * used in external plugins. + */ + +@Retention(AnnotationRetention.SOURCE) +@Target(AnnotationTarget.FUNCTION) +annotation class ExternalUsage \ No newline at end of file diff --git a/src/main/kotlin/org/acejump/search/Finder.kt b/src/main/kotlin/org/acejump/search/Finder.kt index 2295732d..075338d4 100644 --- a/src/main/kotlin/org/acejump/search/Finder.kt +++ b/src/main/kotlin/org/acejump/search/Finder.kt @@ -113,6 +113,7 @@ object Finder : Resettable { * AceFindModel should be empty. Additionally, if * AceFindModes.isRegex == true, only one symbol is highlighted in document. */ + @ExternalUsage fun markResults( results: SortedSet, model: AceFindModel = AceFindModel("", true)