Attach preceding line comments to property accessors (KT-25417)
#KT-25417 Fixed
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
+6
@@ -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) {}
|
||||
|
||||
+40
-1
@@ -472,4 +472,43 @@ KtFile: CommentsBinding.kt
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(EOL_COMMENT)('// prop2')
|
||||
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)('}')
|
||||
+13
-1
@@ -37,4 +37,16 @@ class EmptyProperties {
|
||||
*
|
||||
*/
|
||||
set(value) {}
|
||||
}
|
||||
}
|
||||
|
||||
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) {}
|
||||
+13
-1
@@ -40,4 +40,16 @@ class EmptyProperties {
|
||||
*
|
||||
*/
|
||||
set(value) {}
|
||||
}
|
||||
}
|
||||
|
||||
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) {}
|
||||
Reference in New Issue
Block a user