New J2K: do not apply diagnostic based inspections if target element is not in the converting range
This commit is contained in:
+5
-2
@@ -41,8 +41,11 @@ class DiagnosticBasedPostProcessingGroup(diagnosticBasedProcessings: List<Diagno
|
|||||||
CommandProcessor.getInstance().runUndoTransparentAction {
|
CommandProcessor.getInstance().runUndoTransparentAction {
|
||||||
val diagnostics = runWriteAction { analyzeFileRange(file, rangeMarker) }
|
val diagnostics = runWriteAction { analyzeFileRange(file, rangeMarker) }
|
||||||
for (diagnostic in diagnostics.all()) {
|
for (diagnostic in diagnostics.all()) {
|
||||||
diagnosticToFix[diagnostic.factory]?.forEach { fix ->
|
val range = rangeMarker?.range ?: file.textRange
|
||||||
runWriteAction { fix(diagnostic) }
|
if (diagnostic.psiElement.isInRange(range)) {
|
||||||
|
diagnosticToFix[diagnostic.factory]?.forEach { fix ->
|
||||||
|
runWriteAction { fix(diagnostic) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,13 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.nj2k.postProcessing
|
package org.jetbrains.kotlin.nj2k.postProcessing
|
||||||
|
|
||||||
|
import com.intellij.openapi.util.TextRange
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.search.LocalSearchScope
|
import com.intellij.psi.search.LocalSearchScope
|
||||||
import com.intellij.psi.search.searches.ReferencesSearch
|
import com.intellij.psi.search.searches.ReferencesSearch
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
|
||||||
|
import org.jetbrains.kotlin.idea.core.util.range
|
||||||
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
||||||
import org.jetbrains.kotlin.idea.references.mainReference
|
import org.jetbrains.kotlin.idea.references.mainReference
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
@@ -75,3 +77,6 @@ fun KtElement.hasUsagesOutsideOf(inElement: KtElement, outsideElements: List<KtE
|
|||||||
|
|
||||||
inline fun <reified T : PsiElement> List<PsiElement>.descendantsOfType(): List<T> =
|
inline fun <reified T : PsiElement> List<PsiElement>.descendantsOfType(): List<T> =
|
||||||
flatMap { it.collectDescendantsOfType() }
|
flatMap { it.collectDescendantsOfType() }
|
||||||
|
|
||||||
|
fun PsiElement.isInRange(outerRange: TextRange) =
|
||||||
|
outerRange.contains(range)
|
||||||
Reference in New Issue
Block a user