diff --git a/compiler/psi/src/org/jetbrains/kotlin/parsing/KotlinParsing.java b/compiler/psi/src/org/jetbrains/kotlin/parsing/KotlinParsing.java index c06ecaae47b..1c60cf79843 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/parsing/KotlinParsing.java +++ b/compiler/psi/src/org/jetbrains/kotlin/parsing/KotlinParsing.java @@ -1472,7 +1472,7 @@ public class KotlinParsing extends AbstractKotlinParsing { errorUntil("Accessor body expected", TokenSet.orSet(ACCESSOR_FIRST_OR_PROPERTY_END, TokenSet.create(LBRACE, LPAR, EQ))); } else { - closeDeclarationWithCommentBinders(getterOrSetter, PROPERTY_ACCESSOR, false); + closeDeclarationWithCommentBinders(getterOrSetter, PROPERTY_ACCESSOR, true); return accessorKind; } } @@ -1508,7 +1508,7 @@ public class KotlinParsing extends AbstractKotlinParsing { parseFunctionBody(); - closeDeclarationWithCommentBinders(getterOrSetter, PROPERTY_ACCESSOR, false); + closeDeclarationWithCommentBinders(getterOrSetter, PROPERTY_ACCESSOR, true); return accessorKind; } diff --git a/compiler/testData/psi/CommentsBinding.kt b/compiler/testData/psi/CommentsBinding.kt index 59e3a753e3e..21a5219ffe7 100644 --- a/compiler/testData/psi/CommentsBinding.kt +++ b/compiler/testData/psi/CommentsBinding.kt @@ -71,3 +71,9 @@ var prop: Int // Int set(value) {} // this is setter val prop2: Int get = 1 // prop2 + +var prop3: Int // Int + // this comment is for getter + get() = 1 + // this comment is for setter + set(value) {} diff --git a/compiler/testData/psi/CommentsBinding.txt b/compiler/testData/psi/CommentsBinding.txt index 19d5c91b038..c596e669ab3 100644 --- a/compiler/testData/psi/CommentsBinding.txt +++ b/compiler/testData/psi/CommentsBinding.txt @@ -472,4 +472,43 @@ KtFile: CommentsBinding.kt INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('1') PsiWhiteSpace(' ') - PsiComment(EOL_COMMENT)('// prop2') \ No newline at end of file + PsiComment(EOL_COMMENT)('// prop2') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('prop3') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiComment(EOL_COMMENT)('// Int') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiComment(EOL_COMMENT)('// this comment is for getter') + PsiWhiteSpace('\n ') + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiComment(EOL_COMMENT)('// this comment is for setter') + PsiWhiteSpace('\n ') + PsiElement(set)('set') + PsiElement(LPAR)('(') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/idea/testData/formatter/PropertyAccessors.after.kt b/idea/testData/formatter/PropertyAccessors.after.kt index 66cd4cca83f..dfea0d00587 100644 --- a/idea/testData/formatter/PropertyAccessors.after.kt +++ b/idea/testData/formatter/PropertyAccessors.after.kt @@ -37,4 +37,16 @@ class EmptyProperties { * */ set(value) {} -} \ No newline at end of file +} + +var prop: Int // Int + get() = 1 // this is getter + set(value) {} // this is setter + +val prop2: Int get = 1 // prop2 + +var prop3: Int // Int + // this comment is for getter + get() = 1 + // this comment is for setter + set(value) {} \ No newline at end of file diff --git a/idea/testData/formatter/PropertyAccessors.kt b/idea/testData/formatter/PropertyAccessors.kt index 2b8a188c15d..68b9bedb5e9 100644 --- a/idea/testData/formatter/PropertyAccessors.kt +++ b/idea/testData/formatter/PropertyAccessors.kt @@ -40,4 +40,16 @@ class EmptyProperties { * */ set(value) {} -} \ No newline at end of file +} + +var prop: Int // Int +get() = 1 // this is getter +set(value) {} // this is setter + +val prop2: Int get = 1 // prop2 + +var prop3: Int // Int +// this comment is for getter +get() = 1 +// this comment is for setter +set(value) {} \ No newline at end of file