Extraction Engine: Assume internal visibility for trait members
This commit is contained in:
+10
-1
@@ -736,6 +736,15 @@ fun ExtractionData.isVisibilityApplicable(): Boolean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun ExtractionData.getDefaultVisibility(): String {
|
||||||
|
if (!isVisibilityApplicable()) return ""
|
||||||
|
|
||||||
|
val parent = targetSibling.getStrictParentOfType<JetDeclaration>()
|
||||||
|
if (parent is JetClass && parent.isTrait()) return ""
|
||||||
|
|
||||||
|
return "private"
|
||||||
|
}
|
||||||
|
|
||||||
fun ExtractionData.performAnalysis(): AnalysisResult {
|
fun ExtractionData.performAnalysis(): AnalysisResult {
|
||||||
if (originalElements.isEmpty()) {
|
if (originalElements.isEmpty()) {
|
||||||
return AnalysisResult(null, Status.CRITICAL_ERROR, listOf(ErrorMessage.NO_EXPRESSION))
|
return AnalysisResult(null, Status.CRITICAL_ERROR, listOf(ErrorMessage.NO_EXPRESSION))
|
||||||
@@ -824,7 +833,7 @@ fun ExtractionData.performAnalysis(): AnalysisResult {
|
|||||||
this,
|
this,
|
||||||
bindingContext,
|
bindingContext,
|
||||||
functionNames,
|
functionNames,
|
||||||
if (isVisibilityApplicable()) "private" else "",
|
getDefaultVisibility(),
|
||||||
adjustedParameters.sortBy { it.name },
|
adjustedParameters.sortBy { it.name },
|
||||||
receiverParameter,
|
receiverParameter,
|
||||||
paramsInfo.typeParameters.sortBy { it.originalDeclaration.getName()!! },
|
paramsInfo.typeParameters.sortBy { it.originalDeclaration.getName()!! },
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
trait T{
|
||||||
|
fun foo(): Int {
|
||||||
|
return <selection>1</selection>
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
trait T{
|
||||||
|
fun foo(): Int {
|
||||||
|
return i()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun i(): Int {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// EXTRACTION_TARGET: property with getter
|
// EXTRACTION_TARGET: property with getter
|
||||||
trait T {
|
trait T {
|
||||||
private val i: Int
|
val i: Int
|
||||||
get() {
|
get() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -483,6 +483,12 @@ public class JetExtractionTestGenerated extends AbstractJetExtractionTest {
|
|||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/basic/refInReturn.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/basic/refInReturn.kt");
|
||||||
doExtractFunctionTest(fileName);
|
doExtractFunctionTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("traitFunction.kt")
|
||||||
|
public void testTraitFunction() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/basic/traitFunction.kt");
|
||||||
|
doExtractFunctionTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/refactoring/extractFunction/controlFlow")
|
@TestMetadata("idea/testData/refactoring/extractFunction/controlFlow")
|
||||||
|
|||||||
Reference in New Issue
Block a user