diff --git a/src/main/kotlin/com/github/lppedd/cc/CCExtensions.kt b/src/main/kotlin/com/github/lppedd/cc/CCExtensions.kt index 714306ab..8209ea56 100644 --- a/src/main/kotlin/com/github/lppedd/cc/CCExtensions.kt +++ b/src/main/kotlin/com/github/lppedd/cc/CCExtensions.kt @@ -1,5 +1,6 @@ package com.github.lppedd.cc +import com.github.lppedd.cc.annotation.RequireEDT import com.intellij.codeInsight.AutoPopupController import com.intellij.codeInsight.completion.CompletionParameters import com.intellij.codeInsight.lookup.impl.LookupImpl @@ -82,11 +83,13 @@ internal inline fun Editor.insertStringAtCaret(string: String) { internal inline fun Editor.getTemplateState(): TemplateState? = TemplateManagerImpl.getTemplateState(this) +@RequireEDT internal fun Editor.getCurrentLineRange(): TextRange { val mainCaretLine = EditorUtil.calcCaretLineRange(this).first.line return document.getLineRange(mainCaretLine) } +@RequireEDT internal fun Editor.getCurrentLine(): CharSequence { val (start, end) = getCurrentLineRange() return document.immutableCharSequence.subSequence(start, end) diff --git a/src/main/kotlin/com/github/lppedd/cc/annotation/RequireEDT.kt b/src/main/kotlin/com/github/lppedd/cc/annotation/RequireEDT.kt new file mode 100644 index 00000000..36fa9192 --- /dev/null +++ b/src/main/kotlin/com/github/lppedd/cc/annotation/RequireEDT.kt @@ -0,0 +1,9 @@ +package com.github.lppedd.cc.annotation + +/** + * @author Edoardo Luppi + */ +@Target(AnnotationTarget.FUNCTION) +@Retention(AnnotationRetention.BINARY) +@MustBeDocumented +annotation class RequireEDT