Cleanup in idea plugin modules, ide-common

This commit is contained in:
Ilya Gorbunov
2015-12-29 04:12:47 +03:00
parent fcfb063eca
commit bce9514739
6 changed files with 14 additions and 14 deletions
@@ -50,7 +50,7 @@ public interface ResolutionFacade {
}
public inline fun <reified T : Any> ResolutionFacade.frontendService(): T
= this.getFrontendService(javaClass<T>())
= this.getFrontendService(T::class.java)
public inline fun <reified T : Any> ResolutionFacade.ideService(): T
= this.getIdeService(javaClass<T>())
= this.getIdeService(T::class.java)
@@ -143,7 +143,7 @@ class FuzzyType(
if (otherSubstitutedType.isError) return null
if (!substitutedType.checkInheritance(otherSubstitutedType)) return null
val substitution = constraintSystem.typeVariables.map { it.originalTypeParameter }.toMap({ it.typeConstructor }) {
val substitution = constraintSystem.typeVariables.map { it.originalTypeParameter }.toMapBy({ it.typeConstructor }) {
val type = it.defaultType
val solution = substitutor.substitute(type, Variance.INVARIANT)
TypeProjectionImpl(if (solution != null && !ErrorUtils.containsUninferredParameter(solution)) solution else type)
@@ -75,7 +75,7 @@ public class ShadowedDeclarationsFilter(
public fun <TDescriptor : DeclarationDescriptor> filter(declarations: Collection<TDescriptor>): Collection<TDescriptor> {
return declarations
.groupBy { signature(it) }
.values()
.values
.flatMap { group -> filterEqualSignatureGroup(group) }
}
@@ -129,7 +129,7 @@ public class ShadowedDeclarationsFilter(
val name = first.getName()
val parameters = (first as CallableDescriptor).getValueParameters()
val dummyArgumentExpressions = dummyExpressionFactory.createDummyExpressions(parameters.size())
val dummyArgumentExpressions = dummyExpressionFactory.createDummyExpressions(parameters.size)
val bindingTrace = DelegatingBindingTrace(bindingContext, "Temporary trace for filtering shadowed declarations")
for ((expression, parameter) in dummyArgumentExpressions.zip(parameters)) {
@@ -138,7 +138,7 @@ public class ShadowedDeclarationsFilter(
}
val firstVarargIndex = parameters.withIndex().firstOrNull { it.value.varargElementType != null }?.index
val useNamedFromIndex = if (firstVarargIndex != null && firstVarargIndex != parameters.lastIndex) firstVarargIndex else parameters.size()
val useNamedFromIndex = if (firstVarargIndex != null && firstVarargIndex != parameters.lastIndex) firstVarargIndex else parameters.size
class DummyArgument(val index: Int) : ValueArgument {
private val expression = dummyArgumentExpressions[index]
@@ -219,7 +219,7 @@ public class ShadowedDeclarationsFilter(
private val expressions = ArrayList<KtExpression>()
fun createDummyExpressions(count: Int): List<KtExpression> {
while (expressions.size() < count) {
while (expressions.size < count) {
expressions.add(factory.createExpression("dummy"))
}
return expressions.take(count)
@@ -233,7 +233,7 @@ public class ShadowedDeclarationsFilter(
if (function.getName() != other.function.getName()) return false
val parameters1 = function.getValueParameters()
val parameters2 = other.function.getValueParameters()
if (parameters1.size() != parameters2.size()) return false
if (parameters1.size != parameters2.size) return false
for (i in parameters1.indices) {
val p1 = parameters1[i]
val p2 = parameters2[i]
@@ -243,6 +243,6 @@ public class ShadowedDeclarationsFilter(
return true
}
override fun hashCode() = function.getName().hashCode() * 17 + function.getValueParameters().size()
override fun hashCode() = function.getName().hashCode() * 17 + function.getValueParameters().size
}
}
@@ -113,7 +113,7 @@ class PartialBodyResolveFilter(
val smartCastPlaces = potentialSmartCastPlaces(statement, { it.affectsNames(nameFilter) })
if (!smartCastPlaces.isEmpty()) {
//TODO: do we really need correct resolve for ALL smart cast places?
smartCastPlaces.values()
smartCastPlaces.values
.flatMap { it }
.forEach { statementMarks.mark(it, MarkLevel.NEED_REFERENCE_RESOLVE) }
updateNameFilter()
@@ -149,7 +149,7 @@ class PartialBodyResolveFilter(
fun addPlaces(name: SmartCastName, places: Collection<KtExpression>) {
if (places.isNotEmpty()) {
map.getOrPut(name, { ArrayList(places.size()) }).addAll(places)
map.getOrPut(name, { ArrayList(places.size) }).addAll(places)
}
}
@@ -597,7 +597,7 @@ class PartialBodyResolveFilter(
= statementMarks[statement] ?: MarkLevel.NONE
fun allMarkedStatements(): Collection<KtExpression>
= statementMarks.keySet()
= statementMarks.keys
fun lastMarkedStatement(block: KtBlockExpression, minLevel: MarkLevel): KtExpression? {
val level = blockLevels[block] ?: MarkLevel.NONE
@@ -51,7 +51,7 @@ public fun descriptorsEqualWithSubstitution(descriptor1: DeclarationDescriptor?,
val parameters1 = descriptor1.getValueParameters()
val parameters2 = descriptor2.getValueParameters()
if (parameters1.size() != parameters2.size()) return false
if (parameters1.size != parameters2.size) return false
for ((param1, param2) in parameters1.zip(parameters2)) {
if (!typeChecker.equalTypes(param1.getType(), param2.getType())) return false
}
@@ -25,7 +25,7 @@ import java.util.LinkedHashMap
public fun getTypeSubstitution(baseType: KotlinType, derivedType: KotlinType): LinkedHashMap<TypeConstructor, TypeProjection>? {
val substitutedType = TypeCheckingProcedure.findCorrespondingSupertype(derivedType, baseType) ?: return null
val substitution = LinkedHashMap<TypeConstructor, TypeProjection>(substitutedType.getArguments().size())
val substitution = LinkedHashMap<TypeConstructor, TypeProjection>(substitutedType.getArguments().size)
for ((param, arg) in baseType.getConstructor().getParameters().zip(substitutedType.getArguments())) {
substitution[param.getTypeConstructor()] = arg
}