-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make setter's parameter name
value
by default
per https://kotlinlang.org/docs/properties.html#getters-and-setters KSP1 is left unchanged.
- Loading branch information
Showing
9 changed files
with
287 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
202 changes: 202 additions & 0 deletions
202
kotlin-analysis-api/testData/annotationInDependencies.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// WITH_RUNTIME | ||
// TEST PROCESSOR: AnnotationsInDependenciesProcessor | ||
// EXPECTED: | ||
// main.KotlinClass -> | ||
// class main.KotlinClass : annotations.ClassTarget{[value = onClass]} | ||
// class main.KotlinClass : annotations.NoTargetAnnotation{[value = onClass]} | ||
// function myFun : annotations.FunctionTarget{[value = onMyFun]} | ||
// function myFun : annotations.NoTargetAnnotation{[value = onMyFun]} | ||
// getter of property prop : annotations.PropertyGetterTarget{[value = get:]} | ||
// parameter param1 : annotations.NoTargetAnnotation{[value = onParam1]} | ||
// parameter param1 : annotations.ValueParameterTarget{[value = onParam1]} | ||
// parameter param2 : annotations.NoTargetAnnotation{[value = onParam2]} | ||
// parameter param2 : annotations.ValueParameterTarget{[value = onParam2]} | ||
// parameter value : annotations.ValueParameterTarget{[value = onPropSetter]} | ||
// parameter value : annotations.ValueParameterTarget{[value = onProp]} | ||
// property prop : annotations.FieldTarget2{[value = field:]} | ||
// property prop : annotations.FieldTarget{[value = onProp]} | ||
// property prop : annotations.NoTargetAnnotation{[value = onProp]} | ||
// property prop : annotations.PropertyTarget{[value = onProp]} | ||
// setter of property prop : annotations.PropertySetterTarget{[value = set:]} | ||
// lib.KotlinClass -> | ||
// class lib.KotlinClass : annotations.ClassTarget{[value = onClass]} | ||
// class lib.KotlinClass : annotations.NoTargetAnnotation{[value = onClass]} | ||
// function myFun : annotations.FunctionTarget{[value = onMyFun]} | ||
// function myFun : annotations.NoTargetAnnotation{[value = onMyFun]} | ||
// getter of property prop : annotations.PropertyGetterTarget{[value = get:]} | ||
// parameter param1 : annotations.NoTargetAnnotation{[value = onParam1]} | ||
// parameter param1 : annotations.ValueParameterTarget{[value = onParam1]} | ||
// parameter param2 : annotations.NoTargetAnnotation{[value = onParam2]} | ||
// parameter param2 : annotations.ValueParameterTarget{[value = onParam2]} | ||
// parameter propInConstructor : annotations.ValueParameterTarget{[value = propInConstructor]} | ||
// property prop : annotations.FieldTarget2{[value = field:]} | ||
// property prop : annotations.FieldTarget{[value = onProp]} | ||
// property prop : annotations.NoTargetAnnotation{[value = onProp]} | ||
// property prop : annotations.PropertyTarget{[value = onProp]} | ||
// setter of property prop : annotations.PropertySetterTarget{[value = set:]} | ||
// main.DataClass -> | ||
// class main.DataClass : annotations.ClassTarget{[value = onDataClass]} | ||
// class main.DataClass : annotations.NoTargetAnnotation{[value = onDataClass]} | ||
// getter of property constructorParam : annotations.PropertyGetterTarget{[value = get:]} | ||
// parameter constructorParam : annotations.NoTargetAnnotation{[value = onConstructorParam]} | ||
// parameter constructorParam : annotations.ValueParameterTarget{[value = onConstructorParam]} | ||
// parameter value : annotations.ValueParameterTarget{[value = onConstructorParam]} | ||
// property constructorParam : annotations.FieldTarget2{[value = field:]} | ||
// property constructorParam : annotations.FieldTarget{[value = onConstructorParam]} | ||
// property constructorParam : annotations.NoTargetAnnotation{[value = onConstructorParam]} | ||
// property constructorParam : annotations.PropertyTarget{[value = onConstructorParam]} | ||
// property constructorParam : annotations.ValueParameterAndFieldTarget{[value = valueParameterAndField]} | ||
// setter of property constructorParam : annotations.PropertySetterTarget{[value = set:]} | ||
// lib.DataClass -> | ||
// class lib.DataClass : annotations.ClassTarget{[value = onDataClass]} | ||
// class lib.DataClass : annotations.NoTargetAnnotation{[value = onDataClass]} | ||
// getter of property constructorParam : annotations.PropertyGetterTarget{[value = get:]} | ||
// parameter constructorParam : annotations.NoTargetAnnotation{[value = onConstructorParam]} | ||
// property constructorParam : annotations.FieldTarget2{[value = field:]} | ||
// property constructorParam : annotations.FieldTarget{[value = onConstructorParam]} | ||
// property constructorParam : annotations.PropertyTarget{[value = onConstructorParam]} | ||
// setter of property constructorParam : annotations.PropertySetterTarget{[value = set:]} | ||
// END | ||
// MODULE: annotations | ||
// FILE: Annotations.kt | ||
package annotations; | ||
annotation class NoTargetAnnotation(val value:String) | ||
|
||
@Target(AnnotationTarget.FIELD) | ||
annotation class FieldTarget(val value:String) | ||
|
||
@Target(AnnotationTarget.FIELD) | ||
annotation class FieldTarget2(val value:String) | ||
|
||
@Target(AnnotationTarget.PROPERTY) | ||
annotation class PropertyTarget(val value:String) | ||
|
||
@Target(AnnotationTarget.PROPERTY_SETTER) | ||
annotation class PropertySetterTarget(val value:String) | ||
|
||
@Target(AnnotationTarget.PROPERTY_GETTER) | ||
annotation class PropertyGetterTarget(val value:String) | ||
|
||
@Target(AnnotationTarget.CLASS) | ||
annotation class ClassTarget(val value:String) | ||
|
||
@Target(AnnotationTarget.FUNCTION) | ||
annotation class FunctionTarget(val value:String) | ||
|
||
@Target(AnnotationTarget.VALUE_PARAMETER) | ||
annotation class ValueParameterTarget(val value:String) | ||
|
||
@Target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FIELD) | ||
annotation class ValueParameterAndFieldTarget(val value: String) | ||
|
||
// MODULE: lib(annotations) | ||
// FILE: ClassInLib.kt | ||
package lib; | ||
import annotations.*; | ||
@NoTargetAnnotation("onClass") | ||
@ClassTarget("onClass") | ||
class KotlinClass(@ValueParameterTarget("propInConstructor") val propInConstructor: String ) { | ||
@NoTargetAnnotation("onProp") | ||
@FieldTarget("onProp") | ||
@PropertyTarget("onProp") | ||
@set:PropertySetterTarget("set:") | ||
@get:PropertyGetterTarget("get:") | ||
@field:FieldTarget2("field:") | ||
var prop : String = "" | ||
|
||
@NoTargetAnnotation("onMyFun") | ||
@FunctionTarget("onMyFun") | ||
fun myFun( | ||
@NoTargetAnnotation("onParam1") | ||
@ValueParameterTarget("onParam1") | ||
param1: String, | ||
@NoTargetAnnotation("onParam2") | ||
@ValueParameterTarget("onParam2") | ||
param2: Int | ||
) { | ||
} | ||
} | ||
|
||
@NoTargetAnnotation("onDataClass") | ||
@ClassTarget("onDataClass") | ||
class DataClass( | ||
@NoTargetAnnotation("onConstructorParam") | ||
@FieldTarget("onConstructorParam") | ||
@PropertyTarget("onConstructorParam") | ||
@set:PropertySetterTarget("set:") | ||
@get:PropertyGetterTarget("get:") | ||
@field:FieldTarget2("field:") | ||
var constructorParam : String = "" | ||
) | ||
// FILE: lib/JavaClass.java | ||
package lib; | ||
import annotations.*; | ||
public class JavaClass {} | ||
// MODULE: main(lib, annotations) | ||
// FILE: ClassInModule2.kt | ||
package main; | ||
import annotations.*; | ||
@NoTargetAnnotation("onClass") | ||
@ClassTarget("onClass") | ||
class KotlinClass { | ||
@NoTargetAnnotation("onProp") | ||
@FieldTarget("onProp") | ||
@PropertyTarget("onProp") | ||
@set:PropertySetterTarget("set:") | ||
@get:PropertyGetterTarget("get:") | ||
@field:FieldTarget2("field:") | ||
@setparam:ValueParameterTarget("onProp") | ||
var prop : String = "" | ||
@setparam:ValueParameterTarget("onPropSetter") | ||
set | ||
|
||
@NoTargetAnnotation("onMyFun") | ||
@FunctionTarget("onMyFun") | ||
fun myFun( | ||
@NoTargetAnnotation("onParam1") | ||
@ValueParameterTarget("onParam1") | ||
param1: String, | ||
@NoTargetAnnotation("onParam2") | ||
@ValueParameterTarget("onParam2") | ||
param2: Int | ||
) { | ||
} | ||
} | ||
|
||
@NoTargetAnnotation("onDataClass") | ||
@ClassTarget("onDataClass") | ||
class DataClass( | ||
@NoTargetAnnotation("onConstructorParam") | ||
@FieldTarget("onConstructorParam") | ||
@PropertyTarget("onConstructorParam") | ||
@set:PropertySetterTarget("set:") | ||
@get:PropertyGetterTarget("get:") | ||
@field:FieldTarget2("field:") | ||
@field:ValueParameterAndFieldTarget("valueParameterAndField") | ||
@setparam:ValueParameterTarget("onConstructorParam") | ||
@ValueParameterTarget("onConstructorParam") | ||
var constructorParam : String = "" | ||
) | ||
// FILE: main/JavaClassInModule2.java | ||
pakage main; | ||
import annotations.*; | ||
@NoTargetAnnotation | ||
class JavaClassInMain { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// TEST PROCESSOR: ImplicitPropertyAccessorProcessor | ||
// EXPECTED: | ||
// privateGetterVal.getter(): Int | ||
// privateGetterVar.getter(): String | ||
// privateGetterVar.setter()(value: String) | ||
// val1.getter(): Int | ||
// var2.getter(): String | ||
// var2.setter()(value: String) | ||
// END | ||
// MODULE: lib | ||
// FILE: lib/Bar.kt | ||
package lib | ||
|
||
class Bar { | ||
val val1: Int = 0 | ||
var var2: String = "" | ||
} | ||
// MODULE: main(lib) | ||
// FILE: Foo.kt | ||
|
||
class Foo { | ||
val privateGetterVal: Int | ||
private get | ||
|
||
var privateGetterVar: String | ||
set | ||
private get | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters