[REVERTED] 2692a7d Alexey Sedunov on 2/21/2016 at 00:50 (committed on 3/24/2016 at 18:42)
Spring Support: Inspection for Spring configuration
This commit is contained in:
@@ -25,7 +25,6 @@ class KtLightIdentifier(
|
|||||||
private val lightOwner: PsiNameIdentifierOwner,
|
private val lightOwner: PsiNameIdentifierOwner,
|
||||||
private val ktDeclaration: KtNamedDeclaration?
|
private val ktDeclaration: KtNamedDeclaration?
|
||||||
) : LightIdentifier(lightOwner.manager, ktDeclaration?.name ?: "") {
|
) : LightIdentifier(lightOwner.manager, ktDeclaration?.name ?: "") {
|
||||||
override fun isPhysical() = true
|
|
||||||
override fun getParent() = lightOwner
|
override fun getParent() = lightOwner
|
||||||
override fun getTextRange() = ktDeclaration?.nameIdentifier?.textRange ?: TextRange.EMPTY_RANGE
|
override fun getTextRange() = ktDeclaration?.nameIdentifier?.textRange ?: TextRange.EMPTY_RANGE
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
Ensures that Kotlin files using Spring belong to a module with a configured Spring facet.
|
|
||||||
@@ -13,13 +13,5 @@
|
|||||||
groupPath="Spring,Spring Core"
|
groupPath="Spring,Spring Core"
|
||||||
enabledByDefault="true"
|
enabledByDefault="true"
|
||||||
level="WARNING"/>
|
level="WARNING"/>
|
||||||
<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"/>
|
|
||||||
</extensions>
|
</extensions>
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
-53
@@ -1,53 +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.LocalQuickFix
|
|
||||||
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.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)?.forEach {
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
val descriptor = holder.manager.createProblemDescriptor(
|
|
||||||
classOrObject.nameIdentifier ?: classOrObject,
|
|
||||||
it.descriptionTemplate,
|
|
||||||
isOnTheFly,
|
|
||||||
it.fixes as Array<LocalQuickFix>,
|
|
||||||
it.highlightType
|
|
||||||
)
|
|
||||||
holder.registerProblem(descriptor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-6
@@ -40,10 +40,4 @@ public class UltimateInspectionTestGenerated extends AbstractInspectionTest {
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/ultimateInspections/spring/finalSpringAnnotatedDeclaration/inspectionData/inspections.test");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/ultimateInspections/spring/finalSpringAnnotatedDeclaration/inspectionData/inspections.test");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("spring/unconfiguredFacet/inspectionData/inspections.test")
|
|
||||||
public void testSpring_unconfiguredFacet_inspectionData_Inspections_test() throws Exception {
|
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/ultimateInspections/spring/unconfiguredFacet/inspectionData/inspections.test");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
<problems>
|
|
||||||
<problem>
|
|
||||||
<file>test.kt</file>
|
|
||||||
<line>12</line>
|
|
||||||
<module>light_idea_test_case</module>
|
|
||||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
|
||||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Spring Facet Code Configuration (Kotlin)</problem_class>
|
|
||||||
<description>Application context not configured for this file</description>
|
|
||||||
</problem>
|
|
||||||
<problem>
|
|
||||||
<file>test.kt</file>
|
|
||||||
<line>15</line>
|
|
||||||
<module>light_idea_test_case</module>
|
|
||||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
|
||||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Spring Facet Code Configuration (Kotlin)</problem_class>
|
|
||||||
<description>Application context not configured for this file</description>
|
|
||||||
</problem>
|
|
||||||
</problems>
|
|
||||||
-2
@@ -1,2 +0,0 @@
|
|||||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.spring.inspections.KotlinSpringFacetCodeInspection
|
|
||||||
// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
// WITH_RUNTIME
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.ComponentScan
|
|
||||||
import org.springframework.context.annotation.Configuration
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@ComponentScan
|
|
||||||
annotation class MyConfiguration
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
class Application1
|
|
||||||
|
|
||||||
@MyConfiguration
|
|
||||||
class Application2
|
|
||||||
Reference in New Issue
Block a user