Extract Function: In case of top-level and member declarations place extracted function after the original container

This commit is contained in:
Alexey Sedunov
2014-05-30 14:37:41 +04:00
parent ae7ad6d61c
commit 3c5c0248a7
138 changed files with 482 additions and 440 deletions
@@ -356,10 +356,10 @@ private fun getFunctionForExtractedFragment(
val newDebugExpression = addDebugExpressionBeforeContextElement(codeFragment, contextElement)
if (newDebugExpression == null) return null
val nextSibling = tmpFile.getDeclarations().firstOrNull()
if (nextSibling == null) return null
val targetSibling = tmpFile.getDeclarations().firstOrNull()
if (targetSibling == null) return null
val analysisResult = ExtractionData(tmpFile, Collections.singletonList(newDebugExpression), nextSibling).performAnalysis()
val analysisResult = ExtractionData(tmpFile, Collections.singletonList(newDebugExpression), targetSibling).performAnalysis()
if (analysisResult.status != Status.SUCCESS) {
throw EvaluateExceptionUtil.createEvaluateException(getErrorMessageForExtractFunctionResult(analysisResult))
}
@@ -56,11 +56,11 @@ public class ExtractKotlinFunctionHandler : RefactoringActionHandler {
editor: Editor,
file: JetFile,
elements: List<PsiElement>,
nextSibling: PsiElement
targetSibling: PsiElement
) {
val project = file.getProject()
val analysisResult = ExtractionData(file, elements, nextSibling).performAnalysis()
val analysisResult = ExtractionData(file, elements, targetSibling).performAnalysis()
if (ApplicationManager.getApplication()!!.isUnitTestMode() && analysisResult.status != Status.SUCCESS) {
throw ConflictsInTestsException(analysisResult.messages.map { it.renderMessage() })
@@ -119,8 +119,8 @@ public class ExtractKotlinFunctionHandler : RefactoringActionHandler {
override fun invoke(project: Project, editor: Editor, file: PsiFile, dataContext: DataContext?) {
if (file !is JetFile) return
selectElements(editor, file) { (elements, targetNextSibling) ->
doInvoke(editor, file, elements, targetNextSibling)
selectElements(editor, file) { (elements, targetSibling) ->
doInvoke(editor, file, elements, targetSibling)
}
}
@@ -142,7 +142,7 @@ private fun showErrorHintByKey(project: Project, editor: Editor, key: String) {
fun selectElements(
editor: Editor,
file: PsiFile,
continuation: (elements: List<PsiElement>, targetNextSibling: PsiElement) -> Unit
continuation: (elements: List<PsiElement>, targetSibling: PsiElement) -> Unit
) {
fun noExpressionError() {
showErrorHintByKey(file.getProject(), editor, "cannot.refactor.no.expression")
@@ -33,7 +33,6 @@ import org.jetbrains.jet.plugin.codeInsight.DescriptorToDeclarationUtil
import java.util.Collections
import org.jetbrains.jet.lang.psi.JetBlockExpression
import org.jetbrains.jet.renderer.DescriptorRenderer
import org.jetbrains.jet.lang.psi.psiUtil.getParentByTypeAndBranch
import org.jetbrains.jet.lang.psi.JetQualifiedExpression
import org.jetbrains.jet.lang.psi.psiUtil.isInsideOf
import java.util.ArrayList
@@ -41,6 +40,9 @@ import com.intellij.psi.PsiNamedElement
import org.jetbrains.jet.lang.psi.JetSuperExpression
import org.jetbrains.jet.lang.types.JetType
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
import org.jetbrains.jet.lang.psi.JetDeclaration
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody
data class ResolveResult(
val originalRefExpr: JetSimpleNameExpression,
@@ -58,10 +60,12 @@ data class ResolvedReferenceInfo(
class ExtractionData(
val originalFile: JetFile,
val originalElements: List<PsiElement>,
val nextSibling: PsiElement
val targetSibling: PsiElement
) {
val project: Project = originalFile.getProject()
val insertBefore: Boolean = targetSibling.getParentByType(javaClass<JetDeclaration>(), true) is JetDeclarationWithBody
fun getExpressions(): List<JetExpression> = originalElements.filterIsInstance(javaClass<JetExpression>())
fun getCodeFragmentTextRange(): TextRange? {
@@ -97,7 +97,6 @@ import org.jetbrains.jet.lang.diagnostics.Errors
import org.jetbrains.jet.lang.psi.JetTypeReference
import org.jetbrains.jet.lang.psi.JetTypeParameterListOwner
import org.jetbrains.jet.plugin.refactoring.extractFunction.AnalysisResult.Status
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
import org.jetbrains.jet.lang.psi.codeFragmentUtil.skipVisibilityCheck
import org.jetbrains.jet.lang.psi.codeFragmentUtil.setSkipVisibilityCheck
import org.jetbrains.jet.plugin.refactoring.extractFunction.AnalysisResult.ErrorMessage
@@ -232,15 +231,32 @@ private fun List<Instruction>.analyzeControlFlow(
return Pair(DefaultControlFlow, null)
}
private fun ExtractionData.createTemporaryCodeBlock(): JetBlockExpression {
val position = nextSibling.getTextRange()!!.getStartOffset()
val tmpFile = originalFile.createTempCopy { text ->
StringBuilder(text).insert(position, "fun() {\n${getCodeFragmentText()}\n}\n").toString()
fun ExtractionData.createTemporaryFunction(functionText: String): JetNamedFunction {
val textRange = targetSibling.getTextRange()!!
val insertText: String
val insertPosition: Int
val lookupPosition: Int
if (insertBefore) {
insertPosition = textRange.getStartOffset()
lookupPosition = insertPosition
insertText = functionText
}
val tmpFunction = tmpFile.findElementAt(position)?.getParentByType(javaClass<JetNamedFunction>())!!
return tmpFunction.getBodyExpression() as JetBlockExpression
else {
insertPosition = textRange.getEndOffset()
lookupPosition = insertPosition + 1
insertText = "\n$functionText"
}
val tmpFile = originalFile.createTempCopy { text ->
StringBuilder(text).insert(insertPosition, insertText).toString()
}
return tmpFile.findElementAt(lookupPosition)?.getParentByType(javaClass<JetNamedFunction>())!!
}
private fun ExtractionData.createTemporaryCodeBlock(): JetBlockExpression =
createTemporaryFunction("fun() {\n${getCodeFragmentText()}\n}\n").getBodyExpression() as JetBlockExpression
private fun JetType.collectReferencedTypes(): List<JetType> {
return DFS.dfsFromNode(
this,
@@ -534,8 +550,8 @@ fun ExtractionData.performAnalysis(): AnalysisResult {
checkDeclarationsMovingOutOfScope(controlFlow)?.let { messages.add(it) }
val functionNameValidator = JetNameValidatorImpl(
nextSibling.getParent(),
nextSibling,
targetSibling.getParent(),
targetSibling,
JetNameValidatorImpl.Target.FUNCTIONS_AND_CLASSES
)
val functionName = JetNameSuggester.suggestNames(controlFlow.returnType, functionNameValidator, DEFAULT_FUNCTION_NAME).first()
@@ -673,14 +689,11 @@ fun ExtractionDescriptor.generateFunction(
fun createFunction(): JetNamedFunction {
return with(extractionData) {
if (inTempFile) {
val position = nextSibling.getTextRange()!!.getStartOffset()
val tmpFile = originalFile.createTempCopy { text ->
StringBuilder(text).insert(position, getFunctionText() + "\n").toString()
}
val function = createTemporaryFunction("${getFunctionText()}\n")
if (originalFile.skipVisibilityCheck()) {
tmpFile.setSkipVisibilityCheck(true)
function.getContainingJetFile().setSkipVisibilityCheck(true)
}
tmpFile.findElementAt(position)?.getParentByType(javaClass<JetNamedFunction>())!!
function
}
else {
JetPsiFactory.createFunction(project, getFunctionText())
@@ -763,11 +776,20 @@ fun ExtractionDescriptor.generateFunction(
fun insertFunction(function: JetNamedFunction): JetNamedFunction {
return with(extractionData) {
val targetContainer = nextSibling.getParent()!!
val functionInFile = targetContainer.addBefore(function, nextSibling) as JetNamedFunction
targetContainer.addBefore(JetPsiFactory.createWhiteSpace(project, "\n\n"), nextSibling)
val targetContainer = targetSibling.getParent()!!
val emptyLines = JetPsiFactory.createWhiteSpace(project, "\n\n")
if (insertBefore) {
val functionInFile = targetContainer.addBefore(function, targetSibling) as JetNamedFunction
targetContainer.addBefore(emptyLines, targetSibling)
functionInFile
functionInFile
}
else {
val functionInFile = targetContainer.addAfter(function, targetSibling) as JetNamedFunction
targetContainer.addAfter(emptyLines, targetSibling)
functionInFile
}
}
}
@@ -26,7 +26,6 @@ import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.JetClassBody;
import org.jetbrains.jet.lang.psi.JetClassOrObject;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.plugin.refactoring.JetNameSuggester;
import org.jetbrains.jet.plugin.refactoring.JetRefactoringBundle;
@@ -72,7 +71,7 @@ public class KotlinExtractFunctionDialog extends DialogWrapper {
}
private boolean isVisibilitySectionAvailable() {
PsiElement target = originalDescriptor.getDescriptor().getExtractionData().getNextSibling().getParent();
PsiElement target = originalDescriptor.getDescriptor().getExtractionData().getTargetSibling().getParent();
return target instanceof JetClassBody || target instanceof JetFile;
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
<selection>// test
println(a)
@@ -1,12 +1,12 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
if (b(a)) return a
return -a
}
fun b(a: Int): Boolean {
// test
println(a)
if (a > 0) return true
return false
}
fun foo(a: Int): Int {
if (b(a)) return a
return -a
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
<selection>/*
test
@@ -1,4 +1,9 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
if (b(a)) return a
return -a
}
fun b(a: Int): Boolean {
/*
test
@@ -6,9 +11,4 @@ fun b(a: Int): Boolean {
println(a)
if (a > 0) return true
return false
}
fun foo(a: Int): Int {
if (b(a)) return a
return -a
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
class A {
fun bar(): Int = a + 10
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
class A {
val bar: Int = a + 10
@@ -0,0 +1,4 @@
fun foo(a: Int): Int {
// SIBLING:
return <selection>a + 10</selection>
}
@@ -0,0 +1,8 @@
fun foo(a: Int): Int {
// SIBLING:
fun i(): Int {
return a + 10
}
return i()
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
fun bar(): Int = a + 10
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun bar(): Int = 100
fun foo(a: Int): Int {
@@ -1,6 +1,6 @@
fun foo() {
val a = 1
// NEXT_SIBLING
// SIBLING:
if (<selection>a > 0</selection>) {
fun b(): Int { return 0 }
println(b())
@@ -1,6 +1,6 @@
fun foo() {
val a = 1
// NEXT_SIBLING
// SIBLING:
fun b1(): Boolean {
return a > 0
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
class A {
private val t: Int = 1
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
<selection>println(a)
if (a > 0) return a</selection>
@@ -1,11 +1,11 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
if (b(a)) return a
return -a
}
fun b(a: Int): Boolean {
println(a)
if (a > 0) return true
return false
}
fun foo(a: Int): Int {
if (b(a)) return a
return -a
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
@@ -1,16 +1,16 @@
// NEXT_SIBLING:
fun b(a: Int, b: Int): Boolean {
if (a + b > 0) return true
println(a - b)
if (a - b > 0) return true
println(a + b)
return false
}
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
if (b(a, b)) break
}
return 1
}
fun b(a: Int, b: Int): Boolean {
if (a + b > 0) return true
println(a - b)
if (a - b > 0) return true
println(a + b)
return false
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
@@ -1,13 +1,4 @@
// NEXT_SIBLING:
fun b(a: Int, b: Int): Boolean {
if (a + b > 0) return true
else {
println(a - b)
if (a - b > 0) return true else println(a + b)
}
return false
}
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
@@ -15,4 +6,13 @@ fun foo(a: Int): Int {
}
return 1
}
fun b(a: Int, b: Int): Boolean {
if (a + b > 0) return true
else {
println(a - b)
if (a - b > 0) return true else println(a + b)
}
return false
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
@@ -1,4 +1,12 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
if (b(a, b)) break
}
return 1
}
fun b(a: Int, b: Int): Boolean {
when {
a + b > 0 -> return true
@@ -6,12 +14,4 @@ fun b(a: Int, b: Int): Boolean {
else -> println(0)
}
return false
}
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
if (b(a, b)) break
}
return 1
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
<selection>if (a + b > 0) return 0
@@ -1,12 +1,12 @@
// NEXT_SIBLING:
fun b(a: Int, b: Int): Boolean {
if (a + b > 0) return true
println(a - b)
return false
}
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
if (b(a, b)) return 0
return 1
}
fun b(a: Int, b: Int): Boolean {
if (a + b > 0) return true
println(a - b)
return false
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
<selection>if (a + b > 0) return 0
@@ -1,13 +1,13 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
if (b(a, b)) return 0
return 1
}
fun b(a: Int, b: Int): Boolean {
if (a + b > 0) return true
else if (a - b < 0) println(a - b)
else println(0)
return false
}
fun foo(a: Int): Int {
val b: Int = 1
if (b(a, b)) return 0
return 1
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
<selection>when (a + b) {
@@ -1,4 +1,11 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
if (b(a, b)) return 0
return 1
}
fun b(a: Int, b: Int): Boolean {
when (a + b) {
0 -> return true
@@ -6,11 +13,4 @@ fun b(a: Int, b: Int): Boolean {
else -> println(2)
}
return false
}
fun foo(a: Int): Int {
val b: Int = 1
if (b(a, b)) return 0
return 1
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
@@ -1,10 +1,4 @@
// NEXT_SIBLING:
fun unit(a: Int, b: Int) {
if (a + b > 0) return
println(a - b)
return
}
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
@@ -12,4 +6,10 @@ fun foo(a: Int): Int {
break
}
return 1
}
fun unit(a: Int, b: Int) {
if (a + b > 0) return
println(a - b)
return
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
@@ -1,12 +1,4 @@
// NEXT_SIBLING:
fun unit(a: Int, b: Int) {
if (a + b > 0) return
else {
println(a - b)
return
}
}
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
@@ -14,4 +6,12 @@ fun foo(a: Int): Int {
break
}
return 1
}
fun unit(a: Int, b: Int) {
if (a + b > 0) return
else {
println(a - b)
return
}
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
@@ -1,4 +1,13 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
unit(a, b)
break
}
return 1
}
fun unit(a: Int, b: Int) {
when {
a + b > 0 -> return
@@ -8,13 +17,4 @@ fun unit(a: Int, b: Int) {
return
}
}
}
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
unit(a, b)
break
}
return 1
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int) {
val b: Int = 1
@@ -1,13 +1,13 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int) {
val b: Int = 1
unit(a, b)
}
fun unit(a: Int, b: Int) {
if (a > 0) {
println(a)
}
println(b)
}
fun foo(a: Int) {
val b: Int = 1
unit(a, b)
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int) {
val b: Int = 1
@@ -1,4 +1,10 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int) {
val b: Int = 1
unit(a)
}
fun unit(a: Int) {
var t = a
while (t > 0) {
@@ -7,10 +13,4 @@ fun unit(a: Int) {
if (t == 1) break
t--
}
}
fun foo(a: Int) {
val b: Int = 1
unit(a)
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
<selection>if (a + b > 0) return 1
@@ -1,11 +1,11 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return i(a, b)
}
fun i(a: Int, b: Int): Int {
if (a + b > 0) return 1
else if (a - b < 0) return 2
else return b
}
fun foo(a: Int): Int {
val b: Int = 1
return i(a, b)
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
<selection>when (a + b) {
@@ -1,13 +1,13 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return i(a, b)
}
fun i(a: Int, b: Int): Int {
when (a + b) {
0 -> return b
1 -> return -b
else -> return a - b
}
}
fun foo(a: Int): Int {
val b: Int = 1
return i(a, b)
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
<selection>return a + b</selection>
@@ -1,9 +1,9 @@
// NEXT_SIBLING:
fun i(a: Int, b: Int): Int {
return a + b
}
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return i(a, b)
}
fun i(a: Int, b: Int): Int {
return a + b
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return <selection>if (a + b > 0) 1 else if (a - b < 0) 2 else b </selection>
@@ -1,9 +1,9 @@
// NEXT_SIBLING:
fun i(a: Int, b: Int): Int {
return if (a + b > 0) 1 else if (a - b < 0) 2 else b
}
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return i(a, b)
}
fun i(a: Int, b: Int): Int {
return if (a + b > 0) 1 else if (a - b < 0) 2 else b
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return <selection>when (a + b) {
@@ -1,13 +1,13 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return i(a, b)
}
fun i(a: Int, b: Int): Int {
return when (a + b) {
0 -> b
1 -> -b
else -> a - b
}
}
fun foo(a: Int): Int {
val b: Int = 1
return i(a, b)
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return <selection>a + b</selection>
@@ -1,9 +1,9 @@
// NEXT_SIBLING:
fun i(a: Int, b: Int): Int {
return a + b
}
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return i(a, b)
}
fun i(a: Int, b: Int): Int {
return a + b
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
var c: Int = 1
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
var c: Int = 1
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
var c: Int = 1
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,15 +1,15 @@
// NEXT_SIBLING:
fun i(a: Int, b: Int): Int {
var b1 = b
b1 += a
println(b1)
return b1
}
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
b = i(a, b)
return b
}
fun i(a: Int, b: Int): Int {
var b1 = b
b1 += a
println(b1)
return b1
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,4 +1,12 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
b = i(a, b)
return b
}
fun i(a: Int, b: Int): Int {
var b1 = b
if (a > 0) {
@@ -6,12 +14,4 @@ fun i(a: Int, b: Int): Int {
}
println(b1)
return b1
}
fun foo(a: Int): Int {
var b: Int = 1
b = i(a, b)
return b
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,4 +1,12 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
b = i(a, b)
return b
}
fun i(a: Int, b: Int): Int {
var b1 = b
if (a > 0) {
@@ -10,12 +18,4 @@ fun i(a: Int, b: Int): Int {
}
println(b1)
return b1
}
fun foo(a: Int): Int {
var b: Int = 1
b = i(a, b)
return b
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,4 +1,12 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
b = i(a, b)
return b
}
fun i(a: Int, b: Int): Int {
var b1 = b
when {
@@ -11,12 +19,4 @@ fun i(a: Int, b: Int): Int {
}
println(b1)
return b1
}
fun foo(a: Int): Int {
var b: Int = 1
b = i(a, b)
return b
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,4 +1,12 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
b = i(a, b)
return b
}
fun i(a: Int, b: Int): Int {
var b1 = b
when {
@@ -14,12 +22,4 @@ fun i(a: Int, b: Int): Int {
}
println(b1)
return b1
}
fun foo(a: Int): Int {
var b: Int = 1
b = i(a, b)
return b
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..b) {
@@ -1,14 +1,14 @@
// NEXT_SIBLING:
fun b(a: Int, b: Int): Boolean {
if (a > 0) throw Exception("")
if (a + b > 0) return true
println(a - b)
return false
}
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..b) {
if (b(a, b)) break
}
}
fun b(a: Int, b: Int): Boolean {
if (a > 0) throw Exception("")
if (a + b > 0) return true
println(a - b)
return false
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..b) {
@@ -1,14 +1,14 @@
// NEXT_SIBLING:
fun b(a: Int, b: Int): Boolean {
if (a > 0) throw Exception("")
if (a + b > 0) return true
println(a - b)
return false
}
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..b) {
if (b(a, b)) continue
}
}
fun b(a: Int, b: Int): Boolean {
if (a > 0) throw Exception("")
if (a + b > 0) return true
println(a - b)
return false
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,11 +1,11 @@
// NEXT_SIBLING:
fun i(a: Int, b: Int): Int {
return if (a > 0) throw Exception("") else a + b
}
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
val t = i(a, b)
return t
}
fun i(a: Int, b: Int): Int {
return if (a > 0) throw Exception("") else a + b
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int) {
val b: Int = 1
@@ -1,13 +1,13 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int) {
val b: Int = 1
if (b(a, b)) return
}
fun b(a: Int, b: Int): Boolean {
if (a > 0) throw Exception("")
if (b + a > 0) return true
println(a - b)
return false
}
fun foo(a: Int) {
val b: Int = 1
if (b(a, b)) return
}
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,11 +1,11 @@
// NEXT_SIBLING:
fun i(a: Int, b: Int): Int {
if (a > 0) throw Exception("") else return a + b
return a - b
}
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
return i(a, b)
}
fun i(a: Int, b: Int): Int {
if (a > 0) throw Exception("") else return a + b
return a - b
}
@@ -3,7 +3,7 @@ trait Callable<T> {
}
fun foo(a: Int): Int {
// NEXT_SIBLING:
// SIBLING:
val o = <selection>object: Callable<Int> {
val b: Int = 1
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
for (n in 1..a) {
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
val b: Int = 1
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(a: Int): Int {
var b: Int = 1
@@ -1,4 +1,4 @@
// NEXT_SIBLING:
// SIBLING:
fun foo(t: Int): Int {
<selection>val x = t + 1
if (x > 0) return x</selection>
@@ -2,7 +2,7 @@ public open class Z {
val z: Int = 0
}
// NEXT_SIBLING:
// SIBLING:
public class A(): Z() {
var a: Int = 1
@@ -4,7 +4,7 @@ public open class Z {
}
}
// NEXT_SIBLING:
// SIBLING:
public class A(): Z() {
var a: Int = 1
@@ -4,7 +4,7 @@ public open class Z {
}
}
// NEXT_SIBLING:
// SIBLING:
public class A(): Z() {
var a: Int = 1
@@ -2,7 +2,7 @@ public open class Z {
val z: Int = 0
}
// NEXT_SIBLING:
// SIBLING:
public class A(): Z() {
var a: Int = 1
@@ -2,7 +2,7 @@ public open class Z {
val z: Int = 0
}
// NEXT_SIBLING:
// SIBLING:
public class A(): Z() {
var a: Int = 1
@@ -2,11 +2,7 @@ public open class Z {
val z: Int = 0
}
// NEXT_SIBLING:
fun i(a1: A, b1: A.B): Int {
return a1.a + b1.b + a1.z + b1.z
}
// SIBLING:
public class A(): Z() {
var a: Int = 1
@@ -18,3 +14,7 @@ public class A(): Z() {
}
}
}
fun i(a1: A, b1: A.B): Int {
return a1.a + b1.b + a1.z + b1.z
}
@@ -1,6 +1,6 @@
class Z(val a: Int)
// NEXT_SIBLING:
// SIBLING:
fun Z.foo(): Int {
return <selection>this.a</selection> + 1
}
@@ -1,10 +1,10 @@
class Z(val a: Int)
// NEXT_SIBLING:
fun Z.i(): Int {
return a
}
// SIBLING:
fun Z.foo(): Int {
return i() + 1
}
fun Z.i(): Int {
return a
}
@@ -2,7 +2,7 @@ public open class Z {
val z: Int = 0
}
// NEXT_SIBLING:
// SIBLING:
public class A(): Z() {
var a: Int = 1
@@ -2,11 +2,7 @@ public open class Z {
val z: Int = 0
}
// NEXT_SIBLING:
fun i(a1: A, b1: A.B): Int {
return a1.a + b1.b + b1.z
}
// SIBLING:
public class A(): Z() {
var a: Int = 1
@@ -18,3 +14,7 @@ public class A(): Z() {
}
}
}
fun i(a1: A, b1: A.B): Int {
return a1.a + b1.b + b1.z
}
@@ -2,7 +2,7 @@ public open class Z {
val z: Int = 0
}
// NEXT_SIBLING:
// SIBLING:
public class A(): Z() {
var a: Int = 1
@@ -2,11 +2,7 @@ public open class Z {
val z: Int = 0
}
// NEXT_SIBLING:
fun i(a1: A, b1: A.B): Int {
return a1.a + b1.b + a1.z + b1.z
}
// SIBLING:
public class A(): Z() {
var a: Int = 1
@@ -18,3 +14,7 @@ public class A(): Z() {
}
}
}
fun i(a1: A, b1: A.B): Int {
return a1.a + b1.b + a1.z + b1.z
}
@@ -1,6 +1,6 @@
class Z(val a: Int)
// NEXT_SIBLING:
// SIBLING:
fun Z.foo(): Int {
return <selection>this.a + a</selection> + 1
}
@@ -1,10 +1,10 @@
class Z(val a: Int)
// NEXT_SIBLING:
fun Z.i(): Int {
return a + a
}
// SIBLING:
fun Z.foo(): Int {
return i() + 1
}
fun Z.i(): Int {
return a + a
}

Some files were not shown because too many files have changed in this diff Show More