Fix suggested names in Spring (do not take same parameter into account)
This commit is contained in:
+1
-1
@@ -92,7 +92,7 @@ private fun addCreatePropertyTemplate(
|
|||||||
builder.appendVariableTemplate(currentProperty, candidateBeanClasses) {
|
builder.appendVariableTemplate(currentProperty, candidateBeanClasses) {
|
||||||
val existingNames = currentProperty.containingClassOrObject!!.declarations
|
val existingNames = currentProperty.containingClassOrObject!!.declarations
|
||||||
.mapNotNull { if (it != currentProperty) (it as? KtProperty)?.name else null }
|
.mapNotNull { if (it != currentProperty) (it as? KtProperty)?.name else null }
|
||||||
getSuggestedNames(candidateBean, currentProperty, existingNames) { returnType }
|
getSuggestedNames(candidateBean, currentProperty, existingNames = existingNames) { returnType }
|
||||||
}
|
}
|
||||||
builder.buildInlineTemplate()
|
builder.buildInlineTemplate()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,13 +180,14 @@ private fun createSettable(
|
|||||||
internal fun getSuggestedNames(
|
internal fun getSuggestedNames(
|
||||||
beanPointer: SpringBeanPointer<CommonSpringBean>,
|
beanPointer: SpringBeanPointer<CommonSpringBean>,
|
||||||
declaration: KtCallableDeclaration,
|
declaration: KtCallableDeclaration,
|
||||||
|
excludedInValidator: List<KtDeclaration> = listOf(declaration),
|
||||||
existingNames: Collection<String> = emptyList(),
|
existingNames: Collection<String> = emptyList(),
|
||||||
getType: CallableDescriptor.() -> KotlinType?
|
getType: CallableDescriptor.() -> KotlinType?
|
||||||
): Collection<String> {
|
): Collection<String> {
|
||||||
val names = LinkedHashSet<String>()
|
val names = LinkedHashSet<String>()
|
||||||
|
|
||||||
val newDeclarationNameValidator =
|
val newDeclarationNameValidator =
|
||||||
NewDeclarationNameValidator(declaration.parent, null, NewDeclarationNameValidator.Target.VARIABLES, listOf(declaration))
|
NewDeclarationNameValidator(declaration.parent, null, NewDeclarationNameValidator.Target.VARIABLES, excludedInValidator)
|
||||||
fun validate(name: String) = name !in existingNames && newDeclarationNameValidator(name)
|
fun validate(name: String) = name !in existingNames && newDeclarationNameValidator(name)
|
||||||
|
|
||||||
SpringBeanUtils.getInstance()
|
SpringBeanUtils.getInstance()
|
||||||
@@ -252,7 +253,9 @@ private fun BatchTemplateRunner.addCreateFunctionTemplate(
|
|||||||
addTemplateFactory(parameterList) {
|
addTemplateFactory(parameterList) {
|
||||||
for ((paramIndex, candidateBeanClassesForParam) in candidateBeanClasses) {
|
for ((paramIndex, candidateBeanClassesForParam) in candidateBeanClasses) {
|
||||||
builder.appendVariableTemplate(function.valueParameters[paramIndex], candidateBeanClassesForParam) {
|
builder.appendVariableTemplate(function.valueParameters[paramIndex], candidateBeanClassesForParam) {
|
||||||
getSuggestedNames(dependency, function) { valueParameters[paramIndex].type }
|
getSuggestedNames(dependency, function, listOf(function.valueParameters[paramIndex], function)) {
|
||||||
|
valueParameters[paramIndex].type
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user