Remove 181 bunch files
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
<idea-plugin>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
|
||||
<multiHostInjector implementation="org.jetbrains.kotlin.idea.spring.el.KotlinSpringELInjector"/>
|
||||
|
||||
<codeInsight.lineMarkerProvider language="kotlin" implementationClass="org.jetbrains.kotlin.idea.spring.lineMarking.KotlinSpringModelDependenciesLineMarkerProvider"/>
|
||||
|
||||
<localInspection language="kotlin"
|
||||
displayName="Spring Facet Code Configuration (Kotlin)"
|
||||
groupBundle="resources.messages.SpringBundle"
|
||||
groupKey="inspection.group.setup"
|
||||
groupPath="Spring,Spring Core"
|
||||
enabledByDefault="true"
|
||||
level="WARNING"
|
||||
implementationClass="org.jetbrains.kotlin.idea.spring.inspections.KotlinSpringFacetCodeInspection"/>
|
||||
<localInspection language="kotlin"
|
||||
displayName="Autowired members defined in invalid Spring bean (Kotlin)"
|
||||
groupBundle="resources.messages.SpringBundle"
|
||||
groupKey="inspection.group.code"
|
||||
groupPath="Spring,Spring Core"
|
||||
enabledByDefault="true"
|
||||
level="WARNING"
|
||||
implementationClass="org.jetbrains.kotlin.idea.spring.inspections.SpringKotlinAutowiredMembersInspection"/>
|
||||
<localInspection language="kotlin"
|
||||
displayName="@ComponentScan setup (Kotlin)"
|
||||
groupBundle="resources.messages.SpringBundle"
|
||||
groupKey="inspection.group.code"
|
||||
groupPath="Spring,Spring Core"
|
||||
enabledByDefault="true"
|
||||
level="ERROR"
|
||||
implementationClass="org.jetbrains.kotlin.idea.spring.inspections.KotlinSpringComponentScanInspection"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
<action id="Kotlin.Spring.Beans.Generate.Setter.Dependency.Action"
|
||||
class="org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Setter">
|
||||
<add-to-group anchor="last" group-id="GenerateGroup"/>
|
||||
</action>
|
||||
<action id="Kotlin.Spring.Beans.Generate.Constructor.Dependency.Action"
|
||||
class="org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor">
|
||||
<add-to-group anchor="last" group-id="GenerateGroup"/>
|
||||
</action>
|
||||
<action id="Kotlin.Spring.Beans.Generate.Lateinit.Property.Dependency.Action"
|
||||
class="org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$LateinitProperty">
|
||||
<add-to-group anchor="last" group-id="GenerateGroup"/>
|
||||
</action>
|
||||
|
||||
<action id="Kotlin.Spring.Beans.Generate.Autowired.Dependency.Action"
|
||||
class="org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction">
|
||||
<add-to-group anchor="last" group-id="GenerateGroup"/>
|
||||
</action>
|
||||
</actions>
|
||||
</idea-plugin>
|
||||
@@ -1,10 +0,0 @@
|
||||
<idea-plugin>
|
||||
<depends optional="true" config-file="kotlin-spring.xml">com.intellij.spring</depends>
|
||||
<depends optional="true">com.intellij.javaee</depends>
|
||||
<depends optional="true">com.intellij.persistence</depends>
|
||||
<depends optional="true">com.intellij.database</depends>
|
||||
<depends optional="true">com.intellij.css</depends>
|
||||
<depends optional="true">com.intellij.jsp</depends>
|
||||
<depends optional="true">com.intellij.diagram</depends>
|
||||
<depends optional="true" config-file="kotlin-nodejs.xml">NodeJS</depends>
|
||||
</idea-plugin>
|
||||
-156
@@ -1,156 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring.diagram
|
||||
|
||||
import com.intellij.diagram.DiagramPresentationModel
|
||||
import com.intellij.diagram.presentation.DiagramState
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.ProjectRootManager
|
||||
import com.intellij.openapi.util.component1
|
||||
import com.intellij.openapi.util.component2
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.spring.SpringManager
|
||||
import com.intellij.spring.contexts.model.AbstractSimpleLocalModel
|
||||
import com.intellij.spring.contexts.model.LocalModel
|
||||
import com.intellij.spring.contexts.model.diagram.SpringLocalModelDependenciesDiagramProvider
|
||||
import com.intellij.spring.contexts.model.diagram.SpringLocalModelDiagramNodeContentManager
|
||||
import com.intellij.spring.contexts.model.diagram.SpringLocalModelsDataModel
|
||||
import com.intellij.spring.contexts.model.diagram.beans.*
|
||||
import com.intellij.spring.contexts.model.graph.LazyModelDependenciesGraph
|
||||
import com.intellij.spring.contexts.model.graph.LocalModelDependency
|
||||
import com.intellij.spring.facet.SpringFacet
|
||||
import com.intellij.spring.facet.SpringFileSet
|
||||
import com.intellij.spring.facet.SpringFileSetService
|
||||
import org.jetbrains.kotlin.idea.refactoring.toPsiFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import java.util.*
|
||||
|
||||
// TODO: Drop when SpringLocalModelsDataModel gets support for non-Java/non-XML files
|
||||
class KotlinSpringLocalModelDependenciesDiagramProvider : SpringLocalModelDependenciesDiagramProvider() {
|
||||
inner class KotlinSpringLocalModelsDataModel(
|
||||
project: Project,
|
||||
private val model: LocalModelGraphElementWrapper<*>,
|
||||
private val showModuleFilesetNodes: Boolean
|
||||
) : SpringLocalModelsDataModel(project, this@KotlinSpringLocalModelDependenciesDiagramProvider, model, showModuleFilesetNodes) {
|
||||
private val extraNodes = LinkedHashSet<SpringLocalModelDiagramNode>()
|
||||
private val extraEdges = LinkedHashSet<SpringLocalModelDependencyEdge>()
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
private val nodesSequence: Sequence<SpringLocalModelDiagramNode>
|
||||
get() = (super.getNodes() as Collection<SpringLocalModelDiagramNode>).asSequence() + extraNodes.asSequence()
|
||||
|
||||
private fun getDiagramNode(model: LocalModelGraphElementWrapper<*>): SpringLocalModelDiagramNode {
|
||||
return nodesSequence.firstOrNull { it.identifyingElement == model } ?: SpringLocalModelDiagramNode(model, this.provider)
|
||||
}
|
||||
|
||||
private fun showLibraryConfigs() = DiagramState(builder).isCategoryEnabled(SpringLocalModelDiagramNodeContentManager.SHOW_LIBRARY_CONFIGS)
|
||||
|
||||
private fun isLibraryConfig(element: LocalModelGraphElementWrapper<Any>): Boolean {
|
||||
if (element !is LocalModelWrapper<*>) return false
|
||||
return ProjectRootManager.getInstance(project).fileIndex.isInLibraryClasses(element.element.config.containingFile.virtualFile)
|
||||
}
|
||||
|
||||
private fun visitRelated(fromNode: SpringLocalModelDiagramNode, graph: LazyModelDependenciesGraph) {
|
||||
val localModel = (fromNode.identifyingElement as? LocalModelWrapper<*>)?.element ?: return
|
||||
for ((model, dependency) in graph.getOrCreateOutDependencies(localModel)) {
|
||||
createEdgeToLocalModelAndVisitIt(fromNode, graph, LocalModelWrapper.create(model), dependency)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createEdgeToLocalModelAndVisitIt(
|
||||
fromNode: SpringLocalModelDiagramNode?,
|
||||
graph: LazyModelDependenciesGraph,
|
||||
toNodeLocalModelWrapper: LocalModelWrapper<LocalModel<*>>,
|
||||
dependency: LocalModelDependency
|
||||
) {
|
||||
val toNode = getDiagramNode(toNodeLocalModelWrapper)
|
||||
if (toNode === fromNode) return
|
||||
|
||||
val toNodeExists = toNode in extraNodes
|
||||
if (!toNodeExists) {
|
||||
extraNodes += toNode
|
||||
if (showLibraryConfigs() || !isLibraryConfig(toNode.identifyingElement)) {
|
||||
this.visitRelated(toNode, graph)
|
||||
}
|
||||
}
|
||||
|
||||
if (fromNode != null) {
|
||||
val edge = SpringLocalModelDependencyEdge(fromNode, toNode, dependency)
|
||||
if (toNodeExists) {
|
||||
edge.isError = true
|
||||
}
|
||||
else {
|
||||
fromNode.addChild(toNode)
|
||||
}
|
||||
extraEdges += edge
|
||||
}
|
||||
}
|
||||
|
||||
private fun visitFileSet(node: SpringLocalModelDiagramNode?, fileSet: SpringFileSet) {
|
||||
val springManager = SpringManager.getInstance(project)
|
||||
val module = fileSet.facet.module
|
||||
val profiles = fileSet.activeProfiles
|
||||
val graph = AbstractSimpleLocalModel.getOrCreateLocalModelDependenciesGraph(module, profiles)
|
||||
|
||||
for (filePointer in fileSet.files) {
|
||||
val virtualFile = filePointer.file ?: continue
|
||||
val ktFile = virtualFile.toPsiFile(project) as? KtFile ?: continue
|
||||
for (psiClass in ktFile.classes) {
|
||||
val model = springManager.getLocalSpringModel(psiClass, module) ?: continue
|
||||
createEdgeToLocalModelAndVisitIt(node, graph, LocalModelWrapper.create(model), LocalModelDependency.create())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun visitFileSet(fileSet: SpringFileSet) {
|
||||
visitFileSet(if (showModuleFilesetNodes) getDiagramNode(FilesetLocalModelWrapper.create(fileSet)!!) else null, fileSet)
|
||||
}
|
||||
|
||||
private fun visitModule(module: Module) {
|
||||
if (module.isDisposed) return
|
||||
val springFacet = SpringFacet.getInstance(module) ?: return
|
||||
|
||||
for (fileSet in SpringFileSetService.getInstance().getAllSets(springFacet)) {
|
||||
visitFileSet(fileSet)
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateDataModel() {
|
||||
super.updateDataModel()
|
||||
when (model) {
|
||||
is ModuleLocalModelWrapper -> visitModule(model.element)
|
||||
is FilesetLocalModelWrapper -> visitFileSet(model.element)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getNodes() = nodesSequence.toCollection(LinkedHashSet())
|
||||
override fun getEdges() = super.getEdges() + extraEdges
|
||||
}
|
||||
|
||||
override fun getID() = "KotlinSpringLocalModels"
|
||||
|
||||
override fun createDataModel(
|
||||
project: Project,
|
||||
element: LocalModelGraphElementWrapper<*>?,
|
||||
file: VirtualFile?,
|
||||
presentationModel: DiagramPresentationModel?
|
||||
): SpringLocalModelsDataModel? {
|
||||
if (element == null) return null
|
||||
return KotlinSpringLocalModelsDataModel(project, element, true)
|
||||
}
|
||||
}
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring.diagram
|
||||
|
||||
import com.intellij.diagram.DiagramProvider
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.spring.contexts.model.diagram.actions.OpenSpringModelDependenciesAction
|
||||
import org.jetbrains.kotlin.asJava.toLightClass
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
|
||||
|
||||
class OpenKotlinSpringModelDependenciesAction(klass: KtClass) : OpenSpringModelDependenciesAction() {
|
||||
private val klassPointer = klass.createSmartPointer()
|
||||
|
||||
override fun findInDataContext(provider: DiagramProvider<*>, context: DataContext): Any? {
|
||||
val wrappingContext = DataContext { id ->
|
||||
if (CommonDataKeys.PSI_ELEMENT.`is`(id)) klassPointer.element?.toLightClass() else context.getData(id)
|
||||
}
|
||||
return super.findInDataContext(provider, wrappingContext)
|
||||
}
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring.diagram
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.spring.contexts.model.diagram.actions.OpenSpringModelDependenciesModuleDiagramAction
|
||||
|
||||
// TODO: Drop when SpringLocalModelsDataModel gets support for non-Java/non-XML files
|
||||
class OpenKotlinSpringModelDependenciesModuleDiagramAction : OpenSpringModelDependenciesModuleDiagramAction() {
|
||||
override fun getProvider(e: AnActionEvent) = KotlinSpringLocalModelDependenciesDiagramProvider()
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring.el
|
||||
|
||||
import com.intellij.ide.plugins.PluginManager
|
||||
import com.intellij.lang.injection.MultiHostInjector
|
||||
import com.intellij.lang.injection.MultiHostRegistrar
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiLanguageInjectionHost
|
||||
import com.intellij.psi.impl.source.jsp.el.ELContextProvider
|
||||
import com.intellij.spring.constants.SpringAnnotationsConstants
|
||||
import com.intellij.spring.el.SpringELLanguage
|
||||
import com.intellij.spring.el.SpringElTemplateParser
|
||||
import com.intellij.spring.el.contextProviders.SpringElContextProvider
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.imports.importableFqName
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
|
||||
import org.jetbrains.kotlin.psi.KtValueArgument
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isPlainWithEscapes
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.utils.ifEmpty
|
||||
|
||||
class KotlinSpringELInjector : MultiHostInjector {
|
||||
companion object {
|
||||
private val RELEVANT_ANNOTATIONS = setOf(SpringAnnotationsConstants.VALUE, SpringAnnotationsConstants.SCHEDULED)
|
||||
|
||||
// SpEL support requires both Spring and J2EE plugins
|
||||
// This code works around the inability to specify multiple dependencies for a given plugin config file
|
||||
private val contextRecorder by lazy {
|
||||
if ("com.intellij.javaee" in PluginManager.getDisabledPlugins()) return@lazy null
|
||||
{ host: PsiElement -> host.putUserData(ELContextProvider.ourContextProviderKey, SpringElContextProvider(host)) }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLanguagesToInject(registrar: MultiHostRegistrar, host: PsiElement) {
|
||||
if (host is KtStringTemplateExpression) {
|
||||
if (!host.isPlainWithEscapes()) return
|
||||
|
||||
val argument = host.parent as? KtValueArgument ?: return
|
||||
val entry = argument.getStrictParentOfType<KtAnnotationEntry>() ?: return
|
||||
val context = entry.analyze(BodyResolveMode.PARTIAL)
|
||||
val resolvedCall = entry.getResolvedCall(context) ?: return
|
||||
val annotation = (resolvedCall.resultingDescriptor as? ConstructorDescriptor)?.containingDeclaration ?: return
|
||||
if (annotation.importableFqName?.asString() !in RELEVANT_ANNOTATIONS) return
|
||||
|
||||
val text = host.getText()
|
||||
val ranges = SpringElTemplateParser.parse(text).ifEmpty { return }
|
||||
for (range in ranges) {
|
||||
registrar
|
||||
.startInjecting(SpringELLanguage.INSTANCE)
|
||||
.addPlace(null, null, host as PsiLanguageInjectionHost, range)
|
||||
.doneInjecting()
|
||||
}
|
||||
|
||||
contextRecorder!!(host)
|
||||
}
|
||||
}
|
||||
|
||||
override fun elementsToInjectIn() = contextRecorder?.let { listOf(KtStringTemplateExpression::class.java) } ?: emptyList()
|
||||
}
|
||||
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring.generate
|
||||
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.spring.SpringBundle
|
||||
import org.jetbrains.kotlin.asJava.toLightClass
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
|
||||
class GenerateKotlinAutowiredDependencyAction : GenerateKotlinSpringBeanDependencyAction(
|
||||
SpringBundle.message("action.generate.autowired.dependencies.action.text")
|
||||
) {
|
||||
override fun checkContext(module: Module) = true
|
||||
|
||||
override fun invoke(project: Project, editor: Editor, file: PsiFile) {
|
||||
val klass = getTargetClass(editor, file) as? KtClass ?: return
|
||||
val lightClass = klass.toLightClass() ?: return
|
||||
generateAutowiredDependenciesFor(lightClass).forEach { it.runTemplates() }
|
||||
}
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring.generate
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.spring.model.actions.generate.GenerateSpringBeanDependenciesUtil
|
||||
import icons.SpringApiIcons
|
||||
import org.jetbrains.kotlin.asJava.toLightClass
|
||||
import org.jetbrains.kotlin.idea.actions.generate.KotlinGenerateActionBase
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
|
||||
abstract class GenerateKotlinSpringBeanDependencyAction(text: String) : KotlinGenerateActionBase() {
|
||||
init {
|
||||
templatePresentation.text = text
|
||||
templatePresentation.icon = SpringApiIcons.Spring
|
||||
}
|
||||
|
||||
override fun isValidForClass(targetClass: KtClassOrObject): Boolean {
|
||||
if (targetClass !is KtClass || targetClass.isInterface() || targetClass.isEnum() || targetClass.fqName == null) return false
|
||||
val lightClass = targetClass.toLightClass() ?: return false
|
||||
val module = GenerateSpringBeanDependenciesUtil.getSpringModule(lightClass) ?: return false
|
||||
return checkContext(module)
|
||||
}
|
||||
|
||||
abstract fun checkContext(module: Module): Boolean
|
||||
}
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring.generate
|
||||
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.xml.XmlFile
|
||||
import com.intellij.spring.SpringBundle
|
||||
import com.intellij.spring.SpringManager
|
||||
import com.intellij.spring.model.utils.SpringModelUtils
|
||||
import org.jetbrains.kotlin.asJava.toLightClass
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
|
||||
abstract class GenerateKotlinSpringBeanXmlDependencyAction(
|
||||
text: String,
|
||||
private val injectionKind: SpringDependencyInjectionKind
|
||||
) : GenerateKotlinSpringBeanDependencyAction(text) {
|
||||
class Constructor: GenerateKotlinSpringBeanXmlDependencyAction(
|
||||
SpringBundle.message("action.Spring.Beans.Generate.Constructor.Dependency.Action.text"),
|
||||
SpringDependencyInjectionKind.CONSTRUCTOR
|
||||
)
|
||||
|
||||
class Setter: GenerateKotlinSpringBeanXmlDependencyAction(
|
||||
SpringBundle.message("action.Spring.Beans.Generate.Setter.Dependency.Action.text"),
|
||||
SpringDependencyInjectionKind.SETTER
|
||||
)
|
||||
|
||||
class LateinitProperty: GenerateKotlinSpringBeanXmlDependencyAction(
|
||||
"Spring 'lateinit' Dependency...",
|
||||
SpringDependencyInjectionKind.LATEINIT_PROPERTY
|
||||
)
|
||||
|
||||
override fun checkContext(module: Module): Boolean {
|
||||
return SpringManager.getInstance(module.project).getCombinedModel(module).configFiles.any { it is XmlFile }
|
||||
}
|
||||
|
||||
override fun invoke(project: Project, editor: Editor, file: PsiFile) {
|
||||
val klass = getTargetClass(editor, file) as? KtClass ?: return
|
||||
val lightClass = klass.toLightClass() ?: return
|
||||
val springModel = SpringModelUtils.getInstance().getPsiClassSpringModel(lightClass)
|
||||
val templates = generateDependenciesFor(springModel, lightClass, injectionKind)
|
||||
templates.forEach { it.runTemplates() }
|
||||
}
|
||||
}
|
||||
-126
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring.generate
|
||||
|
||||
import com.intellij.codeInsight.template.TemplateBuilderImpl
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.runWriteAction
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.spring.CommonSpringModel
|
||||
import com.intellij.spring.constants.SpringAnnotationsConstants
|
||||
import com.intellij.spring.model.CommonSpringBean
|
||||
import com.intellij.spring.model.SpringBeanPointer
|
||||
import com.intellij.spring.model.SpringModelSearchParameters
|
||||
import com.intellij.spring.model.actions.generate.GenerateSpringBeanDependenciesUtil
|
||||
import com.intellij.spring.model.utils.SpringModelSearchers
|
||||
import com.intellij.spring.model.utils.SpringModelUtils
|
||||
import com.intellij.util.IncorrectOperationException
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.idea.editor.BatchTemplateRunner
|
||||
import org.jetbrains.kotlin.idea.spring.effectiveBeanClasses
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
||||
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isIdentifier
|
||||
import org.jetbrains.kotlin.utils.ifEmpty
|
||||
|
||||
// TODO: GenerateAutowiredDependenciesUtil.getQualifierName() is not accessible here
|
||||
private fun SpringBeanPointer<CommonSpringBean>.getQualifierName(): String? {
|
||||
val value = springBean.springQualifier?.qualifierValue
|
||||
return if (value.isNullOrBlank()) name else value
|
||||
}
|
||||
|
||||
private fun createAutowiredProperty(
|
||||
currentBeanClass: KtLightClass,
|
||||
candidateBean: SpringBeanPointer<CommonSpringBean>,
|
||||
candidateBeanClasses: Array<out PsiClass>,
|
||||
model: CommonSpringModel
|
||||
): KtProperty? {
|
||||
try {
|
||||
val ktBeanClass = currentBeanClass.kotlinOrigin ?: return null
|
||||
|
||||
val qualifierName = candidateBean.getQualifierName()
|
||||
val candidateBeanClass = candidateBeanClasses.first()
|
||||
val beanName = candidateBean.name
|
||||
val name = if (beanName != null && beanName.isIdentifier()) beanName else candidateBeanClass.name!!
|
||||
|
||||
val psiFactory = KtPsiFactory(currentBeanClass.project)
|
||||
// TODO: Use KtPsiFactory.CallableBuilder
|
||||
val prototype = psiFactory.createProperty("lateinit var ${name.decapitalize()}: ${candidateBeanClass.defaultTypeText}").apply {
|
||||
addAnnotationEntry(psiFactory.createAnnotationEntry("@${SpringAnnotationsConstants.AUTOWIRED}"))
|
||||
|
||||
val searchParameters = SpringModelSearchParameters.byClass(candidateBeanClass).withInheritors().effectiveBeanTypes()
|
||||
if (SpringModelSearchers.findBeans(model, searchParameters).size > 1 && !qualifierName.isNullOrBlank()) {
|
||||
val annotationText = "@${SpringAnnotationsConstants.QUALIFIER}(\"${StringUtil.escapeStringCharacters(qualifierName!!)}\")"
|
||||
addAnnotationEntry(psiFactory.createAnnotationEntry(annotationText))
|
||||
}
|
||||
}
|
||||
return ktBeanClass.addDeclaration(prototype).apply { ShortenReferences.DEFAULT.process(this) }
|
||||
}
|
||||
catch (e: IncorrectOperationException) {
|
||||
throw RuntimeException(e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addCreatePropertyTemplate(
|
||||
property: KtProperty,
|
||||
candidateBean: SpringBeanPointer<CommonSpringBean>,
|
||||
candidateBeanClasses: Array<out PsiClass>
|
||||
): BatchTemplateRunner {
|
||||
return BatchTemplateRunner(property.project).apply {
|
||||
val propertyPointer = property.createSmartPointer()
|
||||
addTemplateFactory(property) {
|
||||
val currentProperty = propertyPointer.element ?: return@addTemplateFactory null
|
||||
val builder = TemplateBuilderImpl(currentProperty)
|
||||
builder.appendVariableTemplate(currentProperty, candidateBeanClasses) {
|
||||
val existingNames = currentProperty.containingClassOrObject!!.declarations
|
||||
.mapNotNull { if (it != currentProperty) (it as? KtProperty)?.name else null }
|
||||
getSuggestedNames(candidateBean, currentProperty, existingNames = existingNames) { returnType }
|
||||
}
|
||||
builder.buildInlineTemplate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createAutowiredDependency(
|
||||
klass: KtLightClass,
|
||||
candidateBean: SpringBeanPointer<CommonSpringBean>,
|
||||
model: CommonSpringModel
|
||||
): BatchTemplateRunner? {
|
||||
val candidateBeanClasses = candidateBean.effectiveBeanClasses().ifEmpty { return null }
|
||||
if (!GenerateSpringBeanDependenciesUtil.ensureFileWritable(klass)) return null
|
||||
return runWriteAction {
|
||||
createAutowiredProperty(klass, candidateBean, candidateBeanClasses, model)?.let { property ->
|
||||
addCreatePropertyTemplate(property, candidateBean, candidateBeanClasses)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun generateAutowiredDependenciesFor(klass: KtLightClass): List<BatchTemplateRunner> {
|
||||
val model = SpringModelUtils.getInstance().getPsiClassSpringModel(klass)
|
||||
val candidates = GenerateSpringBeanDependenciesUtil.getAutowiredBeanCandidates(model) { true }
|
||||
val dependencies = if (ApplicationManager.getApplication().isUnitTestMode) {
|
||||
candidates.map { it.springBean }.filter(klass.project.beanFilter).sortedBy { it.name }
|
||||
}
|
||||
else {
|
||||
GenerateSpringBeanDependenciesUtil.chooseDependentBeans(candidates, klass.project, true)
|
||||
}
|
||||
return dependencies.mapNotNull { createAutowiredDependency(klass, it, model) }
|
||||
}
|
||||
-513
@@ -1,513 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring.generate
|
||||
|
||||
import com.intellij.codeInsight.lookup.LookupElement
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder
|
||||
import com.intellij.codeInsight.template.Expression
|
||||
import com.intellij.codeInsight.template.ExpressionContext
|
||||
import com.intellij.codeInsight.template.TemplateBuilderImpl
|
||||
import com.intellij.codeInsight.template.TextResult
|
||||
import com.intellij.codeInspection.SmartHashMap
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.runWriteAction
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.psi.util.PropertyUtil
|
||||
import com.intellij.psi.util.PsiTypesUtil
|
||||
import com.intellij.spring.CommonSpringModel
|
||||
import com.intellij.spring.model.CommonSpringBean
|
||||
import com.intellij.spring.model.SpringBeanPointer
|
||||
import com.intellij.spring.model.SpringModelSearchParameters
|
||||
import com.intellij.spring.model.actions.generate.GenerateSpringBeanDependenciesUtil
|
||||
import com.intellij.spring.model.actions.generate.GenerateSpringBeanDependenciesUtil.*
|
||||
import com.intellij.spring.model.actions.generate.SpringBeanClassMember
|
||||
import com.intellij.spring.model.highlighting.xml.SpringConstructorArgResolveUtil
|
||||
|
||||
import com.intellij.spring.model.utils.SpringBeanCoreUtils
|
||||
import com.intellij.spring.model.utils.SpringBeanUtils
|
||||
import com.intellij.spring.model.utils.SpringModelSearchers
|
||||
import com.intellij.spring.model.utils.SpringModelUtils
|
||||
import com.intellij.spring.model.xml.DomSpringBean
|
||||
import com.intellij.spring.model.xml.beans.Beans
|
||||
import com.intellij.spring.model.xml.beans.SpringBean
|
||||
import com.intellij.util.IncorrectOperationException
|
||||
import com.intellij.util.xml.DomElement
|
||||
import com.intellij.util.xml.DomUtil
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||
import org.jetbrains.kotlin.asJava.elements.KtLightMethod
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.project.getModuleInfo
|
||||
import org.jetbrains.kotlin.idea.caches.project.forcedModuleInfo
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.*
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaOrKotlinMemberDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.util.getParameterDescriptor
|
||||
import org.jetbrains.kotlin.idea.completion.BasicLookupElementFactory
|
||||
import org.jetbrains.kotlin.idea.completion.InsertHandlerProvider
|
||||
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
|
||||
import org.jetbrains.kotlin.idea.core.NewDeclarationNameValidator
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
import org.jetbrains.kotlin.idea.core.getOrCreateCompanionObject
|
||||
import org.jetbrains.kotlin.idea.editor.BatchTemplateRunner
|
||||
import org.jetbrains.kotlin.idea.spring.beanClass
|
||||
import org.jetbrains.kotlin.idea.spring.effectiveBeanClasses
|
||||
import org.jetbrains.kotlin.idea.util.CallType
|
||||
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
|
||||
import org.jetbrains.kotlin.load.java.propertyNameBySetMethodName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isIdentifier
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.expressions.TypeReconstructionUtil
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import org.jetbrains.kotlin.utils.ifEmpty
|
||||
import java.util.*
|
||||
|
||||
// TODO: GenerateSpringBeanDependenciesUtil.ensureFileWritable() is not accessible here
|
||||
private fun DomElement.ensureFileWritable() = ensureFileWritable(DomUtil.getFile(this).virtualFile, manager.project)
|
||||
|
||||
// TODO: GenerateSpringBeanDependenciesUtil.getReferenceName() is not accessible here
|
||||
private fun getReferencedName(currentBean: SpringBean, bean: SpringBeanPointer<CommonSpringBean>): String? {
|
||||
val model = SpringModelUtils.getInstance().getSpringModel(currentBean)
|
||||
return SpringBeanCoreUtils.getReferencedName(bean, model.allCommonBeans)
|
||||
}
|
||||
|
||||
// TODO: GenerateSpringBeanDependenciesUtil.getExistedSetter() is not accessible here
|
||||
private fun getExistedSetter(currentBeanClass: PsiClass, setterPsiClass: PsiClass): PsiMethod? {
|
||||
val psiClassType = JavaPsiFacade.getInstance(setterPsiClass.project).elementFactory.createType(setterPsiClass)
|
||||
return currentBeanClass.allMethods.firstOrNull {
|
||||
PropertyUtil.isSimplePropertySetter(it) && it.parameterList.parameters.first().type.isAssignableFrom(psiClassType)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: GenerateSpringBeanDependenciesUtil.findConstructor() is not accessible here
|
||||
private fun findConstructor(constructors: Array<PsiMethod>, psiParameterTypes: List<PsiType>): PsiMethod? {
|
||||
return constructors.firstOrNull {
|
||||
val parameters = it.parameterList.parameters
|
||||
if (it.parameterList.parametersCount != psiParameterTypes.size) return@firstOrNull false
|
||||
(psiParameterTypes zip parameters).all { it.first.isAssignableFrom(it.second.type) }
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: GenerateSpringBeanDependenciesUtil.findExistedConstructor() is not accessible here
|
||||
private fun findExistedConstructor(
|
||||
currentBean: SpringBean,
|
||||
currentBeanClass: PsiClass,
|
||||
candidateParameterClasses: Array<out PsiClass>
|
||||
): PsiMethod? {
|
||||
val constructors = SpringConstructorArgResolveUtil.findMatchingMethods(currentBean)
|
||||
for (candidateBeanClass in candidateParameterClasses) {
|
||||
for (constructor in constructors) {
|
||||
val psiParameterTypes = SmartList<PsiType>().apply {
|
||||
constructor.parameterList.parameters.mapTo(this) { it.type }
|
||||
add(PsiTypesUtil.getClassType(candidateBeanClass))
|
||||
}
|
||||
findConstructor(currentBeanClass.constructors, psiParameterTypes)?.let { return it }
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
// TODO: GenerateSpringBeanDependenciesUtil.createSpringBean() is not accessible here
|
||||
private fun createSpringBean(parentBeans: Beans, psiClass: PsiClass): SpringBean? {
|
||||
if (!((parentBeans as DomElement)).ensureFileWritable()) return null
|
||||
|
||||
return parentBeans.addBean().apply {
|
||||
clazz.stringValue = psiClass.qualifiedName
|
||||
id.stringValue = SpringBeanCoreUtils.suggestBeanNames(this).firstOrNull() ?: ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun SpringBean.getFactoryFunctionName(factoryBeanClass: KtClass): String {
|
||||
factoryMethod.stringValue?.let { if (!it.isBlank()) return it }
|
||||
|
||||
val existingNames = factoryBeanClass.declarations.mapNotNull { if (it is KtFunction || it is KtClassOrObject) it.name else null }
|
||||
return KotlinNameSuggester.suggestNameByName("create${beanClass()!!.name}") { it !in existingNames }
|
||||
}
|
||||
|
||||
internal val PsiClass.defaultTypeText: String
|
||||
get() {
|
||||
val qName = qualifiedName ?: return "Any"
|
||||
val typeParameters = typeParameters
|
||||
if (typeParameters.isEmpty()) return qName
|
||||
return TypeReconstructionUtil.getTypeNameAndStarProjectionsString(qName, typeParameters.size)
|
||||
}
|
||||
|
||||
private fun createSettable(
|
||||
candidateBean: SpringBeanPointer<CommonSpringBean>,
|
||||
currentBeanClass: KtLightClass,
|
||||
candidateBeanClasses: Array<out PsiClass>,
|
||||
injectionKind: SpringDependencyInjectionKind
|
||||
): KtNamedDeclaration {
|
||||
val project = currentBeanClass.project
|
||||
val psiFactory = KtPsiFactory(project)
|
||||
val beanName = candidateBean.name
|
||||
try {
|
||||
val candidateClass = candidateBeanClasses.first()
|
||||
val propertyName = if (beanName != null && beanName.isIdentifier()) beanName else candidateClass.name!!
|
||||
|
||||
val prototype: KtNamedDeclaration = when (injectionKind) {
|
||||
SpringDependencyInjectionKind.SETTER -> {
|
||||
psiFactory.createFunction("fun set${propertyName.capitalize()}(${propertyName.decapitalize()}: ${candidateClass.defaultTypeText}) { }")
|
||||
}
|
||||
|
||||
SpringDependencyInjectionKind.LATEINIT_PROPERTY -> {
|
||||
psiFactory.createProperty("lateinit var ${propertyName.decapitalize()}: ${candidateClass.defaultTypeText}")
|
||||
}
|
||||
|
||||
else -> error("Unexpected injection kind: $injectionKind")
|
||||
}
|
||||
return currentBeanClass.kotlinOrigin!!.addDeclaration(prototype).apply { ShortenReferences.DEFAULT.process(this) }
|
||||
}
|
||||
catch (e: IncorrectOperationException) {
|
||||
throw RuntimeException(e)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun getSuggestedNames(
|
||||
beanPointer: SpringBeanPointer<CommonSpringBean>,
|
||||
declaration: KtCallableDeclaration,
|
||||
excludedInValidator: List<KtDeclaration> = listOf(declaration),
|
||||
existingNames: Collection<String> = emptyList(),
|
||||
getType: CallableDescriptor.() -> KotlinType?
|
||||
): Collection<String> {
|
||||
val names = LinkedHashSet<String>()
|
||||
|
||||
val newDeclarationNameValidator =
|
||||
NewDeclarationNameValidator(declaration.parent, null, NewDeclarationNameValidator.Target.VARIABLES, excludedInValidator)
|
||||
fun validate(name: String) = name !in existingNames && newDeclarationNameValidator(name)
|
||||
|
||||
SpringBeanUtils.getInstance()
|
||||
.findBeanNames(beanPointer.springBean)
|
||||
.asSequence()
|
||||
.filter { it.isIdentifier() }
|
||||
.mapTo(names) { KotlinNameSuggester.suggestNameByName(it, ::validate) }
|
||||
|
||||
(declaration.resolveToDescriptor() as CallableDescriptor).getType()?.let {
|
||||
names += KotlinNameSuggester.suggestNamesByType(it, ::validate)
|
||||
}
|
||||
|
||||
return names
|
||||
}
|
||||
|
||||
internal fun TemplateBuilderImpl.appendVariableTemplate(
|
||||
variable: KtCallableDeclaration,
|
||||
candidateBeanClasses: Array<out PsiClass>,
|
||||
computeSuggestions: (() -> Collection<String>)?
|
||||
) {
|
||||
if (computeSuggestions != null) {
|
||||
val suggestedNames = computeSuggestions()
|
||||
val defaultName = variable.name ?: ""
|
||||
val nameExpression = object : Expression() {
|
||||
override fun calculateResult(context: ExpressionContext) = TextResult(defaultName)
|
||||
|
||||
override fun calculateQuickResult(context: ExpressionContext) = calculateResult(context)
|
||||
|
||||
override fun calculateLookupItems(context: ExpressionContext): Array<LookupElement>? {
|
||||
PsiDocumentManager.getInstance(context.project).commitAllDocuments()
|
||||
return suggestedNames.map { LookupElementBuilder.create(it) }.toTypedArray()
|
||||
|
||||
}
|
||||
}
|
||||
replaceElement(variable.nameIdentifier, "names", nameExpression, true)
|
||||
}
|
||||
|
||||
val superTypeVariants = getSuperTypeVariants(candidateBeanClasses)
|
||||
if (superTypeVariants.size > 1) {
|
||||
val lookupFactory = BasicLookupElementFactory(variable.project, InsertHandlerProvider(CallType.TYPE) { emptyList() })
|
||||
val typeReferenceExpression = object : Expression() {
|
||||
override fun calculateResult(context: ExpressionContext) = TextResult(candidateBeanClasses.first().qualifiedName ?: "")
|
||||
|
||||
override fun calculateQuickResult(context: ExpressionContext) = calculateResult(context)
|
||||
|
||||
override fun calculateLookupItems(context: ExpressionContext): Array<LookupElement>? {
|
||||
return superTypeVariants
|
||||
.mapTo(LinkedHashSet()) { lookupFactory.createLookupElementForJavaClass(it, qualifyNestedClasses = true) }
|
||||
.toTypedArray()
|
||||
}
|
||||
}
|
||||
replaceElement(variable.typeReference, "type", typeReferenceExpression, true)
|
||||
}
|
||||
}
|
||||
|
||||
private fun BatchTemplateRunner.addCreateFunctionTemplate(
|
||||
function: KtFunction,
|
||||
candidateBeanClasses: Map<Int, Array<out PsiClass>>,
|
||||
dependency: SpringBeanPointer<CommonSpringBean>
|
||||
) {
|
||||
val parameterList = function.valueParameterList!!
|
||||
val builder = TemplateBuilderImpl(parameterList)
|
||||
addTemplateFactory(parameterList) {
|
||||
for ((paramIndex, candidateBeanClassesForParam) in candidateBeanClasses) {
|
||||
builder.appendVariableTemplate(function.valueParameters[paramIndex], candidateBeanClassesForParam) {
|
||||
getSuggestedNames(dependency, function, listOf(function.valueParameters[paramIndex], function)) {
|
||||
valueParameters[paramIndex].type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
builder.buildInlineTemplate()
|
||||
}
|
||||
}
|
||||
|
||||
private fun BatchTemplateRunner.addCreatePropertyTemplate(property: KtProperty, candidateBeanClasses: Array<out PsiClass>) {
|
||||
val builder = TemplateBuilderImpl(property)
|
||||
addTemplateFactory(property) {
|
||||
builder.appendVariableTemplate(property, candidateBeanClasses, null)
|
||||
builder.buildInlineTemplate()
|
||||
}
|
||||
}
|
||||
|
||||
private fun BatchTemplateRunner.addCreateFunctionTemplate(
|
||||
function: KtFunction,
|
||||
paramIndex: Int,
|
||||
candidateBeanClasses: Array<out PsiClass>,
|
||||
dependency: SpringBeanPointer<CommonSpringBean>
|
||||
) {
|
||||
addCreateFunctionTemplate(function, mapOf(paramIndex to candidateBeanClasses), dependency)
|
||||
}
|
||||
|
||||
private fun getOrCreateSetter(
|
||||
candidateBean: SpringBeanPointer<CommonSpringBean>,
|
||||
currentBeanClass: KtLightClass,
|
||||
candidateBeanClasses: Array<out PsiClass>,
|
||||
templatesHolder: BatchTemplateRunner,
|
||||
injectionKind: SpringDependencyInjectionKind
|
||||
): PsiNamedElement? {
|
||||
for (candidateBeanClass in candidateBeanClasses) {
|
||||
getExistedSetter(currentBeanClass, candidateBeanClass)?.let { return it }
|
||||
}
|
||||
|
||||
if (!ensureFileWritable(currentBeanClass)) return null
|
||||
val settable = createSettable(candidateBean, currentBeanClass, candidateBeanClasses, injectionKind)
|
||||
when (settable) {
|
||||
is KtNamedFunction -> templatesHolder.addCreateFunctionTemplate(settable, 0, candidateBeanClasses, candidateBean)
|
||||
is KtProperty -> templatesHolder.addCreatePropertyTemplate(settable, candidateBeanClasses)
|
||||
}
|
||||
|
||||
return settable
|
||||
}
|
||||
|
||||
private fun createSetterDependency(
|
||||
currentBean: SpringBean,
|
||||
dependency: SpringBeanPointer<CommonSpringBean>,
|
||||
injectionKind: SpringDependencyInjectionKind
|
||||
): BatchTemplateRunner? {
|
||||
val templatesHolder = BatchTemplateRunner(currentBean.manager.project)
|
||||
val currentBeanClass = currentBean.beanClass() as? KtLightClass ?: return null
|
||||
val candidateBeanClasses = dependency.effectiveBeanClasses().ifEmpty { return null }
|
||||
val setter = getOrCreateSetter(dependency, currentBeanClass, candidateBeanClasses, templatesHolder, injectionKind) ?: return null
|
||||
currentBean.addProperty().apply {
|
||||
name.ensureXmlElementExists()
|
||||
name.stringValue = when (setter) {
|
||||
is PsiMethod, is KtFunction -> propertyNameBySetMethodName(Name.identifier(setter.name!!), false)!!.asString()
|
||||
else -> setter.name
|
||||
}
|
||||
refAttr.setStringValue(getReferencedName(currentBean, dependency))
|
||||
}
|
||||
return templatesHolder
|
||||
}
|
||||
|
||||
private fun addConstructorParameter(
|
||||
currentBeanClass: KtLightClass,
|
||||
candidateBeanClass: PsiClass,
|
||||
constructor: KtFunction
|
||||
) {
|
||||
val psiFactory = KtPsiFactory(currentBeanClass)
|
||||
|
||||
val validator = NewDeclarationNameValidator(constructor, null, NewDeclarationNameValidator.Target.VARIABLES)
|
||||
val resolutionFacade = currentBeanClass.kotlinOrigin!!.getResolutionFacade()
|
||||
val defaultType = (candidateBeanClass.getJavaOrKotlinMemberDescriptor(resolutionFacade) as ClassDescriptor).defaultType
|
||||
val name = KotlinNameSuggester.suggestNamesByType(defaultType, validator).first()
|
||||
|
||||
val parameter = psiFactory.createParameter("$name: ${candidateBeanClass.defaultTypeText}")
|
||||
constructor.getValueParameterList()!!.addParameter(parameter).apply { ShortenReferences.DEFAULT.process(this) }
|
||||
}
|
||||
|
||||
private fun findProperConstructorAndAddParameter(
|
||||
currentBean: SpringBean,
|
||||
dependency: SpringBeanPointer<CommonSpringBean>,
|
||||
currentBeanClass: KtLightClass,
|
||||
candidateBeanClass: PsiClass,
|
||||
holder: BatchTemplateRunner
|
||||
): PsiMethod? {
|
||||
val lightConstructor = currentBean.resolvedConstructorArgs.resolvedMethod as? KtLightMethod ?: return null
|
||||
val constructorOrigin = lightConstructor.kotlinOrigin
|
||||
val properConstructor = when (constructorOrigin) {
|
||||
is KtFunction -> constructorOrigin
|
||||
is KtClass -> constructorOrigin.createPrimaryConstructorIfAbsent()
|
||||
else -> return null
|
||||
}
|
||||
addConstructorParameter(currentBeanClass, candidateBeanClass, properConstructor)
|
||||
holder.addCreateFunctionTemplate(properConstructor, properConstructor.getValueParameters().lastIndex, arrayOf(candidateBeanClass), dependency)
|
||||
return lightConstructor
|
||||
}
|
||||
|
||||
private fun createConstructorWithTemplate(
|
||||
currentBean: SpringBean,
|
||||
dependency: SpringBeanPointer<CommonSpringBean>,
|
||||
templatesHolder: BatchTemplateRunner
|
||||
) {
|
||||
val beanClass = currentBean.beanClass() as? KtLightClass ?: return
|
||||
val ktBeanClass = beanClass.kotlinOrigin as? KtClass ?: return
|
||||
|
||||
try {
|
||||
val psiFactory = KtPsiFactory(beanClass)
|
||||
val factoryFunction = when {
|
||||
currentBean.factoryBean.exists() -> {
|
||||
// TODO: Support non-Kotlin factory beans
|
||||
val factoryClass = currentBean.factoryBean.value?.beanClass as? KtLightClass ?: return
|
||||
val ktFactoryClass = factoryClass.kotlinOrigin as? KtClass ?: return
|
||||
val funName = currentBean.getFactoryFunctionName(ktFactoryClass)
|
||||
val funText = "fun $funName(): ${beanClass.defaultTypeText} {\n return null \n}"
|
||||
ktFactoryClass.addDeclaration(psiFactory.createFunction(funText))
|
||||
}
|
||||
currentBean.factoryMethod.exists() -> {
|
||||
val funName = currentBean.getFactoryFunctionName(ktBeanClass)
|
||||
val funText = "@JvmStatic fun $funName(): ${beanClass.defaultTypeText} {\n return null \n}"
|
||||
ktBeanClass.getOrCreateCompanionObject().addDeclaration(psiFactory.createFunction(funText))
|
||||
}
|
||||
else -> {
|
||||
if (ktBeanClass.hasPrimaryConstructor() || ktBeanClass.getSecondaryConstructors().isNotEmpty()) {
|
||||
ktBeanClass.addDeclaration(psiFactory.createSecondaryConstructor("constructor()"))
|
||||
}
|
||||
else {
|
||||
ktBeanClass.createPrimaryConstructorIfAbsent()
|
||||
}
|
||||
}
|
||||
} as KtFunction
|
||||
|
||||
ShortenReferences.DEFAULT.process(factoryFunction)
|
||||
|
||||
val dummyMethod = JavaPsiFacade.getElementFactory(beanClass.project).createMethod("foo", PsiType.VOID)
|
||||
dummyMethod.containingFile.forcedModuleInfo = ktBeanClass.getModuleInfo()
|
||||
SpringConstructorArgResolveUtil.suggestParamsForConstructorArgs(currentBean).forEach { dummyMethod.parameterList.add(it) }
|
||||
|
||||
val parameterList = factoryFunction.valueParameterList!!
|
||||
val indexOffset = parameterList.parameters.size
|
||||
val candidateClassMap = SmartHashMap<Int, Array<PsiClass>>()
|
||||
val resolutionFacade = ktBeanClass.getResolutionFacade()
|
||||
for ((i, psiParam) in dummyMethod.parameterList.parameters.withIndex()) {
|
||||
val descriptor = psiParam.getParameterDescriptor(resolutionFacade)!!
|
||||
val ktParameter = psiFactory.createParameter(
|
||||
"${psiParam.name}: ${IdeDescriptorRenderers.SOURCE_CODE_NOT_NULL_TYPE_APPROXIMATION.renderType(descriptor.type)}"
|
||||
)
|
||||
parameterList.addParameter(ktParameter)
|
||||
(psiParam.type as? PsiClassType)?.resolve()?.let { candidateClassMap[i + indexOffset] = arrayOf(it) }
|
||||
}
|
||||
|
||||
templatesHolder.addCreateFunctionTemplate(factoryFunction, candidateClassMap, dependency)
|
||||
}
|
||||
catch (e: IncorrectOperationException) {
|
||||
throw RuntimeException(e)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createConstructorDependency(
|
||||
currentBean: SpringBean,
|
||||
dependency: SpringBeanPointer<CommonSpringBean>
|
||||
): BatchTemplateRunner? {
|
||||
val templatesHolder = BatchTemplateRunner(currentBean.manager.project)
|
||||
val currentBeanClass = currentBean.beanClass() as? KtLightClass ?: return null
|
||||
val candidateBeanClasses = dependency.effectiveBeanClasses().ifEmpty { return null }
|
||||
var existedConstructor = findExistedConstructor(currentBean, currentBeanClass, candidateBeanClasses)
|
||||
if (existedConstructor == null) {
|
||||
if (!ensureFileWritable(currentBeanClass)) return null
|
||||
existedConstructor = findProperConstructorAndAddParameter(currentBean, dependency, currentBeanClass, candidateBeanClasses.first(), templatesHolder)
|
||||
}
|
||||
|
||||
val newConstructorArg = currentBean.addConstructorArg()
|
||||
newConstructorArg.refAttr.stringValue = getReferencedName(currentBean, dependency)
|
||||
if (existedConstructor == null && SpringConstructorArgResolveUtil.findMatchingMethods(currentBean).isEmpty()) {
|
||||
createConstructorWithTemplate(currentBean, dependency, templatesHolder)
|
||||
}
|
||||
|
||||
return templatesHolder
|
||||
}
|
||||
|
||||
private fun generateDependency(
|
||||
springBean: SpringBean,
|
||||
dependency: SpringBeanPointer<CommonSpringBean>,
|
||||
injectionKind: SpringDependencyInjectionKind
|
||||
): BatchTemplateRunner? {
|
||||
return runWriteAction {
|
||||
if (injectionKind.isSetter) {
|
||||
createSetterDependency(springBean, dependency, injectionKind)
|
||||
}
|
||||
else {
|
||||
createConstructorDependency(springBean, dependency)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class SpringDependencyInjectionKind(val isSetter: Boolean) {
|
||||
CONSTRUCTOR(false),
|
||||
SETTER(true),
|
||||
LATEINIT_PROPERTY(true)
|
||||
}
|
||||
|
||||
@set:TestOnly
|
||||
var Project.beanFilter: (SpringBeanPointer<CommonSpringBean>) -> Boolean
|
||||
by NotNullableUserDataProperty(Key.create("BEAN_CHOOSER")) { true }
|
||||
|
||||
@NotNull
|
||||
private fun chooseDependentBeans(
|
||||
candidates: Set<SpringBeanClassMember>,
|
||||
project: Project,
|
||||
isSetterDependency: Boolean
|
||||
): List<SpringBeanPointer<CommonSpringBean>> {
|
||||
return if (ApplicationManager.getApplication().isUnitTestMode) {
|
||||
candidates.map { it.springBean }.filter(project.beanFilter)
|
||||
}
|
||||
else {
|
||||
GenerateSpringBeanDependenciesUtil.chooseDependentBeans(candidates, project, isSetterDependency)
|
||||
}
|
||||
}
|
||||
|
||||
fun generateDependenciesFor(
|
||||
springModel: CommonSpringModel,
|
||||
klass: KtLightClass,
|
||||
injectionKind: SpringDependencyInjectionKind
|
||||
): List<BatchTemplateRunner> {
|
||||
val project = klass.project
|
||||
val isSetter = injectionKind.isSetter
|
||||
|
||||
SpringModelSearchers
|
||||
.findBeans(springModel, SpringModelSearchParameters.byClass(klass))
|
||||
.asSequence()
|
||||
.map { it.springBean }
|
||||
.filterIsInstance<SpringBean>()
|
||||
.firstOrNull { acceptBean(it, false) }
|
||||
?.let { springBean ->
|
||||
if (!springBean.ensureFileWritable()) return emptyList()
|
||||
if (springBean.beanClass() == null) return emptyList()
|
||||
val dependencies = chooseDependentBeans(getCandidates(springBean, isSetter), project, isSetter)
|
||||
return dependencies.mapNotNull { generateDependency(springBean, it, injectionKind) }
|
||||
}
|
||||
|
||||
val dependencies = chooseDependentBeans(getCandidates(springModel, klass, isSetter), project, isSetter)
|
||||
val beanXml = dependencies.singleOrNull()?.springBean as? DomSpringBean ?: return emptyList()
|
||||
val beansXml = beanXml.getParentOfType(Beans::class.java, false) ?: return emptyList()
|
||||
val newBean = createSpringBean(beansXml, klass) ?: return emptyList()
|
||||
|
||||
return dependencies.mapNotNull { generateDependency(newBean, it, injectionKind) }
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
package org.jetbrains.kotlin.idea.spring.inspections
|
||||
|
||||
import com.intellij.codeInspection.ProblemHighlightType
|
||||
import com.intellij.codeInspection.ProblemsHolder
|
||||
import com.intellij.jam.NonPhysicalReferenceWrapper
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.psi.PsiReference
|
||||
import com.intellij.psi.impl.source.resolve.reference.impl.providers.PsiPackageReference
|
||||
import com.intellij.spring.model.jam.stereotype.SpringComponentScan
|
||||
import com.intellij.spring.model.jam.utils.SpringJamUtils
|
||||
import org.jetbrains.kotlin.asJava.elements.KtLightAnnotationForSourceEntry
|
||||
import org.jetbrains.kotlin.asJava.toLightClass
|
||||
import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtStringTemplateEntry
|
||||
import org.jetbrains.kotlin.psi.KtTreeVisitorVoid
|
||||
import org.jetbrains.kotlin.psi.KtVisitorVoid
|
||||
|
||||
class KotlinSpringComponentScanInspection : AbstractKotlinInspection() {
|
||||
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
|
||||
return object: KtVisitorVoid() {
|
||||
override fun visitClassOrObject(classOrObject: KtClassOrObject) {
|
||||
val lightClass = classOrObject.toLightClass() ?: return
|
||||
val beansPackagesScan = SpringJamUtils.getInstance().getBeansPackagesScan(lightClass)
|
||||
.filterIsInstance<SpringComponentScan>()
|
||||
val kotlinAnnotations = beansPackagesScan
|
||||
.mapNotNull { (it.annotation as? KtLightAnnotationForSourceEntry)?.kotlinOrigin }
|
||||
if (kotlinAnnotations.isEmpty()) return
|
||||
val literalVisitor = PsiPackageReferenceChecker(holder)
|
||||
for (kotlinAnnotation in kotlinAnnotations) {
|
||||
kotlinAnnotation.accept(literalVisitor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PsiPackageReferenceChecker(private val holder: ProblemsHolder) : KtTreeVisitorVoid() {
|
||||
override fun visitStringTemplateEntry(entry: KtStringTemplateEntry) {
|
||||
for (reference in entry.references) {
|
||||
val packageReference = psiPackageReference(reference) ?: continue
|
||||
if (packageReference.multiResolve(false).isEmpty()) {
|
||||
holder.registerProblem(reference, //registering on physical reference
|
||||
ProblemsHolder.unresolvedReferenceMessage(packageReference), //but getting message from logical reference
|
||||
ProblemHighlightType.LIKE_UNKNOWN_SYMBOL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun psiPackageReference(reference: PsiReference): PsiPackageReference? = when (reference) {
|
||||
is PsiPackageReference -> reference
|
||||
is NonPhysicalReferenceWrapper -> psiPackageReference(reference.wrappedReference)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring.inspections
|
||||
|
||||
import com.intellij.codeInspection.ProblemsHolder
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.spring.model.highlighting.config.SpringFacetCodeInspection
|
||||
import org.jetbrains.kotlin.asJava.toLightClass
|
||||
import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection
|
||||
import org.jetbrains.kotlin.idea.inspections.registerWithElementsUnwrapped
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtVisitorVoid
|
||||
|
||||
class KotlinSpringFacetCodeInspection : AbstractKotlinInspection() {
|
||||
private val javaInspection by lazy { SpringFacetCodeInspection() }
|
||||
|
||||
override fun getDisplayName() = "Spring Facet Code Configuration (Kotlin)"
|
||||
|
||||
override fun getGroupDisplayName() = "Code"
|
||||
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
|
||||
return object: KtVisitorVoid() {
|
||||
override fun visitClassOrObject(classOrObject: KtClassOrObject) {
|
||||
val lightClass = classOrObject.toLightClass() ?: return
|
||||
javaInspection.checkClass(lightClass, holder.manager, isOnTheFly)?.registerWithElementsUnwrapped(holder, isOnTheFly)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring.inspections
|
||||
|
||||
import com.intellij.codeInspection.ProblemsHolder
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.spring.model.highlighting.autowire.SpringJavaAutowiredMembersInspection
|
||||
|
||||
import org.jetbrains.kotlin.asJava.toLightClass
|
||||
import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection
|
||||
import org.jetbrains.kotlin.idea.inspections.registerWithElementsUnwrapped
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtVisitorVoid
|
||||
|
||||
class SpringKotlinAutowiredMembersInspection : AbstractKotlinInspection() {
|
||||
private val javaInspection by lazy { SpringJavaAutowiredMembersInspection() }
|
||||
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
|
||||
return object: KtVisitorVoid() {
|
||||
override fun visitClassOrObject(classOrObject: KtClassOrObject) {
|
||||
val lightClass = classOrObject.toLightClass() ?: return
|
||||
javaInspection.checkClass(lightClass, holder.manager, isOnTheFly)?.registerWithElementsUnwrapped(holder, isOnTheFly)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-83
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring.lineMarking
|
||||
|
||||
import com.intellij.codeHighlighting.Pass
|
||||
import com.intellij.codeInsight.daemon.GutterIconNavigationHandler
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup
|
||||
import com.intellij.openapi.actionSystem.impl.SimpleDataContext
|
||||
import com.intellij.openapi.editor.markup.GutterIconRenderer
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.spring.SpringBundle
|
||||
import com.intellij.spring.SpringManager
|
||||
import com.intellij.spring.contexts.model.diagram.gutter.ModelDependenciesLineMarkerProviderJava
|
||||
import com.intellij.spring.model.jam.stereotype.SpringConfiguration
|
||||
import com.intellij.spring.model.utils.SpringCommonUtils
|
||||
import com.intellij.ui.awt.RelativePoint
|
||||
import com.intellij.util.Function
|
||||
import icons.SpringCoreIcons
|
||||
import org.jetbrains.kotlin.asJava.toLightClass
|
||||
import org.jetbrains.kotlin.idea.spring.diagram.OpenKotlinSpringModelDependenciesAction
|
||||
import org.jetbrains.kotlin.idea.spring.diagram.OpenKotlinSpringModelDependenciesModuleDiagramAction
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch
|
||||
|
||||
class KotlinSpringModelDependenciesLineMarkerProvider : ModelDependenciesLineMarkerProviderJava() {
|
||||
override fun getId() = javaClass.name
|
||||
|
||||
override fun getName() = "Model Dependencies Graph (Kotlin)"
|
||||
|
||||
override fun isRelevantPsiElement(psiElement: PsiElement): Boolean {
|
||||
val lightClass = psiElement.getParentOfTypeAndBranch<KtClass> { nameIdentifier }?.toLightClass() ?: return false
|
||||
return SpringConfiguration.PSI_CLASS_PATTERN.accepts(lightClass) && SpringCommonUtils.isConfigurationOrMeta(lightClass)
|
||||
}
|
||||
|
||||
override fun doAnnotate(element: PsiElement): LineMarkerInfo<*>? {
|
||||
val klass = element.getParentOfTypeAndBranch<KtClass> { nameIdentifier } ?: return null
|
||||
val lightClass = klass.toLightClass() ?: return null
|
||||
if (SpringManager.getInstance(element.project).getLocalSpringModel(lightClass) == null) return null
|
||||
return createLineMarkerInfo(klass)
|
||||
}
|
||||
|
||||
private fun createLineMarkerInfo(klass: KtClass): LineMarkerInfo<PsiElement>? {
|
||||
val nameIdentifier = klass.nameIdentifier ?: return null
|
||||
return LineMarkerInfo(
|
||||
nameIdentifier,
|
||||
nameIdentifier.textRange,
|
||||
SpringCoreIcons.SpringModelsDependencyGraph,
|
||||
Pass.UPDATE_ALL,
|
||||
Function { SpringBundle.message("local.model.dependencies.diagram.title") },
|
||||
createNavigationHandler(klass),
|
||||
GutterIconRenderer.Alignment.RIGHT
|
||||
)
|
||||
}
|
||||
|
||||
private fun createNavigationHandler(klass: KtClass): GutterIconNavigationHandler<PsiElement> {
|
||||
return GutterIconNavigationHandler { event, element ->
|
||||
val group = DefaultActionGroup().apply {
|
||||
add(OpenKotlinSpringModelDependenciesModuleDiagramAction())
|
||||
add(OpenKotlinSpringModelDependenciesAction(klass))
|
||||
}
|
||||
val context = SimpleDataContext.getProjectContext(null)
|
||||
JBPopupFactory.getInstance()
|
||||
.createActionGroupPopup(null, group, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true)
|
||||
.show(RelativePoint(event))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.spring
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil
|
||||
import com.intellij.openapi.module.ModuleUtilCore
|
||||
import com.intellij.psi.PsiClassType
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiModifierListOwner
|
||||
import com.intellij.spring.CommonSpringModel
|
||||
import com.intellij.spring.model.CommonSpringBean
|
||||
import com.intellij.spring.model.SpringBeanPointer
|
||||
import com.intellij.spring.model.jam.utils.JamAnnotationTypeUtil
|
||||
import com.intellij.spring.model.utils.SpringModelUtils
|
||||
|
||||
internal fun PsiModifierListOwner.isAnnotatedWith(annotationFqName: String): Boolean {
|
||||
val module = ModuleUtilCore.findModuleForPsiElement(this) ?: return false
|
||||
return JamAnnotationTypeUtil.getInstance(module)
|
||||
.getAnnotationTypesWithChildren(annotationFqName)
|
||||
.mapNotNull { it.qualifiedName }
|
||||
.any { AnnotationUtil.isAnnotated(this, it, true) }
|
||||
}
|
||||
|
||||
internal val PsiElement.springModel: CommonSpringModel?
|
||||
get() = SpringModelUtils.getInstance().getSpringModel(this)
|
||||
|
||||
internal fun CommonSpringBean.beanClass() = (beanType as? PsiClassType)?.resolve()
|
||||
|
||||
internal fun SpringBeanPointer<*>.effectiveBeanClasses() = effectiveBeanTypes.mapNotNull { (it as? PsiClassType)?.resolve() }.toTypedArray()
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.spring.inspections.SpringKotlinAutowiredMembersInspection
|
||||
// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension
|
||||
@@ -1,60 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
import org.springframework.context.annotation.Configuration
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
open class AmbiguousConstructors
|
||||
|
||||
// Not reported if there is only one constructor
|
||||
|
||||
@Component
|
||||
open class SingleConstructor1(n: Int)
|
||||
|
||||
@Component
|
||||
open class SingleConstructor2 {
|
||||
constructor(n: Int)
|
||||
}
|
||||
|
||||
// Not reported if no-arg constructor is present
|
||||
|
||||
@Component
|
||||
open class NoArgConstructor1() {
|
||||
constructor(n: Int): this()
|
||||
constructor(s: String): this()
|
||||
}
|
||||
|
||||
@Component
|
||||
open class NoArgConstructor2 {
|
||||
constructor()
|
||||
constructor(n: Int)
|
||||
constructor(s: String)
|
||||
}
|
||||
|
||||
// Not reported if @Autowired constructor is present
|
||||
@Component
|
||||
open class AutowiredConstructor1 {
|
||||
@Autowired constructor(n: Int)
|
||||
constructor(s: String)
|
||||
}
|
||||
|
||||
@Component
|
||||
open class AutowiredConstructor2 @Autowired constructor(n: Int) {
|
||||
constructor(s: String): this(0)
|
||||
}
|
||||
|
||||
// Reported
|
||||
|
||||
@Component
|
||||
open class AmbigiousConstructor1 {
|
||||
constructor(n: Int)
|
||||
constructor(s: String)
|
||||
}
|
||||
|
||||
@Component
|
||||
open class AmbigiousConstructor2(n: Int) {
|
||||
constructor(s: String): this(0)
|
||||
}
|
||||
-97
@@ -1,97 +0,0 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>ambiguousConstructors.kt</file>
|
||||
<line>52</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/ambiguousConstructors/ambiguousConstructors.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description>Class doesn't contain matching constructor for autowiring</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>ambiguousConstructors.kt</file>
|
||||
<line>58</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/ambiguousConstructors/ambiguousConstructors.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description>Class doesn't contain matching constructor for autowiring</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>multipleAutowiredConstructors.kt</file>
|
||||
<line>30</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/multipleAutowiredConstructors/multipleAutowiredConstructors.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description>Only one constructor can have @Autowired annotation</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>multipleAutowiredConstructors.kt</file>
|
||||
<line>31</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/multipleAutowiredConstructors/multipleAutowiredConstructors.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description>Only one constructor can have @Autowired annotation</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>multipleAutowiredConstructors.kt</file>
|
||||
<line>35</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/multipleAutowiredConstructors/multipleAutowiredConstructors.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description>Only one constructor can have @Autowired annotation</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>multipleAutowiredConstructors.kt</file>
|
||||
<line>36</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/multipleAutowiredConstructors/multipleAutowiredConstructors.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description>Only one constructor can have @Autowired annotation</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>invalidAutowiredResource.kt</file>
|
||||
<line>24</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/mismatchedType/mismatchedType.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description>Could not autowire. Bean should be of 'invalidAutowiredResource.BarBean' type</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>invalidAutowiredResource.kt</file>
|
||||
<line>31</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/invalidAutowiredResource/invalidAutowiredResource.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description>Cannot resolve bean 'fooBeannn'</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>invalidAutowiredQualifier.kt</file>
|
||||
<line>23</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/invalidAutowiredQualifier/invalidAutowiredQualifier.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description>Could not autowire. Qualified bean must be of 'BarBean' type.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>invalidAutowiredQualifier.kt</file>
|
||||
<line>30</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/invalidAutowiredQualifier/invalidAutowiredQualifier.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description>Cannot find bean with qualifier 'fooBeannn'</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>invalidAutowiredQualifier.kt</file>
|
||||
<line>37</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/invalidAutowiredQualifier/invalidAutowiredQualifier.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description>Cannot find bean qualified with @Qualifier</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>invalidAutowiredByType.kt</file>
|
||||
<line>23</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/invalidAutowiredByType/invalidAutowiredByType.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description>Could not autowire. No beans of 'String' type found.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>invalidAutowiredByType.kt</file>
|
||||
<line>29</line>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/invalidAutowiredByType/invalidAutowiredByType.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Autowiring for Bean Class (Kotlin)</problem_class>
|
||||
<description><html><table><tr><td>Could not autowire. There is more than one bean of 'AbstractBarBean' type.</td></tr><tr><td><table><tr><td valign='top'>Beans:</td><td>abstractBarBean&nbsp;&nbsp; (invalidAutowiredByType.kt)<br>barBean1&nbsp;&nbsp; (invalidAutowiredByType.kt)<br>barBean2&nbsp;&nbsp; (invalidAutowiredByType.kt)<br></td></tr></table></td></tr></table></html></description>
|
||||
</problem>
|
||||
</problems>
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
import org.springframework.context.annotation.Configuration
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
open class MultipleAutowiredConstructors
|
||||
|
||||
// Not reported if required == false
|
||||
|
||||
@Component
|
||||
open class NonRequiredAutowired1 {
|
||||
@Autowired(required = false) constructor(n: Int)
|
||||
@Autowired constructor(s: String)
|
||||
}
|
||||
|
||||
@Component
|
||||
open class NonRequiredAutowired2 @Autowired(required = false) constructor(n: Int) {
|
||||
@Autowired constructor(s: String): this(0)
|
||||
}
|
||||
|
||||
// Reported
|
||||
|
||||
@Component
|
||||
open class BothAutowired1 {
|
||||
@Autowired constructor(n: Int)
|
||||
@Autowired constructor(s: String)
|
||||
}
|
||||
|
||||
@Component
|
||||
open class BothAutowired2 @Autowired constructor(n: Int) {
|
||||
@Autowired constructor(s: String): this(0)
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>14</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@ComponentScan setup (Kotlin)</problem_class>
|
||||
<description>Cannot resolve package bar</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>test.kt</file>
|
||||
<line>18</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@ComponentScan setup (Kotlin)</problem_class>
|
||||
<description>Cannot resolve package bar</description>
|
||||
</problem>
|
||||
</problems>
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.spring.inspections.KotlinSpringComponentScanInspection
|
||||
// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension
|
||||
// CONFIGURE_SPRING_FILE_SET
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.spring.inspections.KotlinSpringFacetCodeInspection
|
||||
// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension
|
||||
// FORBID_SPRING_FILE_SET_AUTOCONFIGURE
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
|
||||
@Component
|
||||
open class FooBean {
|
||||
@Autowired lateinit var bean: BarBean<caret>
|
||||
}
|
||||
|
||||
@Component
|
||||
open class BarBean
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
open class Application
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
|
||||
@Component
|
||||
open class FooBean {
|
||||
@Autowired lateinit var bean: BarBean
|
||||
@Autowired
|
||||
lateinit var barBean<caret>: BarBean
|
||||
}
|
||||
|
||||
@Component
|
||||
open class BarBean
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
open class Application
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CONFIG_FILE: spring-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
|
||||
open class FooBean {
|
||||
@Autowired lateinit var bean: BarBean<caret>
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CONFIG_FILE: spring-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
|
||||
open class FooBean {
|
||||
@Autowired lateinit var bean: BarBean
|
||||
@Autowired
|
||||
lateinit var barBean<caret>: BarBean
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CHOOSE_BEAN: barBean, application
|
||||
package a
|
||||
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
|
||||
@Component
|
||||
open class FooBean {
|
||||
<caret>
|
||||
}
|
||||
|
||||
@Component
|
||||
open class BarBean
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
open class Application
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CHOOSE_BEAN: barBean, application
|
||||
package a
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
|
||||
@Component
|
||||
open class FooBean {
|
||||
@Autowired
|
||||
lateinit var application: Application
|
||||
@Autowired
|
||||
lateinit var barBean<caret>: BarBean
|
||||
|
||||
}
|
||||
|
||||
@Component
|
||||
open class BarBean
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
open class Application
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CONFIG_FILE: spring-config.xml
|
||||
// CHOOSE_BEAN: barBean, fooBean
|
||||
package a
|
||||
|
||||
open class FooBean {
|
||||
<caret>
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CONFIG_FILE: spring-config.xml
|
||||
// CHOOSE_BEAN: barBean, fooBean
|
||||
package a
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
|
||||
open class FooBean {
|
||||
@Autowired
|
||||
lateinit var barBean: BarBean
|
||||
@Autowired
|
||||
lateinit var fooBean<caret>: FooBean
|
||||
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
|
||||
@Component
|
||||
open class FooBean {
|
||||
<caret>
|
||||
}
|
||||
|
||||
@Component
|
||||
open class BarBean
|
||||
|
||||
@Component
|
||||
open class BarBeanChild : BarBean()
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
open class Application
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.beans.factory.annotation.Qualifier
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
|
||||
@Component
|
||||
open class FooBean {
|
||||
@Qualifier("barBean")
|
||||
@Autowired
|
||||
lateinit var barBean<caret>: BarBean
|
||||
|
||||
}
|
||||
|
||||
@Component
|
||||
open class BarBean
|
||||
|
||||
@Component
|
||||
open class BarBeanChild : BarBean()
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
open class Application
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CONFIG_FILE: spring-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean {
|
||||
<caret>
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
|
||||
open class BarBeanChild : BarBean()
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CONFIG_FILE: spring-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.beans.factory.annotation.Qualifier
|
||||
|
||||
open class FooBean {
|
||||
@Qualifier("barBean")
|
||||
@Autowired
|
||||
lateinit var barBean<caret>: BarBean
|
||||
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
|
||||
open class BarBeanChild : BarBean()
|
||||
Vendored
-19
@@ -1,19 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
|
||||
@Component
|
||||
open class FooBean {
|
||||
<caret>
|
||||
}
|
||||
|
||||
@Component
|
||||
open class BarBean
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
open class Application
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Component
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
|
||||
@Component
|
||||
open class FooBean {
|
||||
@Autowired
|
||||
lateinit var barBean<caret>: BarBean
|
||||
|
||||
}
|
||||
|
||||
@Component
|
||||
open class BarBean
|
||||
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
open class Application
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CONFIG_FILE: spring-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean {
|
||||
<caret>
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinAutowiredDependencyAction
|
||||
// CONFIG_FILE: spring-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
|
||||
open class FooBean {
|
||||
@Autowired
|
||||
lateinit var barBean<caret>: BarBean
|
||||
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean"/>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
<bean id="barBeanChild" class="a.BarBeanChild"/>
|
||||
</beans>
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean" factory-bean="fooFactoryBean" factory-method="create"/>
|
||||
<bean id="fooFactoryBean" class="a.FooFactoryBean"/>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
</beans>
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean" factory-bean="fooFactoryBean" factory-method="create">
|
||||
<constructor-arg ref="barBean"/>
|
||||
</bean>
|
||||
<bean id="fooFactoryBean" class="a.FooFactoryBean"/>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
</beans>
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor
|
||||
// CONFIG_FILE: factoryMethod-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean {<caret>
|
||||
}
|
||||
|
||||
open class FooFactoryBean {
|
||||
open fun create(barBean: BarBean) = FooBean()
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor
|
||||
// CONFIG_FILE: factoryMethod-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean {<caret>
|
||||
}
|
||||
|
||||
open class FooFactoryBean {
|
||||
open fun create() = FooBean()
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean" factory-method="create" />
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
</beans>
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean" factory-method="create">
|
||||
<constructor-arg ref="barBean"/>
|
||||
</bean>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
</beans>
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor
|
||||
// CONFIG_FILE: factoryMethod-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean {
|
||||
companion object {
|
||||
@JvmStatic fun create(barBean: BarBean): FooBean {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor
|
||||
// CONFIG_FILE: factoryMethod-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean {<caret>
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean"/>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
</beans>
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean">
|
||||
<constructor-arg ref="barBean"/>
|
||||
</bean>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
</beans>
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor
|
||||
// CONFIG_FILE: firstConstructor-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean {<caret>
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor
|
||||
// CONFIG_FILE: firstConstructor-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean(barBean: BarBean) {
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean">
|
||||
<constructor-arg ref="barBean"/>
|
||||
</bean>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
<bean id="bazBean" class="a.BazBean"/>
|
||||
</beans>
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean">
|
||||
<constructor-arg ref="barBean"/>
|
||||
<constructor-arg ref="bazBean"/>
|
||||
</bean>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
<bean id="bazBean" class="a.BazBean"/>
|
||||
</beans>
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor
|
||||
// CONFIG_FILE: primaryConstructorAddParam-config.xml
|
||||
// CHOOSE_BEAN: bazBean
|
||||
package a
|
||||
|
||||
open class FooBean(barBean: BarBean) {<caret>
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
|
||||
open class BazBean
|
||||
ultimate/testData/spring/core/generate/beanDependenciesByXml/primaryConstructorAddParam.kt.after.181
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor
|
||||
// CONFIG_FILE: primaryConstructorAddParam-config.xml
|
||||
// CHOOSE_BEAN: bazBean
|
||||
package a
|
||||
|
||||
open class FooBean(barBean: BarBean, bazBean: BazBean) {
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
|
||||
open class BazBean
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean"/>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
</beans>
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean">
|
||||
<property name="barBean" ref="barBean"/>
|
||||
</bean>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
</beans>
|
||||
@@ -1,9 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$LateinitProperty
|
||||
// CONFIG_FILE: property-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean {<caret>
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$LateinitProperty
|
||||
// CONFIG_FILE: property-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean {
|
||||
lateinit var barBean: BarBean
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean"/>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
</beans>
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean"/>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
</beans>
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor
|
||||
// CONFIG_FILE: secondaryConstructor-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean(n: Int) {
|
||||
<caret>
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor
|
||||
// CONFIG_FILE: secondaryConstructor-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean(n: Int) {<caret>
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean">
|
||||
<constructor-arg ref="barBean"/>
|
||||
</bean>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
<bean id="bazBean" class="a.BazBean"/>
|
||||
</beans>
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean">
|
||||
<constructor-arg ref="barBean"/>
|
||||
<constructor-arg ref="bazBean"/>
|
||||
</bean>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
<bean id="bazBean" class="a.BazBean"/>
|
||||
</beans>
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor
|
||||
// CONFIG_FILE: secondaryConstructorAddParam-config.xml
|
||||
// CHOOSE_BEAN: bazBean
|
||||
package a
|
||||
|
||||
open class FooBean(n: Int) {
|
||||
constructor(barBean: BarBean): this(1)<caret>
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
|
||||
open class BazBean
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Constructor
|
||||
// CONFIG_FILE: secondaryConstructorAddParam-config.xml
|
||||
// CHOOSE_BEAN: bazBean
|
||||
package a
|
||||
|
||||
open class FooBean(n: Int) {
|
||||
constructor(barBean: BarBean, bazBean: BazBean): this(1)
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
|
||||
open class BazBean
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean"/>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
</beans>
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="fooBean" class="a.FooBean">
|
||||
<property name="barBean" ref="barBean"/>
|
||||
</bean>
|
||||
<bean id="barBean" class="a.BarBean"/>
|
||||
</beans>
|
||||
@@ -1,9 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Setter
|
||||
// CONFIG_FILE: setter-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean {<caret>
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// ACTION_CLASS: org.jetbrains.kotlin.idea.spring.generate.GenerateKotlinSpringBeanXmlDependencyAction$Setter
|
||||
// CONFIG_FILE: setter-config.xml
|
||||
// CHOOSE_BEAN: barBean
|
||||
package a
|
||||
|
||||
open class FooBean {
|
||||
fun setBarBean(barBean: BarBean) {}
|
||||
}
|
||||
|
||||
open class BarBean
|
||||
@@ -1,17 +0,0 @@
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.context.annotation.Bean
|
||||
|
||||
class Bean {
|
||||
@Autowired
|
||||
fun setProp1(autowiredProp: String) {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
lateinit var prop2: String
|
||||
|
||||
@Be<caret>an(name = "myBean")
|
||||
@Autowired
|
||||
fun myBean(collab: String): String {
|
||||
return "aaa" + collab
|
||||
}
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
{
|
||||
withRuntime: "true",
|
||||
springConfig: ["config.xml"],
|
||||
file: "Bean.kt",
|
||||
icon: "ShowAutowiredDependencies",
|
||||
tooltip: "Navigate to autowired candidates",
|
||||
naming: "generic",
|
||||
targets: ["autowiredProp", "collab", "prop2"]
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="bean" class="Bean"/>
|
||||
|
||||
<bean id="stringBean1" class="java.lang.String"/>
|
||||
<bean id="stringBean2" class="java.lang.String"/>
|
||||
</beans>
|
||||
@@ -1,3 +0,0 @@
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
|
||||
class Bean(<caret>val prop: String)
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
{
|
||||
springConfig: ["config.xml"],
|
||||
file: "Bean.kt",
|
||||
icon: "SpringBeanMethod",
|
||||
tooltip: "Navigate to the spring bean",
|
||||
naming: "bean",
|
||||
targets: ["bean"]
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="bean" class="Bean">
|
||||
<constructor-arg index="0" value="string1"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -1,6 +0,0 @@
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
|
||||
class Bean {
|
||||
@Autowired
|
||||
lateinit var pr<caret>op: String
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
{
|
||||
springConfig: ["config.xml"],
|
||||
file: "Bean.kt",
|
||||
icon: "ShowAutowiredDependencies",
|
||||
tooltip: "Navigate to the autowired dependencies",
|
||||
naming: "bean",
|
||||
targets: ["stringBean1", "stringBean2"]
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="bean" class="Bean"/>
|
||||
|
||||
<bean id="stringBean1" class="java.lang.String"/>
|
||||
<bean id="stringBean2" class="java.lang.String"/>
|
||||
</beans>
|
||||
@@ -1,6 +0,0 @@
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
|
||||
class Bean {
|
||||
@Autowired
|
||||
fun setProp(autowired<caret>Prop: String) { }
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
withRuntime: "true",
|
||||
"springConfig": ["config.xml"],
|
||||
file: "Bean.kt",
|
||||
icon: "ShowAutowiredDependencies",
|
||||
tooltip: "Navigate to the autowired dependencies",
|
||||
naming: "bean",
|
||||
targets: ["stringBean1", "stringBean2"]
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
default-init-method="myDefaultInitMethod"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="bean" class="Bean"/>
|
||||
|
||||
<bean id="stringBean1" class="java.lang.String"/>
|
||||
<bean id="stringBean2" class="java.lang.String"/>
|
||||
</beans>
|
||||
@@ -1,7 +0,0 @@
|
||||
class Be<caret>an {
|
||||
var prop1: String
|
||||
|
||||
fun setProp2(value: String) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
springConfig: ["config.xml"],
|
||||
file: "Bean.kt",
|
||||
icon: "SpringBean",
|
||||
tooltip: "Navigate to the spring bean declaration(s)",
|
||||
naming: "bean",
|
||||
targets: ["bean"]
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
<beans>
|
||||
<bean id="bean" class="Bean"/>
|
||||
</beans>
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
abstract class Abstract<caret>Bean
|
||||
-1
@@ -1 +0,0 @@
|
||||
class AbstractBeanInheritor : AbstractBean()
|
||||
-1
@@ -1 +0,0 @@
|
||||
class AbstractBeanInheritor2 : AbstractBean()
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
{
|
||||
springConfig: ["inheritors.xml"],
|
||||
file: "AbstractBean.kt",
|
||||
icon: "SpringBean",
|
||||
tooltip: "Navigate to the spring bean declaration(s)",
|
||||
naming: "bean",
|
||||
targets: ["inheritor", "inheritor2"]
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="inheritor" class="AbstractBeanInheritor"/>
|
||||
<bean id="inheritor2" class="AbstractBeanInheritor2"/>
|
||||
</beans>
|
||||
@@ -1,3 +0,0 @@
|
||||
package test
|
||||
|
||||
class Bean(val n: Int)
|
||||
@@ -1,6 +0,0 @@
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
import org.springframework.context.annotation.Configuration
|
||||
|
||||
@Component<caret>Scan("beans")
|
||||
@Configuration
|
||||
open class ComponentScan
|
||||
@@ -1,6 +0,0 @@
|
||||
package beans
|
||||
|
||||
import org.springframework.stereotype.Controller
|
||||
|
||||
@Controller(value = "customControllerName")
|
||||
class MyController
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package beans
|
||||
|
||||
import org.springframework.stereotype.Component
|
||||
import javax.annotation.Resource
|
||||
import test.Bean
|
||||
|
||||
@Component
|
||||
class ResourceGutter {
|
||||
@Resource(name = "bean1")
|
||||
fun setResource(be<caret>an: Bean) {
|
||||
|
||||
}
|
||||
|
||||
@Resource
|
||||
fun setUnknown(booo: Boolean) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
springConfig: ["ComponentScan.kt"],
|
||||
file: "ComponentScan.kt",
|
||||
icon: "SpringScan",
|
||||
tooltip: "Navigate to the spring bean declaration(s)",
|
||||
naming: "bean",
|
||||
targets: ["resourceGutter", "customControllerName"]
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import foo.FooBean
|
||||
import bar.BarBean
|
||||
|
||||
@ComponentScan(basePackageClasses = arrayOf(FooBean::class, BarBean::class))
|
||||
@Configuration
|
||||
open class Config
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
package bar
|
||||
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
class BarBean {
|
||||
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
{
|
||||
springConfig: ["Config.kt"],
|
||||
file: "foo/beans.kt",
|
||||
icon: "SpringJavaBean",
|
||||
tooltip: "Navigate to the spring bean declaration(s)",
|
||||
naming: "generic",
|
||||
targets: ["Config"]
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user