KT-32366: Add tests for right preview window
- also, fix missing test generation in `GenerateTests` bunch files (which was introduced in e54b43ba)
This commit is contained in:
committed by
Roman Golyshev
parent
bddf87337c
commit
e488e920d8
@@ -810,6 +810,8 @@ fun main(args: Array<String>) {
|
|||||||
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetCompilingTest", testClassName = "WorksheetCompiling", recursive = false)
|
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetCompilingTest", testClassName = "WorksheetCompiling", recursive = false)
|
||||||
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetReplTest", testClassName = "WorksheetRepl", recursive = false)
|
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetReplTest", testClassName = "WorksheetRepl", recursive = false)
|
||||||
model("worksheet/multiFile", extension = null, testMethod = "doWorksheetMultiFileTest", testClassName = "WorksheetMultiFile", recursive = false)
|
model("worksheet/multiFile", extension = null, testMethod = "doWorksheetMultiFileTest", testClassName = "WorksheetMultiFile", recursive = false)
|
||||||
|
|
||||||
|
model("scratch/rightPanelOutput", extension = "kts", testMethod = "doRightPreviewPanelOutputTest", testClassName = "ScratchRightPanelOutput", recursive = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractScratchLineMarkersTest> {
|
testClass<AbstractScratchLineMarkersTest> {
|
||||||
|
|||||||
@@ -817,9 +817,15 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractScratchRunActionTest> {
|
testClass<AbstractScratchRunActionTest> {
|
||||||
model("scratch", extension = "kts", testMethod = "doCompilingTest", testClassName = "Compiling", recursive = false)
|
model("scratch", extension = "kts", testMethod = "doScratchCompilingTest", testClassName = "ScratchCompiling", recursive = false)
|
||||||
model("scratch", extension = "kts", testMethod = "doReplTest", testClassName = "Repl", recursive = false)
|
model("scratch", extension = "kts", testMethod = "doScratchReplTest", testClassName = "ScratchRepl", recursive = false)
|
||||||
model("scratch/multiFile", extension = null, testMethod = "doMultiFileTest", recursive = false)
|
model("scratch/multiFile", extension = null, testMethod = "doScratchMultiFileTest", testClassName = "ScratchMultiFile", recursive = false)
|
||||||
|
|
||||||
|
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetCompilingTest", testClassName = "WorksheetCompiling", recursive = false)
|
||||||
|
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetReplTest", testClassName = "WorksheetRepl", recursive = false)
|
||||||
|
model("worksheet/multiFile", extension = null, testMethod = "doWorksheetMultiFileTest", testClassName = "WorksheetMultiFile", recursive = false)
|
||||||
|
|
||||||
|
model("scratch/rightPanelOutput", extension = "kts", testMethod = "doRightPreviewPanelOutputTest", testClassName = "ScratchRightPanelOutput", recursive = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractScratchLineMarkersTest> {
|
testClass<AbstractScratchLineMarkersTest> {
|
||||||
|
|||||||
@@ -783,9 +783,15 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractScratchRunActionTest> {
|
testClass<AbstractScratchRunActionTest> {
|
||||||
model("scratch", extension = "kts", testMethod = "doCompilingTest", testClassName = "Compiling", recursive = false)
|
model("scratch", extension = "kts", testMethod = "doScratchCompilingTest", testClassName = "ScratchCompiling", recursive = false)
|
||||||
model("scratch", extension = "kts", testMethod = "doReplTest", testClassName = "Repl", recursive = false)
|
model("scratch", extension = "kts", testMethod = "doScratchReplTest", testClassName = "ScratchRepl", recursive = false)
|
||||||
model("scratch/multiFile", extension = null, testMethod = "doMultiFileTest", recursive = false)
|
model("scratch/multiFile", extension = null, testMethod = "doScratchMultiFileTest", testClassName = "ScratchMultiFile", recursive = false)
|
||||||
|
|
||||||
|
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetCompilingTest", testClassName = "WorksheetCompiling", recursive = false)
|
||||||
|
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetReplTest", testClassName = "WorksheetRepl", recursive = false)
|
||||||
|
model("worksheet/multiFile", extension = null, testMethod = "doWorksheetMultiFileTest", testClassName = "WorksheetMultiFile", recursive = false)
|
||||||
|
|
||||||
|
model("scratch/rightPanelOutput", extension = "kts", testMethod = "doRightPreviewPanelOutputTest", testClassName = "ScratchRightPanelOutput", recursive = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractScratchLineMarkersTest> {
|
testClass<AbstractScratchLineMarkersTest> {
|
||||||
|
|||||||
@@ -787,9 +787,15 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractScratchRunActionTest> {
|
testClass<AbstractScratchRunActionTest> {
|
||||||
model("scratch", extension = "kts", testMethod = "doCompilingTest", testClassName = "Compiling", recursive = false)
|
model("scratch", extension = "kts", testMethod = "doScratchCompilingTest", testClassName = "ScratchCompiling", recursive = false)
|
||||||
model("scratch", extension = "kts", testMethod = "doReplTest", testClassName = "Repl", recursive = false)
|
model("scratch", extension = "kts", testMethod = "doScratchReplTest", testClassName = "ScratchRepl", recursive = false)
|
||||||
model("scratch/multiFile", extension = null, testMethod = "doMultiFileTest", recursive = false)
|
model("scratch/multiFile", extension = null, testMethod = "doScratchMultiFileTest", testClassName = "ScratchMultiFile", recursive = false)
|
||||||
|
|
||||||
|
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetCompilingTest", testClassName = "WorksheetCompiling", recursive = false)
|
||||||
|
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetReplTest", testClassName = "WorksheetRepl", recursive = false)
|
||||||
|
model("worksheet/multiFile", extension = null, testMethod = "doWorksheetMultiFileTest", testClassName = "WorksheetMultiFile", recursive = false)
|
||||||
|
|
||||||
|
model("scratch/rightPanelOutput", extension = "kts", testMethod = "doRightPreviewPanelOutputTest", testClassName = "ScratchRightPanelOutput", recursive = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractScratchLineMarkersTest> {
|
testClass<AbstractScratchLineMarkersTest> {
|
||||||
|
|||||||
@@ -783,9 +783,15 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractScratchRunActionTest> {
|
testClass<AbstractScratchRunActionTest> {
|
||||||
model("scratch", extension = "kts", testMethod = "doCompilingTest", testClassName = "Compiling", recursive = false)
|
model("scratch", extension = "kts", testMethod = "doScratchCompilingTest", testClassName = "ScratchCompiling", recursive = false)
|
||||||
model("scratch", extension = "kts", testMethod = "doReplTest", testClassName = "Repl", recursive = false)
|
model("scratch", extension = "kts", testMethod = "doScratchReplTest", testClassName = "ScratchRepl", recursive = false)
|
||||||
model("scratch/multiFile", extension = null, testMethod = "doMultiFileTest", recursive = false)
|
model("scratch/multiFile", extension = null, testMethod = "doScratchMultiFileTest", testClassName = "ScratchMultiFile", recursive = false)
|
||||||
|
|
||||||
|
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetCompilingTest", testClassName = "WorksheetCompiling", recursive = false)
|
||||||
|
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetReplTest", testClassName = "WorksheetRepl", recursive = false)
|
||||||
|
model("worksheet/multiFile", extension = null, testMethod = "doWorksheetMultiFileTest", testClassName = "WorksheetMultiFile", recursive = false)
|
||||||
|
|
||||||
|
model("scratch/rightPanelOutput", extension = "kts", testMethod = "doRightPreviewPanelOutputTest", testClassName = "ScratchRightPanelOutput", recursive = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractScratchLineMarkersTest> {
|
testClass<AbstractScratchLineMarkersTest> {
|
||||||
|
|||||||
@@ -783,9 +783,15 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractScratchRunActionTest> {
|
testClass<AbstractScratchRunActionTest> {
|
||||||
model("scratch", extension = "kts", testMethod = "doCompilingTest", testClassName = "Compiling", recursive = false)
|
model("scratch", extension = "kts", testMethod = "doScratchCompilingTest", testClassName = "ScratchCompiling", recursive = false)
|
||||||
model("scratch", extension = "kts", testMethod = "doReplTest", testClassName = "Repl", recursive = false)
|
model("scratch", extension = "kts", testMethod = "doScratchReplTest", testClassName = "ScratchRepl", recursive = false)
|
||||||
model("scratch/multiFile", extension = null, testMethod = "doMultiFileTest", recursive = false)
|
model("scratch/multiFile", extension = null, testMethod = "doScratchMultiFileTest", testClassName = "ScratchMultiFile", recursive = false)
|
||||||
|
|
||||||
|
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetCompilingTest", testClassName = "WorksheetCompiling", recursive = false)
|
||||||
|
model("worksheet", extension = "ws.kts", testMethod = "doWorksheetReplTest", testClassName = "WorksheetRepl", recursive = false)
|
||||||
|
model("worksheet/multiFile", extension = null, testMethod = "doWorksheetMultiFileTest", testClassName = "WorksheetMultiFile", recursive = false)
|
||||||
|
|
||||||
|
model("scratch/rightPanelOutput", extension = "kts", testMethod = "doRightPreviewPanelOutputTest", testClassName = "ScratchRightPanelOutput", recursive = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass<AbstractScratchLineMarkersTest> {
|
testClass<AbstractScratchLineMarkersTest> {
|
||||||
|
|||||||
@@ -119,6 +119,9 @@ class KtScratchFileEditorWithPreview private constructor(
|
|||||||
layout = if (isPreviewEnabled) Layout.SHOW_EDITOR_AND_PREVIEW else Layout.SHOW_EDITOR
|
layout = if (isPreviewEnabled) Layout.SHOW_EDITOR_AND_PREVIEW else Layout.SHOW_EDITOR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestOnly
|
||||||
|
fun getPreviewEditor(): TextEditor = previewTextEditor
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun create(scratchFile: ScratchFile): KtScratchFileEditorWithPreview {
|
fun create(scratchFile: ScratchFile): KtScratchFileEditorWithPreview {
|
||||||
val textEditorProvider = TextEditorProvider.getInstance()
|
val textEditorProvider = TextEditorProvider.getInstance()
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
Hello world
|
||||||
|
|
||||||
|
Hello world
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Hello world
|
||||||
|
Hello world
|
||||||
|
Hello world
|
||||||
|
|
||||||
|
Hello world
|
||||||
|
Hello world
|
||||||
|
<fold text='Hello world...'>Hello world
|
||||||
|
Hello world</fold>
|
||||||
|
|
||||||
|
<fold text='Hello world...'>Hello world
|
||||||
|
Hello world
|
||||||
|
Hello world</fold>
|
||||||
|
|
||||||
|
Hello world
|
||||||
|
Hello world
|
||||||
|
Hello world
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// PREVIEW_ENABLED: TRUE
|
||||||
|
println("Hello world")
|
||||||
|
|
||||||
|
for (x in 1..1) {
|
||||||
|
println("Hello world")
|
||||||
|
}
|
||||||
|
|
||||||
|
for (x in 1..3) {
|
||||||
|
println("Hello world")
|
||||||
|
}
|
||||||
|
|
||||||
|
for (x in 1..4) {
|
||||||
|
println("Hello world")
|
||||||
|
}
|
||||||
|
|
||||||
|
println(List(3) { "Hello world" }.joinToString(separator = "\n"))
|
||||||
|
|
||||||
|
println(
|
||||||
|
List(3) { "Hello world" }.joinToString(separator = "\n")
|
||||||
|
)
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
<fold text='First string...'>First string
|
||||||
|
Second string
|
||||||
|
Third string</fold>
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
// PREVIEW_ENABLED: TRUE
|
||||||
|
println("First string\nSecond string\nThird string")
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
Single string
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
// PREVIEW_ENABLED: TRUE
|
||||||
|
println("Single string")
|
||||||
@@ -45,20 +45,24 @@ import java.io.File
|
|||||||
|
|
||||||
abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() {
|
abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() {
|
||||||
|
|
||||||
|
fun doRightPreviewPanelOutputTest(fileName: String) {
|
||||||
|
doRightPreviewPanelOutputTest(fileName = fileName, isRepl = false)
|
||||||
|
}
|
||||||
|
|
||||||
fun doWorksheetReplTest(fileName: String) {
|
fun doWorksheetReplTest(fileName: String) {
|
||||||
doTest(fileName = fileName, isRepl = true, isWorksheet = true)
|
doInlayOutputTest(fileName = fileName, isRepl = true, isWorksheet = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doScratchReplTest(fileName: String) {
|
fun doScratchReplTest(fileName: String) {
|
||||||
doTest(fileName = fileName, isRepl = true, isWorksheet = false)
|
doInlayOutputTest(fileName = fileName, isRepl = true, isWorksheet = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doWorksheetCompilingTest(fileName: String) {
|
fun doWorksheetCompilingTest(fileName: String) {
|
||||||
doTest(fileName = fileName, isRepl = false, isWorksheet = true)
|
doInlayOutputTest(fileName = fileName, isRepl = false, isWorksheet = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doScratchCompilingTest(fileName: String) {
|
fun doScratchCompilingTest(fileName: String) {
|
||||||
doTest(fileName = fileName, isRepl = false, isWorksheet = false)
|
doInlayOutputTest(fileName = fileName, isRepl = false, isWorksheet = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doWorksheetMultiFileTest(dirName: String) {
|
fun doWorksheetMultiFileTest(dirName: String) {
|
||||||
@@ -97,18 +101,36 @@ abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() {
|
|||||||
PsiTestUtil.setCompilerOutputPath(myFixture.module, outputDir.path, false)
|
PsiTestUtil.setCompilerOutputPath(myFixture.module, outputDir.path, false)
|
||||||
|
|
||||||
val mainFileName = "$dirName/${getTestName(true)}.$mainFileExtension"
|
val mainFileName = "$dirName/${getTestName(true)}.$mainFileExtension"
|
||||||
doTest(mainFileName, isRepl = false, isWorksheet = isWorksheet)
|
doInlayOutputTest(mainFileName, isRepl = false, isWorksheet = isWorksheet)
|
||||||
|
|
||||||
launchAction(ClearScratchAction())
|
launchAction(ClearScratchAction())
|
||||||
|
|
||||||
doTest(mainFileName, isRepl = true, isWorksheet = isWorksheet)
|
doInlayOutputTest(mainFileName, isRepl = true, isWorksheet = isWorksheet)
|
||||||
|
|
||||||
ModuleRootModificationUtil.updateModel(myFixture.module) { model ->
|
ModuleRootModificationUtil.updateModel(myFixture.module) { model ->
|
||||||
model.getModuleExtension(CompilerModuleExtension::class.java).inheritCompilerOutputPath(true)
|
model.getModuleExtension(CompilerModuleExtension::class.java).inheritCompilerOutputPath(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doTest(fileName: String, isRepl: Boolean, isWorksheet: Boolean) {
|
private fun doInlayOutputTest(fileName: String, isRepl: Boolean, isWorksheet: Boolean) {
|
||||||
|
configureAndLaunchScratch(fileName = fileName, isRepl = isRepl, isWorksheet = isWorksheet)
|
||||||
|
|
||||||
|
val actualOutput = getFileTextWithInlays()
|
||||||
|
|
||||||
|
val expectedFile = getExpectedFile(fileName, isRepl, suffix = "after")
|
||||||
|
KotlinTestUtils.assertEqualsToFile(expectedFile, actualOutput)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun doRightPreviewPanelOutputTest(fileName: String, isRepl: Boolean) {
|
||||||
|
configureAndLaunchScratch(fileName = fileName, isRepl = isRepl, isWorksheet = false)
|
||||||
|
|
||||||
|
val previewTextWithFoldings = getPreviewTextWithFoldings()
|
||||||
|
|
||||||
|
val expectedFile = getExpectedFile(fileName, isRepl, suffix = "preview")
|
||||||
|
KotlinTestUtils.assertEqualsToFile(expectedFile, previewTextWithFoldings)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun configureAndLaunchScratch(fileName: String, isRepl: Boolean, isWorksheet: Boolean) {
|
||||||
val sourceFile = File(testDataPath, fileName)
|
val sourceFile = File(testDataPath, fileName)
|
||||||
val fileText = sourceFile.readText().inlinePropertiesValues(isRepl)
|
val fileText = sourceFile.readText().inlinePropertiesValues(isRepl)
|
||||||
|
|
||||||
@@ -122,16 +144,16 @@ abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() {
|
|||||||
|
|
||||||
launchScratch()
|
launchScratch()
|
||||||
waitUntilScratchFinishes()
|
waitUntilScratchFinishes()
|
||||||
|
}
|
||||||
|
|
||||||
val actualOutput = getFileTextWithInlays()
|
private fun getExpectedFile(fileName: String, isRepl: Boolean, suffix: String): File {
|
||||||
|
|
||||||
val expectedFileName = if (isRepl) {
|
val expectedFileName = if (isRepl) {
|
||||||
fileName.replace(".kts", ".repl.after")
|
fileName.replace(".kts", ".repl.$suffix")
|
||||||
} else {
|
} else {
|
||||||
fileName.replace(".kts", ".comp.after")
|
fileName.replace(".kts", ".comp.$suffix")
|
||||||
}
|
}
|
||||||
val expectedFile = File(testDataPath, expectedFileName)
|
|
||||||
KotlinTestUtils.assertEqualsToFile(expectedFile, actualOutput)
|
return File(testDataPath, expectedFileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun String.inlinePropertiesValues(
|
protected fun String.inlinePropertiesValues(
|
||||||
@@ -158,6 +180,14 @@ abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() {
|
|||||||
return actualOutput.toString().trim()
|
return actualOutput.toString().trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getPreviewTextWithFoldings(): String {
|
||||||
|
val scratchFileEditor = getScratchEditorForSelectedFile(myManager, myFixture.file.virtualFile)
|
||||||
|
?: error("Couldn't find scratch panel")
|
||||||
|
|
||||||
|
val previewEditor = scratchFileEditor.getPreviewEditor()
|
||||||
|
return getFoldingData(previewEditor.editor, withCollapseStatus = false)
|
||||||
|
}
|
||||||
|
|
||||||
protected fun getInlays(start: Int = 0, end: Int = myFixture.file.textLength): List<InlayScratchFileRenderer> {
|
protected fun getInlays(start: Int = 0, end: Int = myFixture.file.textLength): List<InlayScratchFileRenderer> {
|
||||||
val inlineElementsInRange = myFixture.editor.inlayModel.getInlays(start, end)
|
val inlineElementsInRange = myFixture.editor.inlayModel.getInlays(start, end)
|
||||||
return inlineElementsInRange.map { it.renderer as InlayScratchFileRenderer }
|
return inlineElementsInRange.map { it.renderer as InlayScratchFileRenderer }
|
||||||
|
|||||||
+28
@@ -276,4 +276,32 @@ public class ScratchRunActionTestGenerated extends AbstractScratchRunActionTest
|
|||||||
runTest("idea/testData/worksheet/multiFile/javaDepScriptRuntime/");
|
runTest("idea/testData/worksheet/multiFile/javaDepScriptRuntime/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/testData/scratch/rightPanelOutput")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class ScratchRightPanelOutput extends AbstractScratchRunActionTest {
|
||||||
|
private void runTest(String testDataFilePath) throws Exception {
|
||||||
|
KotlinTestUtils.runTest(this::doRightPreviewPanelOutputTest, TargetBackend.ANY, testDataFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInScratchRightPanelOutput() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/scratch/rightPanelOutput"), Pattern.compile("^(.+)\\.kts$"), TargetBackend.ANY, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("bigSequentialOutputs.kts")
|
||||||
|
public void testBigSequentialOutputs() throws Exception {
|
||||||
|
runTest("idea/testData/scratch/rightPanelOutput/bigSequentialOutputs.kts");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("shortExpression.longOutput.singleTop.kts")
|
||||||
|
public void testShortExpression_longOutput_singleTop() throws Exception {
|
||||||
|
runTest("idea/testData/scratch/rightPanelOutput/shortExpression.longOutput.singleTop.kts");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("shortExpression.shortOutput.singleTop.kts")
|
||||||
|
public void testShortExpression_shortOutput_singleTop() throws Exception {
|
||||||
|
runTest("idea/testData/scratch/rightPanelOutput/shortExpression.shortOutput.singleTop.kts");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.scratch
|
||||||
|
|
||||||
|
import com.intellij.openapi.editor.Editor
|
||||||
|
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl
|
||||||
|
|
||||||
|
fun getFoldingData(editor: Editor, withCollapseStatus: Boolean): String {
|
||||||
|
return CodeInsightTestFixtureImpl.getFoldingData(editor, withCollapseStatus)
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.scratch
|
||||||
|
|
||||||
|
import com.intellij.openapi.editor.Editor
|
||||||
|
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl
|
||||||
|
|
||||||
|
fun getFoldingData(topEditor: Editor, withCollapseStatus: Boolean): String {
|
||||||
|
return CodeInsightTestFixtureImpl.getTagsFromSegments(
|
||||||
|
topEditor.document.text,
|
||||||
|
topEditor.foldingModel.allFoldRegions.asList(),
|
||||||
|
"fold"
|
||||||
|
) { foldRegion ->
|
||||||
|
"""text='${foldRegion.placeholderText}'${if (withCollapseStatus) """ expand='${foldRegion.isExpanded}'""" else ""}"""
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user