New J2K: Fix old j2k build
This commit is contained in:
committed by
Ilya Kirillov
parent
dff4ab2437
commit
939b379694
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.core.moveFunctionLiteralOutsideParenthesesIfPossible
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.core.setVisibility
|
||||
import org.jetbrains.kotlin.idea.inspections.*
|
||||
@@ -38,6 +37,7 @@ import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isTrivialSta
|
||||
import org.jetbrains.kotlin.idea.quickfix.RemoveModifierFix
|
||||
import org.jetbrains.kotlin.idea.quickfix.RemoveUselessCastFix
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.j2k.ConverterSettings
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getChildOfType
|
||||
@@ -179,76 +179,6 @@ object J2KPostProcessingRegistrarImpl : J2KPostProcessingRegistrar {
|
||||
})
|
||||
}
|
||||
|
||||
private inline fun <TInspection : AbstractKotlinInspection> registerGeneralInspectionBasedProcessing(
|
||||
inspection: TInspection,
|
||||
acceptInformationLevel: Boolean = false
|
||||
) {
|
||||
_processings.add(object : J2kPostProcessing {
|
||||
override val writeActionNeeded = false
|
||||
|
||||
fun <D : CommonProblemDescriptor> QuickFix<D>.applyFixSmart(project: Project, descriptor: D) {
|
||||
if (descriptor is ProblemDescriptor) {
|
||||
if (this is IntentionWrapper) {
|
||||
@Suppress("NOT_YET_SUPPORTED_IN_INLINE")
|
||||
fun applySelfTargetingIntention(action: SelfTargetingIntention<PsiElement>) {
|
||||
val target = action.getTarget(descriptor.psiElement.startOffset, descriptor.psiElement.containingFile) ?: return
|
||||
if (!action.isApplicableTo(target, descriptor.psiElement.startOffset)) return
|
||||
action.applyTo(target, null)
|
||||
}
|
||||
|
||||
@Suppress("NOT_YET_SUPPORTED_IN_INLINE")
|
||||
fun applyQuickFixActionBase(action: QuickFixActionBase<PsiElement>) {
|
||||
if (!action.isAvailable(project, null, descriptor.psiElement.containingFile)) return
|
||||
action.invoke(project, null, descriptor.psiElement.containingFile)
|
||||
}
|
||||
|
||||
|
||||
@Suppress("NOT_YET_SUPPORTED_IN_INLINE")
|
||||
fun applyIntention() {
|
||||
val action = this.action
|
||||
when (action) {
|
||||
is SelfTargetingIntention<*> -> applySelfTargetingIntention(action as SelfTargetingIntention<PsiElement>)
|
||||
is QuickFixActionBase<*> -> applyQuickFixActionBase(action)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (this.startInWriteAction()) {
|
||||
ApplicationManager.getApplication().runWriteAction(::applyIntention)
|
||||
} else {
|
||||
applyIntention()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
this.applyFix(project, descriptor)
|
||||
}
|
||||
}
|
||||
|
||||
override fun createAction(element: KtElement, diagnostics: Diagnostics): (() -> Unit)? {
|
||||
val holder = ProblemsHolder(InspectionManager.getInstance(element.project), element.containingFile, false)
|
||||
val visitor = inspection.buildVisitor(
|
||||
holder,
|
||||
false,
|
||||
LocalInspectionToolSession(element.containingFile, 0, element.containingFile.endOffset)
|
||||
)
|
||||
element.accept(visitor)
|
||||
if (!holder.hasResults()) return null
|
||||
return {
|
||||
holder.results.clear()
|
||||
element.accept(visitor)
|
||||
if (holder.hasResults()) {
|
||||
holder.results
|
||||
.filter { acceptInformationLevel || it.highlightType != ProblemHighlightType.INFORMATION }
|
||||
.forEach { it.fixes?.firstOrNull()?.applyFixSmart(element.project, it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private inline fun
|
||||
<reified TElement : KtElement,
|
||||
TInspection: AbstractApplicabilityBasedInspection<TElement>> registerInspectionBasedProcessing(
|
||||
|
||||
@@ -36,7 +36,9 @@ import org.jetbrains.kotlin.j2k.PostProcessor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
import org.jetbrains.kotlin.psi.psiUtil.elementsInRange
|
||||
import org.jetbrains.kotlin.resolve.ImportPath
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||
import java.util.*
|
||||
|
||||
@@ -71,20 +73,17 @@ class J2kPostProcessor(private val formatCode: Boolean) : PostProcessor {
|
||||
runWriteAction {
|
||||
action()
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
action()
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
modificationStamp = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modificationStamp == file.modificationStamp) break
|
||||
}
|
||||
while (elementToActions.isNotEmpty())
|
||||
} while (elementToActions.isNotEmpty())
|
||||
|
||||
|
||||
if (formatCode) {
|
||||
@@ -95,8 +94,7 @@ class J2kPostProcessor(private val formatCode: Boolean) : PostProcessor {
|
||||
if (rangeMarker.isValid) {
|
||||
codeStyleManager.reformatRange(file, rangeMarker.startOffset, rangeMarker.endOffset)
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
codeStyleManager.reformat(file)
|
||||
}
|
||||
Unit
|
||||
@@ -122,12 +120,16 @@ class J2kPostProcessor(private val formatCode: Boolean) : PostProcessor {
|
||||
super.visitElement(element)
|
||||
|
||||
if (rangeResult == RangeFilterResult.PROCESS) {
|
||||
J2KPostProcessingRegistrar.processings.forEach { processing ->
|
||||
J2KPostProcessingRegistrarImpl.processings.forEach { processing ->
|
||||
val action = processing.createAction(element, diagnostics)
|
||||
if (action != null) {
|
||||
availableActions.add(ActionData(element, action,
|
||||
J2KPostProcessingRegistrar.priority(processing),
|
||||
processing.writeActionNeeded))
|
||||
availableActions.add(
|
||||
ActionData(
|
||||
element, action,
|
||||
J2KPostProcessingRegistrarImpl.priority(processing),
|
||||
processing.writeActionNeeded
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ dependencies {
|
||||
testRuntime(intellijDep())
|
||||
|
||||
compile(kotlinStdlib())
|
||||
compile(project(":idea:idea-core"))
|
||||
compile(project(":compiler:frontend"))
|
||||
compile(project(":compiler:frontend.java"))
|
||||
compile(project(":compiler:light-classes"))
|
||||
|
||||
@@ -26,7 +26,6 @@ dependencies {
|
||||
compile(projectRuntimeJar(":kotlin-daemon-client"))
|
||||
compile(project(":kotlin-compiler-runner")) { isTransitive = false }
|
||||
compile(project(":compiler:plugin-api"))
|
||||
compile(project(":eval4j"))
|
||||
compile(project(":j2k"))
|
||||
compile(project(":nj2k"))
|
||||
compile(project(":idea"))
|
||||
|
||||
Reference in New Issue
Block a user