KT-15092 Suppress inspection "use property access syntax" for some getters and fix completion for them

#KT-15092 fixed
This commit is contained in:
Simon Ogorodnik
2016-12-20 20:39:06 +03:00
parent c1538aea43
commit 0cf02dcb7b
17 changed files with 434 additions and 13 deletions
+1 -1
View File
@@ -15,7 +15,7 @@
<orderEntry type="library" scope="PROVIDED" name="java-i18n" level="project" />
<orderEntry type="library" scope="PROVIDED" name="gradle-and-groovy-plugin" level="project" />
<orderEntry type="module" module-name="eval4j" />
<orderEntry type="library" name="intellij-core-analysis" level="project" />
<orderEntry type="library" exported="" name="intellij-core-analysis" level="project" />
<orderEntry type="module-library">
<library>
<CLASSES>
@@ -78,7 +78,9 @@ abstract class IntentionBasedInspection<TElement : PsiElement>(
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor {
val intentionsAndCheckers = intentionInfos.map {
it.intention.constructors.single().call() to it.additionalChecker
val instance = it.intention.constructors.single().call()
instance.inspection = this
instance to it.additionalChecker
}
val elementType = intentionsAndCheckers.map { it.first.elementType }.distinct().singleOrNull()
?: error("$intentionInfos should have the same elementType")
@@ -105,7 +107,7 @@ abstract class IntentionBasedInspection<TElement : PsiElement>(
if (fixes == null) {
fixes = SmartList<LocalQuickFix>()
}
fixes!!.add(createQuickFix(intention, additionalChecker, targetElement))
fixes.add(createQuickFix(intention, additionalChecker, targetElement))
}
}
@@ -91,8 +91,11 @@ abstract class SelfTargetingIntention<TElement : PsiElement>(
return !isIntentionBaseInspectionEnabled(project, target)
}
var inspection: IntentionBasedInspection<TElement>? = null
internal set
protected fun isIntentionBaseInspectionEnabled(project: Project, target: TElement): Boolean {
val inspection = findInspection(this.javaClass.kotlin) ?: return false
val inspection = inspection ?: findInspection(this.javaClass.kotlin) ?: return false
val key = HighlightDisplayKey.find(inspection.shortName)
if (!InspectionProjectProfileManager.getInstance(project).inspectionProfile.isToolEnabled(key, target)) {