Add indent before accessor for extension property (KT-33131)
#KT-33131 Fixed
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
c6a481190a
commit
ab34f8c738
@@ -328,10 +328,15 @@ abstract class KotlinCommonBlock(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newChildIndex > 0) {
|
if (newChildIndex > 0) {
|
||||||
val prevBlock = mySubBlocks?.get(newChildIndex - 1)
|
val prevNode = mySubBlocks?.get(newChildIndex - 1)?.node
|
||||||
if (prevBlock?.node?.elementType == MODIFIER_LIST) {
|
if (prevNode?.elementType == MODIFIER_LIST) {
|
||||||
return ChildAttributes(Indent.getNoneIndent(), null)
|
return ChildAttributes(Indent.getNoneIndent(), null)
|
||||||
}
|
}
|
||||||
|
val property = prevNode?.psi as? KtProperty
|
||||||
|
if (property?.receiverTypeReference != null && property.accessors.isNotEmpty()) {
|
||||||
|
val indent = if (type in CODE_BLOCKS) Indent.getContinuationIndent() else Indent.getNormalIndent()
|
||||||
|
return ChildAttributes(indent, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return when (type) {
|
return when (type) {
|
||||||
|
|||||||
+10
@@ -34,6 +34,16 @@ public class PerformanceTypingIndentationTestGenerated extends AbstractPerforman
|
|||||||
runTest("idea/testData/indentationOnNewline/AfterClassNameBeforeFun.kt");
|
runTest("idea/testData/indentationOnNewline/AfterClassNameBeforeFun.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("AfterExtensionPropertyGetter.kt")
|
||||||
|
public void testAfterExtensionPropertyGetter() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/AfterExtensionPropertyGetter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("AfterExtensionPropertySetter.kt")
|
||||||
|
public void testAfterExtensionPropertySetter() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/AfterExtensionPropertySetter.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("AfterFinally.kt")
|
@TestMetadata("AfterFinally.kt")
|
||||||
public void testAfterFinally() throws Exception {
|
public void testAfterFinally() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/AfterFinally.kt");
|
runTest("idea/testData/indentationOnNewline/AfterFinally.kt");
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
var String.foo: Int
|
||||||
|
get() = length
|
||||||
|
<caret>
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
var String.foo: Int
|
||||||
|
get() = length<caret>
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
var String.foo: Int
|
||||||
|
set(value) {}
|
||||||
|
<caret>
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
var String.foo: Int
|
||||||
|
set(value) {}<caret>
|
||||||
|
|
||||||
|
// WITHOUT_CUSTOM_LINE_INDENT_PROVIDER
|
||||||
+10
@@ -36,6 +36,16 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio
|
|||||||
runTest("idea/testData/indentationOnNewline/AfterClassNameBeforeFun.after.kt");
|
runTest("idea/testData/indentationOnNewline/AfterClassNameBeforeFun.after.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("AfterExtensionPropertyGetter.after.kt")
|
||||||
|
public void testAfterExtensionPropertyGetter() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/AfterExtensionPropertyGetter.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("AfterExtensionPropertySetter.after.kt")
|
||||||
|
public void testAfterExtensionPropertySetter() throws Exception {
|
||||||
|
runTest("idea/testData/indentationOnNewline/AfterExtensionPropertySetter.after.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("AfterFinally.after.kt")
|
@TestMetadata("AfterFinally.after.kt")
|
||||||
public void testAfterFinally() throws Exception {
|
public void testAfterFinally() throws Exception {
|
||||||
runTest("idea/testData/indentationOnNewline/AfterFinally.after.kt");
|
runTest("idea/testData/indentationOnNewline/AfterFinally.after.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user