@@ -2,10 +2,7 @@ package com.github.lppedd.cc.liveTemplate
22
33import com.github.lppedd.cc.*
44import com.github.lppedd.cc.annotation.Compatibility
5- import com.github.lppedd.cc.lookupElement.INDEX_BODY_OR_FOOTER_TYPE
6- import com.github.lppedd.cc.lookupElement.INDEX_FOOTER_VALUE
7- import com.github.lppedd.cc.lookupElement.INDEX_SCOPE
8- import com.github.lppedd.cc.lookupElement.INDEX_SUBJECT
5+ import com.github.lppedd.cc.lookupElement.TemplateSegment
96import com.intellij.codeInsight.template.Template
107import com.intellij.codeInsight.template.TemplateEditingAdapter
118import com.intellij.codeInsight.template.impl.TemplateState
@@ -44,8 +41,8 @@ internal class CCTemplateEditingListener : TemplateEditingAdapter() {
4441 return
4542 }
4643
47- if (oldIndex == INDEX_BODY_OR_FOOTER_TYPE && newIndex > oldIndex) {
48- if (templateState.getSegmentRange(INDEX_BODY_OR_FOOTER_TYPE ).isEmpty) {
44+ if (oldIndex == TemplateSegment . BodyOrFooterType && newIndex > oldIndex) {
45+ if (templateState.getSegmentRange(TemplateSegment . BodyOrFooterType ).isEmpty) {
4946 deleteFooterValue(templateState)
5047 templateState.gotoEnd()
5148 return
@@ -59,7 +56,7 @@ internal class CCTemplateEditingListener : TemplateEditingAdapter() {
5956 }
6057
6158 override fun beforeTemplateFinished (templateState : TemplateState , template : Template ) {
62- val bodyOrFooterTypeRange = templateState.getSegmentRange(INDEX_BODY_OR_FOOTER_TYPE )
59+ val bodyOrFooterTypeRange = templateState.getSegmentRange(TemplateSegment . BodyOrFooterType )
6360
6461 if (bodyOrFooterTypeRange.isEmpty) {
6562 repositionCursorAfterSubjectAndCleanUp(templateState, bodyOrFooterTypeRange)
@@ -74,7 +71,7 @@ internal class CCTemplateEditingListener : TemplateEditingAdapter() {
7471 ) {
7572 // If the body is empty, it means the user didn't need to insert it.
7673 // Thus, we can reposition the cursor at the end of the subject
77- val newOffset = templateState.getSegmentRange(INDEX_SUBJECT ).endOffset
74+ val newOffset = templateState.getSegmentRange(TemplateSegment . Subject ).endOffset
7875
7976 if (newOffset <= bodyOrFooterTypeRange.endOffset) {
8077 val editor = templateState.editor
@@ -88,7 +85,7 @@ internal class CCTemplateEditingListener : TemplateEditingAdapter() {
8885 }
8986
9087 private fun deleteScopeParenthesesIfEmpty (templateState : TemplateState ) {
91- val (scopeStart, scopeEnd, isScopeEmpty) = templateState.getSegmentRange(INDEX_SCOPE )
88+ val (scopeStart, scopeEnd, isScopeEmpty) = templateState.getSegmentRange(TemplateSegment . Scope )
9289
9390 // If the scope is empty, it means the user didn't need to insert it, thus we can remove it
9491 if (isScopeEmpty) {
@@ -105,7 +102,7 @@ internal class CCTemplateEditingListener : TemplateEditingAdapter() {
105102 }
106103
107104 private fun deleteFooterValue (templateState : TemplateState ) {
108- val (start, end, isEmpty) = templateState.getSegmentRange(INDEX_FOOTER_VALUE )
105+ val (start, end, isEmpty) = templateState.getSegmentRange(TemplateSegment . FooterValue )
109106
110107 if (! isEmpty) {
111108 runWriteAction {
0 commit comments