Temporarily replace usages of extension on iterators in compiler by _tmp() calls
This commit is contained in:
committed by
Andrey Breslav
parent
f07b7cc58d
commit
a3b45b919c
@@ -60,6 +60,8 @@ import org.jetbrains.jet.lang.psi.JetTypeReference
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils
|
||||
import org.jetbrains.jet.plugin.imports.*
|
||||
import org.jetbrains.jet.lang.descriptors.PackageViewDescriptor
|
||||
import org.jetbrains.jet.utils.*
|
||||
|
||||
//NOTE: this class is based on CopyPasteReferenceProcessor and JavaCopyPasteReferenceProcessor
|
||||
public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor<ReferenceTransferableData?> {
|
||||
@@ -340,9 +342,9 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor<Refere
|
||||
private val ReferenceData.fqName: FqName
|
||||
get() = FqName(qClassName!!)
|
||||
|
||||
private fun zip(first: IntArray, second: IntArray): Iterator<Pair<Int, Int>> {
|
||||
private fun zip(first: IntArray, second: IntArray): Iterable<Pair<Int, Int>> {
|
||||
assert(first.size == second.size)
|
||||
return first.iterator().zip(second.iterator())
|
||||
return first.toList().zip_tmp(second.toList())
|
||||
}
|
||||
|
||||
private fun PsiElement.isInCopiedArea(fileCopiedFrom: JetFile, startOffsets: IntArray, endOffsets: IntArray): Boolean {
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
||||
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
||||
import org.jetbrains.jet.utils.*
|
||||
|
||||
trait SmartCompletionData{
|
||||
fun accepts(descriptor: DeclarationDescriptor): Boolean
|
||||
@@ -287,8 +288,8 @@ private fun processDataFlowInfo(dataFlowInfo: DataFlowInfo?, receiver: JetExpres
|
||||
}
|
||||
|
||||
val nullabilityInfo: Map<DataFlowValue, Nullability> = dataFlowInfo.getCompleteNullabilityInfo()
|
||||
val notNullVariables = nullabilityInfo.iterator()
|
||||
.filter { it.getValue() == Nullability.NOT_NULL }
|
||||
val notNullVariables = nullabilityInfo
|
||||
.filter_tmp { it.getValue() == Nullability.NOT_NULL }
|
||||
.map { dataFlowValueToVariable(it.getKey()) }
|
||||
.filterNotNullTo(HashSet<VariableDescriptor>())
|
||||
|
||||
@@ -408,4 +409,4 @@ private fun <T> MutableCollection<T>.addAll(iterator: Iterator<T>) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun String?.isNullOrEmpty() = this == null || this.isEmpty()
|
||||
private fun String?.isNullOrEmpty() = this == null || this.isEmpty()
|
||||
|
||||
+2
-2
@@ -30,8 +30,8 @@ import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
import org.jetbrains.jet.plugin.references.JetReference
|
||||
import org.jetbrains.jet.plugin.codeInsight.firstOrNull
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor
|
||||
import org.jetbrains.jet.utils.firstOrNull_tmp
|
||||
|
||||
public class ReplaceExplicitFunctionLiteralParamWithItIntention() : PsiElementBaseIntentionAction() {
|
||||
override fun invoke(project: Project, editor: Editor, element: PsiElement) {
|
||||
@@ -75,7 +75,7 @@ public class ReplaceExplicitFunctionLiteralParamWithItIntention() : PsiElementBa
|
||||
}
|
||||
is JetSimpleNameExpression -> {
|
||||
val reference = expression.getReference() as JetReference?
|
||||
val variableDescriptor = reference?.resolveToDescriptors()?.firstOrNull() as? VariableDescriptor?
|
||||
val variableDescriptor = reference?.resolveToDescriptors()?.firstOrNull_tmp() as? VariableDescriptor?
|
||||
if (variableDescriptor != null) {
|
||||
val containingDescriptor = variableDescriptor.getContainingDeclaration()
|
||||
if (containingDescriptor is AnonymousFunctionDescriptor) {
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteral
|
||||
import org.jetbrains.jet.plugin.references.JetReference
|
||||
import org.jetbrains.jet.plugin.codeInsight.firstOrNull
|
||||
import org.jetbrains.jet.utils.firstOrNull_tmp
|
||||
|
||||
public class ReplaceItWithExplicitFunctionLiteralParamIntention() : PsiElementBaseIntentionAction() {
|
||||
override fun invoke(project: Project, editor: Editor, element: PsiElement) {
|
||||
@@ -64,7 +64,7 @@ public class ReplaceItWithExplicitFunctionLiteralParamIntention() : PsiElementBa
|
||||
|
||||
val bindingContext = AnalyzerFacadeWithCache.getContextForElement(simpleNameExpression)
|
||||
val reference = simpleNameExpression.getReference() as JetReference?
|
||||
val simpleNameTarget = reference?.resolveToDescriptors()?.firstOrNull() as? ValueParameterDescriptor?
|
||||
val simpleNameTarget = reference?.resolveToDescriptors()?.firstOrNull_tmp() as? ValueParameterDescriptor?
|
||||
if (simpleNameTarget == null || bindingContext.get(BindingContext.AUTO_CREATED_IT, simpleNameTarget) != true) {
|
||||
return false
|
||||
}
|
||||
|
||||
+8
-7
@@ -27,6 +27,7 @@ import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import java.util.Collections
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import org.jetbrains.jet.utils.*
|
||||
|
||||
public val TRANSFORM_WITHOUT_CHECK: String = "Expression must be checked before applying transformation"
|
||||
|
||||
@@ -325,17 +326,17 @@ public fun JetWhenExpression.canMergeWithNext(): Boolean {
|
||||
fun checkConditions(e1: JetWhenEntry, e2: JetWhenEntry): Boolean {
|
||||
if (e1.isElse() != e2.isElse()) return false
|
||||
|
||||
val conditions1 = e1.getConditions()
|
||||
val conditions2 = e2.getConditions()
|
||||
val conditions1 = e1.getConditions().toList()
|
||||
val conditions2 = e2.getConditions().toList()
|
||||
return conditions1.size == conditions2.size &&
|
||||
(conditions1.iterator() zip conditions2.iterator()).all { pair -> JetPsiMatcher.checkElementMatch(pair.first, pair.second)}
|
||||
(conditions1 zip_tmp conditions2).all { pair -> JetPsiMatcher.checkElementMatch(pair.first, pair.second)}
|
||||
}
|
||||
|
||||
fun JetWhenEntry.declarationNames(): Set<String> =
|
||||
getExpression()?.blockExpressionsOrSingle()
|
||||
?.filterIsInstance(javaClass<JetNamedDeclaration>())
|
||||
?.filter { it is JetNamedDeclaration }
|
||||
?.map { decl -> decl.getName() }
|
||||
?.filterNotNull()?.toHashSet() ?: Collections.emptySet<String>()
|
||||
?.filterNotNull()?.toSet() ?: Collections.emptySet<String>()
|
||||
|
||||
fun checkBodies(e1: JetWhenEntry, e2: JetWhenEntry): Boolean {
|
||||
if (ContainerUtil.intersects(e1.declarationNames(), e2.declarationNames())) return false
|
||||
@@ -353,7 +354,7 @@ public fun JetWhenExpression.canMergeWithNext(): Boolean {
|
||||
|
||||
val entries1 = getEntries()
|
||||
val entries2 = sibling.getEntries()
|
||||
return entries1.size == entries2.size && (entries1.iterator() zip entries2.iterator()).all { pair ->
|
||||
return entries1.size == entries2.size && (entries1 zip_tmp entries2).all { pair ->
|
||||
checkConditions(pair.first, pair.second) && checkBodies(pair.first, pair.second)
|
||||
}
|
||||
}
|
||||
@@ -373,7 +374,7 @@ public fun JetWhenExpression.mergeWithNext() {
|
||||
}
|
||||
|
||||
val sibling = PsiTreeUtil.skipSiblingsForward(this, javaClass<PsiWhiteSpace>()) as JetWhenExpression
|
||||
for ((entry1, entry2) in getEntries().iterator() zip sibling.getEntries().iterator()) {
|
||||
for ((entry1, entry2) in getEntries() zip_tmp sibling.getEntries()) {
|
||||
entry1.getExpression() mergeWith entry2.getExpression()
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.parsing.JetExpressionParsing
|
||||
import java.util.HashMap
|
||||
import org.jetbrains.jet.lang.parsing.JetExpressionParsing.Precedence.*
|
||||
import org.jetbrains.jet.lang.psi.*
|
||||
import org.jetbrains.jet.utils.*
|
||||
|
||||
public object JetPsiPrecedences {
|
||||
|
||||
@@ -30,7 +31,7 @@ public object JetPsiPrecedences {
|
||||
private val precedence: Map<IElementType, Int>
|
||||
{
|
||||
val builder = HashMap<IElementType, Int>()
|
||||
for ((i, record) in JetExpressionParsing.Precedence.values().withIndices()) {
|
||||
for ((i, record) in JetExpressionParsing.Precedence.values().withIndices_tmp()) {
|
||||
for (elementType in record.getOperations().getTypes()) {
|
||||
builder[elementType] = i
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user