Temporary fixes for Kotlin project after enabling NI
Most of these fixes will gone away after compiler bootstraping
This commit is contained in:
@@ -315,7 +315,7 @@ private fun OrderEntry.toIdeaModuleInfo(
|
||||
/**
|
||||
* @see [org.jetbrains.kotlin.types.typeUtil.closure].
|
||||
*/
|
||||
fun <T> Collection<T>.lazyClosure(f: (T) -> Collection<T>): Sequence<T> = sequence {
|
||||
fun <T> Collection<T>.lazyClosure(f: (T) -> Collection<T>): Sequence<T> = sequence<T> {
|
||||
if (size == 0) return@sequence
|
||||
var sizeBeforeIteration = 0
|
||||
|
||||
|
||||
+1
-1
@@ -308,7 +308,7 @@ class ExpressionsOfTypeProcessor(
|
||||
}
|
||||
|
||||
val file = psiClass.containingFile
|
||||
(file ?: psiClass).useScope
|
||||
if (file != null) file.useScope else psiClass.useScope
|
||||
}
|
||||
|
||||
private fun addStaticMemberToProcess(psiMember: PsiMember, scope: SearchScope, processor: ReferenceProcessor) {
|
||||
|
||||
@@ -243,8 +243,8 @@ private class TemplateTokenSequence(private val inputString: String) : Sequence<
|
||||
while (to < inputString.length) {
|
||||
val c = inputString[to]
|
||||
if (c == '\\') {
|
||||
to += 1
|
||||
if (to < inputString.length) to += 1
|
||||
to += 1.toInt()
|
||||
if (to < inputString.length) to += 1.toInt()
|
||||
continue
|
||||
} else if (c == '$') {
|
||||
if (inputString.substring(to).guessIsTemplateEntryStart()) {
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.psi.search.searches.DefinitionsScopedSearch
|
||||
import com.intellij.psi.search.searches.MethodReferencesSearch
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
import com.intellij.refactoring.safeDelete.SafeDeleteHandler
|
||||
import com.intellij.util.Processor
|
||||
import org.jetbrains.kotlin.asJava.LightClassUtil
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||
import org.jetbrains.kotlin.asJava.toLightClass
|
||||
@@ -376,7 +377,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
|
||||
useScope,
|
||||
kotlinOptions = searchOptions
|
||||
)
|
||||
val referenceUsed: Boolean by lazy { !ReferencesSearch.search(searchParameters).forEach(::checkReference) }
|
||||
val referenceUsed: Boolean by lazy { !ReferencesSearch.search(searchParameters).forEach(Processor { checkReference(it) }) }
|
||||
|
||||
if (descriptor is FunctionDescriptor && DescriptorUtils.findJvmNameAnnotation(descriptor) != null) {
|
||||
if (referenceUsed) return true
|
||||
@@ -386,7 +387,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
|
||||
val lightMethods = declaration.toLightMethods()
|
||||
if (lightMethods.isNotEmpty()) {
|
||||
val lightMethodsUsed = lightMethods.any { method ->
|
||||
!MethodReferencesSearch.search(method).forEach(::checkReference)
|
||||
!MethodReferencesSearch.search(method).forEach(Processor { checkReference(it) })
|
||||
}
|
||||
if (lightMethodsUsed) return true
|
||||
if (!declaration.hasActualModifier()) return false
|
||||
|
||||
@@ -129,9 +129,9 @@ abstract class ImplementAbstractMemberIntentionBase :
|
||||
|
||||
private fun implementInClass(member: KtNamedDeclaration, targetClasses: List<PsiElement>) {
|
||||
val project = member.project
|
||||
project.executeCommand(CodeInsightBundle.message("intention.implement.abstract.method.command.name")) {
|
||||
project.executeCommand<Unit>(CodeInsightBundle.message("intention.implement.abstract.method.command.name")) {
|
||||
if (!FileModificationService.getInstance().preparePsiElementsForWrite(targetClasses)) return@executeCommand
|
||||
runWriteAction {
|
||||
runWriteAction<Unit> {
|
||||
for (targetClass in targetClasses) {
|
||||
try {
|
||||
val descriptor = OpenFileDescriptor(project, targetClass.containingFile.virtualFile)
|
||||
|
||||
+1
-1
@@ -202,7 +202,7 @@ open class CreateClassFromUsageFix<E : KtElement> protected constructor(
|
||||
|
||||
val element = element ?: return
|
||||
|
||||
runWriteAction {
|
||||
runWriteAction<Unit> {
|
||||
with(classInfo) {
|
||||
val targetParent =
|
||||
when (selectedParent) {
|
||||
|
||||
+1
-1
@@ -381,7 +381,7 @@ class CopyKotlinDeclarationsHandler : CopyHandlerDelegateBase() {
|
||||
doRefactoringOnElement(sourceData, targetFile)
|
||||
}
|
||||
|
||||
refactoringResult.copiedDeclaration?.let { newDeclaration ->
|
||||
refactoringResult.copiedDeclaration?.let<KtNamedDeclaration, Unit> { newDeclaration ->
|
||||
if (targetData.newName == newDeclaration.name) return@let
|
||||
val selfReferences = ReferencesSearch.search(newDeclaration, LocalSearchScope(newDeclaration)).findAll()
|
||||
runWriteAction {
|
||||
|
||||
+1
-1
@@ -250,7 +250,7 @@ class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
||||
else -> return
|
||||
}
|
||||
for (constructor in constructors) {
|
||||
constructor.processDelegationCallConstructorUsages(constructor.useScope) {
|
||||
constructor.processDelegationCallConstructorUsages((constructor as PsiElement).useScope) {
|
||||
if (!getIgnoranceCondition().value(it)) {
|
||||
usages.add(SafeDeleteReferenceSimpleDeleteUsageInfo(it, element, false))
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ class AutoloadedScriptDefinitions(
|
||||
loadScriptTemplatesFromClasspath(
|
||||
listOf("org.jetbrains.kotlin.mainKts.MainKtsScript"),
|
||||
mainKtsJars,
|
||||
emptyList(),
|
||||
emptyList<File>(),
|
||||
baseClassloader,
|
||||
hostConfiguration,
|
||||
messageReporter
|
||||
|
||||
+2
-2
@@ -72,7 +72,7 @@ private fun scriptTemplatesDiscoverySequence(
|
||||
hostConfiguration: ScriptingHostConfiguration,
|
||||
messageReporter: MessageReporter
|
||||
): Sequence<ScriptDefinition> {
|
||||
return sequence {
|
||||
return sequence<ScriptDefinition> {
|
||||
// for jar files the definition class is expected in the same jar as the discovery file
|
||||
// in case of directories, the class output may come separate from the resources, so some candidates should be deffered and processed later
|
||||
val defferedDirDependencies = ArrayList<File>()
|
||||
@@ -165,7 +165,7 @@ fun loadScriptTemplatesFromClasspath(
|
||||
messageReporter: MessageReporter
|
||||
): Sequence<ScriptDefinition> =
|
||||
if (scriptTemplates.isEmpty()) emptySequence()
|
||||
else sequence {
|
||||
else sequence<ScriptDefinition> {
|
||||
// trying the direct classloading from baseClassloader first, since this is the most performant variant
|
||||
val (initialLoadedDefinitions, initialNotFoundTemplates) = scriptTemplates.partitionMapNotNull {
|
||||
loadScriptDefinition(
|
||||
|
||||
Reference in New Issue
Block a user