KT-7848 -- unmerged changes (#1075)
* KT-7848 Initial implementation of literal copy/paste processor for Kotlin * KT-7848: Tests * KT-7848: fix issues caught in unit tests with recognizing invalid template entries * KT-7848: check for KtFile * KT-7848: fix capitalization for test data file names * KT-7848: Initial changes according as per review * KT-7848: TemplateTokenSequence tests * KT-7848: fix off by one error caught in test * KT-7848: Reformat with keep empty lines in code -> 0
This commit is contained in:
committed by
Dmitry Jemerov
parent
99b1bb98dc
commit
4393e2d518
@@ -26,6 +26,7 @@ import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.idea.editor.fixers.range
|
||||
import org.jetbrains.kotlin.lexer.KotlinLexer
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -198,7 +199,7 @@ private class TemplateTokenSequence(private val inputString: String) : Sequence<
|
||||
else if (lexer.tokenType == KtTokens.LONG_TEMPLATE_ENTRY_END) {
|
||||
depth--
|
||||
if (depth == 0) {
|
||||
return from + lexer.currentPosition.offset - 1
|
||||
return from + lexer.currentPosition.offset
|
||||
}
|
||||
}
|
||||
lexer.advance()
|
||||
@@ -261,3 +262,14 @@ private class TemplateTokenSequence(private val inputString: String) : Sequence<
|
||||
override fun iterator(): Iterator<TemplateChunk> = iterTemplateChunks()
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
internal fun createTemplateSequenceTokenString(input:String):String{
|
||||
return TemplateTokenSequence(input).map {
|
||||
when (it){
|
||||
is LiteralChunk -> "LITERAL_CHUNK(${it.text})"
|
||||
is EntryChunk -> "ENTRY_CHUNK(${it.text})"
|
||||
is NewLineChunk -> "NEW_LINE()"
|
||||
}
|
||||
}.joinToString (separator = "")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user