From a0982341eebcdfaa83aecd63987d194976b07409 Mon Sep 17 00:00:00 2001 From: Nikolay Lunyak Date: Thu, 19 Aug 2021 23:19:41 +0300 Subject: [PATCH] [FIR] Update parser test data --- .../PropertiesWithFunctionReceivers.txt | 2 +- .../explicitBackingField.kt | 29 +++ .../explicitBackingField.txt | 218 ++++++++++++++++++ .../kotlin/parsing/ParsingTestGenerated.java | 18 ++ 4 files changed, 266 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/psi/propertyBackingField/explicitBackingField.kt create mode 100644 compiler/testData/psi/propertyBackingField/explicitBackingField.txt diff --git a/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceivers.txt b/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceivers.txt index 151520f6e45..2c7baca7fd8 100644 --- a/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceivers.txt +++ b/compiler/testData/psi/functionReceivers/PropertiesWithFunctionReceivers.txt @@ -521,7 +521,7 @@ KtFile: PropertiesWithFunctionReceivers.kt PsiElement(RBRACE)('}') PsiWhiteSpace('\n ') PsiErrorElement:Expecting a top level declaration - PsiElement(IDENTIFIER)('set') + PsiElement(set)('set') PsiErrorElement:Expecting a top level declaration PsiElement(LPAR)('(') PsiErrorElement:Expecting a top level declaration diff --git a/compiler/testData/psi/propertyBackingField/explicitBackingField.kt b/compiler/testData/psi/propertyBackingField/explicitBackingField.kt new file mode 100644 index 00000000000..f90e1a1a66d --- /dev/null +++ b/compiler/testData/psi/propertyBackingField/explicitBackingField.kt @@ -0,0 +1,29 @@ +val simpleNumber: Number + field = 4 + +val numberWithPrivateField: Number + private field = 4 + +val numberWithLateinitField: Number + lateinit field: Int + +val numberWithInternalLateinitField: Number + internal lateinit field: Int + +var numberWithFieldAndAccessors: Number + field = "test" + get() = field.length + set(value) { + field = value.toString() + } + +val numberWithExplicitType: Number + field: Int = 10 + +val numberWithBlockInitializer: Number + field { + return 10 + } + +val minimalNumber + field diff --git a/compiler/testData/psi/propertyBackingField/explicitBackingField.txt b/compiler/testData/psi/propertyBackingField/explicitBackingField.txt new file mode 100644 index 00000000000..ba63d82cbf8 --- /dev/null +++ b/compiler/testData/psi/propertyBackingField/explicitBackingField.txt @@ -0,0 +1,218 @@ +KtFile: explicitBackingField.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('simpleNumber') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiWhiteSpace('\n ') + BACKING_FIELD + PsiElement(field)('field') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('4') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('numberWithPrivateField') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiWhiteSpace('\n ') + BACKING_FIELD + MODIFIER_LIST + PsiElement(private)('private') + PsiWhiteSpace(' ') + PsiElement(field)('field') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('4') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('numberWithLateinitField') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiWhiteSpace('\n ') + BACKING_FIELD + MODIFIER_LIST + PsiElement(lateinit)('lateinit') + PsiWhiteSpace(' ') + PsiElement(field)('field') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('numberWithInternalLateinitField') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiWhiteSpace('\n ') + BACKING_FIELD + MODIFIER_LIST + PsiElement(internal)('internal') + PsiWhiteSpace(' ') + PsiElement(lateinit)('lateinit') + PsiWhiteSpace(' ') + PsiElement(field)('field') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(var)('var') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('numberWithFieldAndAccessors') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiWhiteSpace('\n ') + BACKING_FIELD + PsiElement(field)('field') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('test') + PsiElement(CLOSING_QUOTE)('"') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(get)('get') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('field') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('length') + PsiWhiteSpace('\n ') + PROPERTY_ACCESSOR + PsiElement(set)('set') + PsiElement(LPAR)('(') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('value') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + BINARY_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('field') + PsiWhiteSpace(' ') + OPERATION_REFERENCE + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('value') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('toString') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('numberWithExplicitType') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiWhiteSpace('\n ') + BACKING_FIELD + PsiElement(field)('field') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('10') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('numberWithBlockInitializer') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Number') + PsiWhiteSpace('\n ') + BACKING_FIELD + PsiElement(field)('field') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('10') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('minimalNumber') + PsiWhiteSpace('\n ') + BACKING_FIELD + PsiElement(field)('field') \ No newline at end of file diff --git a/compiler/tests-gen/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java index 32aa635f7f3..e99472fde4e 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java @@ -1983,6 +1983,24 @@ public class ParsingTestGenerated extends AbstractParsingTest { } } + @TestMetadata("compiler/testData/psi/propertyBackingField") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PropertyBackingField extends AbstractParsingTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doParsingTest, this, testDataFilePath); + } + + public void testAllFilesPresentInPropertyBackingField() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/psi/propertyBackingField"), Pattern.compile("^(.*)\\.kts?$"), null, true); + } + + @TestMetadata("explicitBackingField.kt") + public void testExplicitBackingField() throws Exception { + runTest("compiler/testData/psi/propertyBackingField/explicitBackingField.kt"); + } + } + @TestMetadata("compiler/testData/psi/propertyDelegate") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)