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].
|
* @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
|
if (size == 0) return@sequence
|
||||||
var sizeBeforeIteration = 0
|
var sizeBeforeIteration = 0
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -308,7 +308,7 @@ class ExpressionsOfTypeProcessor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val file = psiClass.containingFile
|
val file = psiClass.containingFile
|
||||||
(file ?: psiClass).useScope
|
if (file != null) file.useScope else psiClass.useScope
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addStaticMemberToProcess(psiMember: PsiMember, scope: SearchScope, processor: ReferenceProcessor) {
|
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) {
|
while (to < inputString.length) {
|
||||||
val c = inputString[to]
|
val c = inputString[to]
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
to += 1
|
to += 1.toInt()
|
||||||
if (to < inputString.length) to += 1
|
if (to < inputString.length) to += 1.toInt()
|
||||||
continue
|
continue
|
||||||
} else if (c == '$') {
|
} else if (c == '$') {
|
||||||
if (inputString.substring(to).guessIsTemplateEntryStart()) {
|
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.MethodReferencesSearch
|
||||||
import com.intellij.psi.search.searches.ReferencesSearch
|
import com.intellij.psi.search.searches.ReferencesSearch
|
||||||
import com.intellij.refactoring.safeDelete.SafeDeleteHandler
|
import com.intellij.refactoring.safeDelete.SafeDeleteHandler
|
||||||
|
import com.intellij.util.Processor
|
||||||
import org.jetbrains.kotlin.asJava.LightClassUtil
|
import org.jetbrains.kotlin.asJava.LightClassUtil
|
||||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||||
import org.jetbrains.kotlin.asJava.toLightClass
|
import org.jetbrains.kotlin.asJava.toLightClass
|
||||||
@@ -376,7 +377,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
|
|||||||
useScope,
|
useScope,
|
||||||
kotlinOptions = searchOptions
|
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 (descriptor is FunctionDescriptor && DescriptorUtils.findJvmNameAnnotation(descriptor) != null) {
|
||||||
if (referenceUsed) return true
|
if (referenceUsed) return true
|
||||||
@@ -386,7 +387,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
|
|||||||
val lightMethods = declaration.toLightMethods()
|
val lightMethods = declaration.toLightMethods()
|
||||||
if (lightMethods.isNotEmpty()) {
|
if (lightMethods.isNotEmpty()) {
|
||||||
val lightMethodsUsed = lightMethods.any { method ->
|
val lightMethodsUsed = lightMethods.any { method ->
|
||||||
!MethodReferencesSearch.search(method).forEach(::checkReference)
|
!MethodReferencesSearch.search(method).forEach(Processor { checkReference(it) })
|
||||||
}
|
}
|
||||||
if (lightMethodsUsed) return true
|
if (lightMethodsUsed) return true
|
||||||
if (!declaration.hasActualModifier()) return false
|
if (!declaration.hasActualModifier()) return false
|
||||||
|
|||||||
@@ -129,9 +129,9 @@ abstract class ImplementAbstractMemberIntentionBase :
|
|||||||
|
|
||||||
private fun implementInClass(member: KtNamedDeclaration, targetClasses: List<PsiElement>) {
|
private fun implementInClass(member: KtNamedDeclaration, targetClasses: List<PsiElement>) {
|
||||||
val project = member.project
|
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
|
if (!FileModificationService.getInstance().preparePsiElementsForWrite(targetClasses)) return@executeCommand
|
||||||
runWriteAction {
|
runWriteAction<Unit> {
|
||||||
for (targetClass in targetClasses) {
|
for (targetClass in targetClasses) {
|
||||||
try {
|
try {
|
||||||
val descriptor = OpenFileDescriptor(project, targetClass.containingFile.virtualFile)
|
val descriptor = OpenFileDescriptor(project, targetClass.containingFile.virtualFile)
|
||||||
|
|||||||
+1
-1
@@ -202,7 +202,7 @@ open class CreateClassFromUsageFix<E : KtElement> protected constructor(
|
|||||||
|
|
||||||
val element = element ?: return
|
val element = element ?: return
|
||||||
|
|
||||||
runWriteAction {
|
runWriteAction<Unit> {
|
||||||
with(classInfo) {
|
with(classInfo) {
|
||||||
val targetParent =
|
val targetParent =
|
||||||
when (selectedParent) {
|
when (selectedParent) {
|
||||||
|
|||||||
+1
-1
@@ -381,7 +381,7 @@ class CopyKotlinDeclarationsHandler : CopyHandlerDelegateBase() {
|
|||||||
doRefactoringOnElement(sourceData, targetFile)
|
doRefactoringOnElement(sourceData, targetFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
refactoringResult.copiedDeclaration?.let { newDeclaration ->
|
refactoringResult.copiedDeclaration?.let<KtNamedDeclaration, Unit> { newDeclaration ->
|
||||||
if (targetData.newName == newDeclaration.name) return@let
|
if (targetData.newName == newDeclaration.name) return@let
|
||||||
val selfReferences = ReferencesSearch.search(newDeclaration, LocalSearchScope(newDeclaration)).findAll()
|
val selfReferences = ReferencesSearch.search(newDeclaration, LocalSearchScope(newDeclaration)).findAll()
|
||||||
runWriteAction {
|
runWriteAction {
|
||||||
|
|||||||
+1
-1
@@ -250,7 +250,7 @@ class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
|||||||
else -> return
|
else -> return
|
||||||
}
|
}
|
||||||
for (constructor in constructors) {
|
for (constructor in constructors) {
|
||||||
constructor.processDelegationCallConstructorUsages(constructor.useScope) {
|
constructor.processDelegationCallConstructorUsages((constructor as PsiElement).useScope) {
|
||||||
if (!getIgnoranceCondition().value(it)) {
|
if (!getIgnoranceCondition().value(it)) {
|
||||||
usages.add(SafeDeleteReferenceSimpleDeleteUsageInfo(it, element, false))
|
usages.add(SafeDeleteReferenceSimpleDeleteUsageInfo(it, element, false))
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ class AutoloadedScriptDefinitions(
|
|||||||
loadScriptTemplatesFromClasspath(
|
loadScriptTemplatesFromClasspath(
|
||||||
listOf("org.jetbrains.kotlin.mainKts.MainKtsScript"),
|
listOf("org.jetbrains.kotlin.mainKts.MainKtsScript"),
|
||||||
mainKtsJars,
|
mainKtsJars,
|
||||||
emptyList(),
|
emptyList<File>(),
|
||||||
baseClassloader,
|
baseClassloader,
|
||||||
hostConfiguration,
|
hostConfiguration,
|
||||||
messageReporter
|
messageReporter
|
||||||
|
|||||||
+2
-2
@@ -72,7 +72,7 @@ private fun scriptTemplatesDiscoverySequence(
|
|||||||
hostConfiguration: ScriptingHostConfiguration,
|
hostConfiguration: ScriptingHostConfiguration,
|
||||||
messageReporter: MessageReporter
|
messageReporter: MessageReporter
|
||||||
): Sequence<ScriptDefinition> {
|
): Sequence<ScriptDefinition> {
|
||||||
return sequence {
|
return sequence<ScriptDefinition> {
|
||||||
// for jar files the definition class is expected in the same jar as the discovery file
|
// 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
|
// 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>()
|
val defferedDirDependencies = ArrayList<File>()
|
||||||
@@ -165,7 +165,7 @@ fun loadScriptTemplatesFromClasspath(
|
|||||||
messageReporter: MessageReporter
|
messageReporter: MessageReporter
|
||||||
): Sequence<ScriptDefinition> =
|
): Sequence<ScriptDefinition> =
|
||||||
if (scriptTemplates.isEmpty()) emptySequence()
|
if (scriptTemplates.isEmpty()) emptySequence()
|
||||||
else sequence {
|
else sequence<ScriptDefinition> {
|
||||||
// trying the direct classloading from baseClassloader first, since this is the most performant variant
|
// trying the direct classloading from baseClassloader first, since this is the most performant variant
|
||||||
val (initialLoadedDefinitions, initialNotFoundTemplates) = scriptTemplates.partitionMapNotNull {
|
val (initialLoadedDefinitions, initialNotFoundTemplates) = scriptTemplates.partitionMapNotNull {
|
||||||
loadScriptDefinition(
|
loadScriptDefinition(
|
||||||
|
|||||||
Reference in New Issue
Block a user