Fix "infix modifier required" errors in project

This commit is contained in:
Yan Zhulanow
2015-11-24 17:27:48 +03:00
parent d1c5bd4526
commit 46ac3571d5
44 changed files with 65 additions and 65 deletions
@@ -26,7 +26,7 @@ public fun getTypeSubstitution(baseType: KotlinType, derivedType: KotlinType): L
val substitutedType = TypeCheckingProcedure.findCorrespondingSupertype(derivedType, baseType) ?: return null
val substitution = LinkedHashMap<TypeConstructor, TypeProjection>(substitutedType.getArguments().size())
for ((param, arg) in baseType.getConstructor().getParameters() zip substitutedType.getArguments()) {
for ((param, arg) in baseType.getConstructor().getParameters().zip(substitutedType.getArguments())) {
substitution[param.getTypeConstructor()] = arg
}
@@ -41,7 +41,7 @@ public fun getCallableSubstitution(
val derivedClass = derivedCallable.getContainingDeclaration() as? ClassDescriptor ?: return null
val substitution = getTypeSubstitution(baseClass.getDefaultType(), derivedClass.getDefaultType()) ?: return null
for ((baseParam, derivedParam) in baseCallable.getTypeParameters() zip derivedCallable.getTypeParameters()) {
for ((baseParam, derivedParam) in baseCallable.getTypeParameters().zip(derivedCallable.getTypeParameters())) {
substitution[baseParam.getTypeConstructor()] = TypeProjectionImpl(derivedParam.getDefaultType())
}
@@ -81,7 +81,7 @@ public abstract class AbstractKtReference<T : KtElement>(element: T)
private fun resolveToPsiElements(context: BindingContext, targetDescriptors: Collection<DeclarationDescriptor>): Collection<PsiElement> {
if (targetDescriptors.isNotEmpty()) {
return targetDescriptors flatMap { target -> resolveToPsiElements(target) }
return targetDescriptors.flatMap { target -> resolveToPsiElements(target) }
}
val labelTargets = getLabelTargets(context)
@@ -24,10 +24,10 @@ import com.intellij.psi.search.SearchScope
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.psi.KtFile
public fun SearchScope.and(otherScope: SearchScope): SearchScope = intersectWith(otherScope)
public fun SearchScope.or(otherScope: SearchScope): SearchScope = union(otherScope)
public fun SearchScope.minus(otherScope: GlobalSearchScope): SearchScope = this and !otherScope
public fun GlobalSearchScope.not(): GlobalSearchScope = GlobalSearchScope.notScope(this)
infix fun SearchScope.and(otherScope: SearchScope): SearchScope = intersectWith(otherScope)
infix fun SearchScope.or(otherScope: SearchScope): SearchScope = union(otherScope)
operator fun SearchScope.minus(otherScope: GlobalSearchScope): SearchScope = this and !otherScope
operator fun GlobalSearchScope.not(): GlobalSearchScope = GlobalSearchScope.notScope(this)
public fun Project.allScope(): GlobalSearchScope = GlobalSearchScope.allScope(this)
@@ -103,8 +103,8 @@ abstract class CompletionSession(
protected val bindingContext = resolutionFacade.analyze(position.parentsWithSelf.firstIsInstance<KtElement>(), BodyResolveMode.PARTIAL_FOR_COMPLETION)
protected val inDescriptor = position.getResolutionScope(bindingContext, resolutionFacade).ownerDescriptor
private val kotlinIdentifierStartPattern = StandardPatterns.character().javaIdentifierStart() andNot singleCharPattern('$')
private val kotlinIdentifierPartPattern = StandardPatterns.character().javaIdentifierPart() andNot singleCharPattern('$')
private val kotlinIdentifierStartPattern = StandardPatterns.character().javaIdentifierStart().andNot(singleCharPattern('$'))
private val kotlinIdentifierPartPattern = StandardPatterns.character().javaIdentifierPart().andNot(singleCharPattern('$'))
protected val prefix = CompletionUtil.findIdentifierPrefix(
parameters.getPosition().getContainingFile(),
@@ -123,7 +123,7 @@ abstract class CompletionSession(
nameFilter
}
private fun ((Name) -> Boolean).or(otherFilter: (Name) -> Boolean): (Name) -> Boolean
private infix fun ((Name) -> Boolean).or(otherFilter: (Name) -> Boolean): (Name) -> Boolean
= { this(it) || otherFilter(it) }
protected val isVisibleFilter: (DeclarationDescriptor) -> Boolean = { isVisibleDescriptor(it, completeNonAccessible = configuration.completeNonAccessibleDeclarations) }
@@ -345,9 +345,9 @@ fun shortenReferences(context: InsertionContext, startOffset: Int, endOffset: In
ShortenReferences.DEFAULT.process(context.file as KtFile, startOffset, endOffset)
}
fun <T> ElementPattern<T>.and(rhs: ElementPattern<T>) = StandardPatterns.and(this, rhs)
infix fun <T> ElementPattern<T>.and(rhs: ElementPattern<T>) = StandardPatterns.and(this, rhs)
fun <T> ElementPattern<T>.andNot(rhs: ElementPattern<T>) = StandardPatterns.and(this, StandardPatterns.not(rhs))
fun <T> ElementPattern<T>.or(rhs: ElementPattern<T>) = StandardPatterns.or(this, rhs)
infix fun <T> ElementPattern<T>.or(rhs: ElementPattern<T>) = StandardPatterns.or(this, rhs)
fun singleCharPattern(char: Char) = StandardPatterns.character().equalTo(char)
@@ -215,7 +215,7 @@ public class KotlinCompletionContributor : CompletionContributor() {
if (tokenType == KtTokens.FUN_KEYWORD) {
tail += "()"
}
builder append tail
builder.append(tail)
val text = builder.toString()
val file = KtPsiFactory(tokenBefore.getProject()).createFile(text)
@@ -28,7 +28,7 @@ public class ConsoleErrorRenderer(private val messages: List<SeverityDetails>) :
}
override fun getTooltipText(): String {
val htmlTooltips = messages map { "<b>${msgType(it.severity)}</b> ${it.description}" }
val htmlTooltips = messages.map { "<b>${msgType(it.severity)}</b> ${it.description}" }
return "<html>${htmlTooltips.joinToString("<hr size=1 noshade>")}</html>"
}
@@ -85,7 +85,7 @@ public fun getOverriddenMethodTooltip(method: PsiMethod): String? {
val comparator = MethodCellRenderer(false).getComparator()
val overridingJavaMethods = processor.getCollection().filter { !it.isMethodWithDeclarationInOtherClass() } sortedWith (comparator)
val overridingJavaMethods = processor.getCollection().filter { !it.isMethodWithDeclarationInOtherClass() }.sortedWith(comparator)
if (overridingJavaMethods.isEmpty()) return null
val start = if (isAbstract) DaemonBundle.message("method.is.implemented.header") else DaemonBundle.message("method.is.overriden.header")
@@ -377,7 +377,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
fakeFunction: FunctionDescriptor,
typeArguments: Set<KotlinType>,
result: MutableMap<KotlinType, KotlinType>) {
for ((typeArgument, typeParameter) in typeArguments zip fakeFunction.getTypeParameters()) {
for ((typeArgument, typeParameter) in typeArguments.zip(fakeFunction.getTypeParameters())) {
result[typeArgument] = typeParameter.getDefaultType()
}
}
@@ -43,7 +43,7 @@ internal class ParameterNameExpression(
private val names: Array<String>,
private val parameterTypeToNamesMap: Map<String, Array<String>>) : Expression() {
init {
assert(names all { it.isNotEmpty() })
assert(names.all { it.isNotEmpty() })
}
override fun calculateResult(context: ExpressionContext?): Result? {
@@ -276,7 +276,7 @@ private fun TypePredicate.getRepresentativeTypes(): Set<KotlinType> {
is AllSubtypes -> Collections.singleton(upperBound)
is ForAllTypes -> {
if (typeSets.isEmpty()) AllTypes.getRepresentativeTypes()
else typeSets.map { it.getRepresentativeTypes() }.reduce { a, b -> a intersect b }
else typeSets.map { it.getRepresentativeTypes() }.reduce { a, b -> a.intersect(b) }
}
is ForSomeType -> typeSets.flatMapTo(LinkedHashSet<KotlinType>()) { it.getRepresentativeTypes() }
is AllTypes -> emptySet()
@@ -109,7 +109,7 @@ public abstract class CallableRefactoring<T: CallableDescriptor>(
public fun run(): Boolean {
fun buttonPressed(code: Int, dialogButtons: List<String>, button: String): Boolean {
return code == dialogButtons indexOf button && button in dialogButtons
return code == dialogButtons.indexOf(button) && button in dialogButtons
}
fun performForWholeHierarchy(dialogButtons: List<String>, code: Int): Boolean {
@@ -337,7 +337,7 @@ public open class KotlinChangeInfo(
if (!(isPrimaryMethodUpdated
&& originalBaseFunctionDescriptor is FunctionDescriptor
&& originalBaseFunctionDescriptor.hasJvmOverloadsAnnotation())) {
return (originalPsiMethods zip currentPsiMethods).toMap()
return (originalPsiMethods.zip(currentPsiMethods)).toMap()
}
if (originalPsiMethods.isEmpty() || currentPsiMethods.isEmpty()) return emptyMap()
@@ -158,7 +158,7 @@ public class KotlinChangeSignature(project: Project,
// TODO: Support visibility change
val visibility = VisibilityUtil.getVisibilityModifier(originalMethod.getModifierList())
val returnType = CanonicalTypes.createTypeWrapper(preview.getReturnType() ?: PsiType.VOID)
val params = (preview.getParameterList().getParameters() zip ktChangeInfo.getNewParameters()).map {
val params = (preview.getParameterList().getParameters().zip(ktChangeInfo.getNewParameters())).map {
val (param, paramInfo) = it
// Keep original default value for proper update of Kotlin usages
KotlinAwareJavaParameterInfoImpl(paramInfo.getOldIndex(), param.getName()!!, param.getType(), paramInfo.defaultValueForCall)
@@ -213,7 +213,7 @@ fun ExtractableCodeDescriptor.findDuplicates(): List<DuplicateInfo> {
.originalRange
.match(scopeElement, unifier)
.asSequence()
.filter { !(it.range.getPhysicalTextRange() intersects originalTextRange) }
.filter { !(it.range.getPhysicalTextRange().intersects(originalTextRange)) }
.mapNotNull { match ->
val controlFlow = getControlFlowIfMatched(match)
val range = with(match.range) {
@@ -179,7 +179,7 @@ fun selectNewParameterContext(
file = file,
getContainers = { elements, parent ->
val parents = parent.parents
val stopAt = (parent.parents zip parent.parents.drop(1))
val stopAt = (parent.parents.zip(parent.parents.drop(1)))
.firstOrNull { isObjectOrNonInnerClass(it.first) }
?.second
@@ -337,7 +337,7 @@ object KotlinIntroduceVariableHandler : KotlinIntroduceHandlerBase() {
private fun KtElement.getContainer(): KtElement? {
if (this is KtBlockExpression) return this
return (parentsWithSelf zip parents).firstOrNull {
return (parentsWithSelf.zip(parents)).firstOrNull {
val (place, parent) = it
when (parent) {
is KtContainerNode -> !parent.isBadContainerNode(place)
@@ -361,7 +361,7 @@ object KotlinIntroduceVariableHandler : KotlinIntroduceHandlerBase() {
private fun KtExpression.getOccurrenceContainer(): KtElement? {
var result: KtElement? = null
for ((place, parent) in parentsWithSelf zip parents) {
for ((place, parent) in parentsWithSelf.zip(parents)) {
when {
parent is KtContainerNode && place !is KtBlockExpression && !parent.isBadContainerNode(place) -> result = parent
parent is KtClassBody, parent is KtFile -> return result
@@ -301,7 +301,7 @@ public class MoveKotlinTopLevelDeclarationsProcessor(
oldToNewElementsMapping[sourceFile] = newDeclaration.getContainingKtFile()
getTransaction()!!.getElementListener(oldDeclaration).elementMoved(newDeclaration)
for ((oldElement, newElement) in oldLightElements.asSequence() zip newDeclaration.toLightElements().asSequence()) {
for ((oldElement, newElement) in oldLightElements.asSequence().zip(newDeclaration.toLightElements().asSequence())) {
oldToNewElementsMapping[oldElement] = newElement
}
}
@@ -194,12 +194,12 @@ public class KotlinPsiUnifier(
if (args1.size() != args2.size()) return UNMATCHED
if (rc1.getCall().getValueArguments().size() != args1.size() || rc2.getCall().getValueArguments().size() != args2.size()) return null
return (args1.asSequence() zip args2.asSequence()).fold(MATCHED) { s, p ->
return (args1.asSequence().zip(args2.asSequence())).fold(MATCHED) { s, p ->
val (arg1, arg2) = p
s and when {
arg1 == arg2 -> MATCHED
arg1 == null || arg2 == null -> UNMATCHED
else -> (arg1.getArguments().asSequence() zip arg2.getArguments().asSequence()).fold(MATCHED) { s, p ->
else -> (arg1.getArguments().asSequence().zip(arg2.getArguments().asSequence())).fold(MATCHED) { s, p ->
s and matchArguments(p.first, p.second)
}
}
@@ -250,7 +250,7 @@ public class KotlinPsiUnifier(
val typeArgs2 = rc2.getTypeArguments().toList()
if (typeArgs1.size() != typeArgs2.size()) return UNMATCHED
for ((typeArg1, typeArg2) in (typeArgs1 zip typeArgs2)) {
for ((typeArg1, typeArg2) in (typeArgs1.zip(typeArgs2))) {
if (!matchDescriptors(typeArg1.first, typeArg2.first)) return UNMATCHED
val s = matchTypes(typeArg1.second, typeArg2.second)
@@ -354,7 +354,7 @@ public class KotlinPsiUnifier(
fun sortTypes(types: Collection<KotlinType>) = types.sortedBy { DescriptorRenderer.DEBUG_TEXT.renderType(it) }
if (types1.size() != types2.size()) return false
return (sortTypes(types1) zip sortTypes(types2)).all { matchTypes(it.first, it.second) == MATCHED }
return (sortTypes(types1).zip(sortTypes(types2))).all { matchTypes(it.first, it.second) == MATCHED }
}
private fun KtElement.shouldIgnoreResolvedCall(): Boolean {
@@ -527,7 +527,7 @@ public class KotlinPsiUnifier(
declarations2: List<T>,
matchPair: (Pair<T, T>) -> Boolean
): Boolean {
val zippedParams = declarations1 zip declarations2
val zippedParams = declarations1.zip(declarations2)
if (declarations1.size() != declarations2.size() || !zippedParams.all { matchPair(it) }) return false
zippedParams.forEach { declarationPatternsToTargets.putValue(it.first, it.second) }
@@ -777,7 +777,7 @@ public class KotlinPsiUnifier(
val patternElements = pattern.elements
if (targetElements.size() != patternElements.size()) return UNMATCHED
return (targetElements.asSequence() zip patternElements.asSequence()).fold(MATCHED) { s, p ->
return (targetElements.asSequence().zip(patternElements.asSequence())).fold(MATCHED) { s, p ->
if (s != UNMATCHED) s and doUnify(p.first, p.second) else s
}
}