More cleanup: lift return / assignment out
This commit is contained in:
@@ -500,9 +500,9 @@ class ExpectedInfos(
|
||||
if (expressionWithType != block.statements.last()) return null
|
||||
|
||||
val functionLiteral = block.parent as? KtFunctionLiteral
|
||||
if (functionLiteral != null) {
|
||||
return if (functionLiteral != null) {
|
||||
val literalExpression = functionLiteral.parent as KtLambdaExpression
|
||||
return calculate(literalExpression)
|
||||
calculate(literalExpression)
|
||||
.mapNotNull { it.fuzzyType }
|
||||
.filter { it.type.isFunctionType }
|
||||
.map {
|
||||
@@ -511,7 +511,7 @@ class ExpectedInfos(
|
||||
}
|
||||
}
|
||||
else {
|
||||
return calculate(block).map { ExpectedInfo(it.filter, it.expectedName, null) }
|
||||
calculate(block).map { ExpectedInfo(it.filter, it.expectedName, null) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -287,12 +287,12 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
|
||||
val tryImport = result.descriptors.isNotEmpty()
|
||||
&& result.descriptors.none { it in failedToImportDescriptors }
|
||||
&& result.descriptors.all { mayImport(it, file) }
|
||||
if (tryImport) {
|
||||
toBeShortened = if (tryImport) {
|
||||
descriptorsToImport.addAll(result.descriptors)
|
||||
toBeShortened = true
|
||||
true
|
||||
}
|
||||
else {
|
||||
toBeShortened = false
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,11 +548,11 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
|
||||
|
||||
private fun targetsMatch(targets1: Collection<DeclarationDescriptor>, targets2: Collection<DeclarationDescriptor>): Boolean {
|
||||
if (targets1.size != targets2.size) return false
|
||||
if (targets1.size == 1) {
|
||||
return targets1.single().asString() == targets2.single().asString()
|
||||
return if (targets1.size == 1) {
|
||||
targets1.single().asString() == targets2.single().asString()
|
||||
}
|
||||
else {
|
||||
return targets1.map { it.asString() }.toSet() == targets2.map { it.asString() }.toSet()
|
||||
targets1.map { it.asString() }.toSet() == targets2.map { it.asString() }.toSet()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,13 +77,13 @@ abstract class TypesWithOperatorDetector(
|
||||
}
|
||||
|
||||
fun findOperator(type: FuzzyType): Pair<FunctionDescriptor, TypeSubstitutor>? {
|
||||
if (cache.containsKey(type)) {
|
||||
return cache[type]
|
||||
return if (cache.containsKey(type)) {
|
||||
cache[type]
|
||||
}
|
||||
else {
|
||||
val result = findOperatorNoCache(type)
|
||||
cache[type] = result
|
||||
return result
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,15 +118,17 @@ fun compareDescriptors(project: Project, currentDescriptor: DeclarationDescripto
|
||||
|
||||
fun Visibility.toKeywordToken(): KtModifierKeywordToken {
|
||||
val normalized = normalize()
|
||||
when (normalized) {
|
||||
Visibilities.PUBLIC -> return KtTokens.PUBLIC_KEYWORD
|
||||
Visibilities.PROTECTED -> return KtTokens.PROTECTED_KEYWORD
|
||||
Visibilities.INTERNAL -> return KtTokens.INTERNAL_KEYWORD
|
||||
return when (normalized) {
|
||||
Visibilities.PUBLIC -> KtTokens.PUBLIC_KEYWORD
|
||||
Visibilities.PROTECTED -> KtTokens.PROTECTED_KEYWORD
|
||||
Visibilities.INTERNAL -> KtTokens.INTERNAL_KEYWORD
|
||||
else -> {
|
||||
if (Visibilities.isPrivate(normalized)) {
|
||||
return KtTokens.PRIVATE_KEYWORD
|
||||
KtTokens.PRIVATE_KEYWORD
|
||||
}
|
||||
else {
|
||||
error("Unexpected visibility '$normalized'")
|
||||
}
|
||||
error("Unexpected visibility '$normalized'")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -60,11 +60,11 @@ interface OverrideMemberChooserObject : ClassMember {
|
||||
preferConstructorParameter: Boolean = false
|
||||
): OverrideMemberChooserObject {
|
||||
val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, descriptor)
|
||||
if (declaration != null) {
|
||||
return WithDeclaration(descriptor, declaration, immediateSuper, bodyType, preferConstructorParameter)
|
||||
return if (declaration != null) {
|
||||
WithDeclaration(descriptor, declaration, immediateSuper, bodyType, preferConstructorParameter)
|
||||
}
|
||||
else {
|
||||
return WithoutDeclaration(descriptor, immediateSuper, bodyType, preferConstructorParameter)
|
||||
WithoutDeclaration(descriptor, immediateSuper, bodyType, preferConstructorParameter)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -84,14 +84,14 @@ open class DescriptorMemberChooserObject(
|
||||
if (declaration != null && declaration.isValid) {
|
||||
val isClass = declaration is PsiClass || declaration is KtClass
|
||||
val flags = if (isClass) 0 else Iconable.ICON_FLAG_VISIBILITY
|
||||
if (declaration is KtDeclaration) {
|
||||
return if (declaration is KtDeclaration) {
|
||||
// kotlin declaration
|
||||
// visibility and abstraction better detect by a descriptor
|
||||
return KotlinDescriptorIconProvider.getIcon(descriptor, declaration, flags)
|
||||
KotlinDescriptorIconProvider.getIcon(descriptor, declaration, flags)
|
||||
}
|
||||
else {
|
||||
// it is better to show java icons for java code
|
||||
return declaration.getIcon(flags)
|
||||
declaration.getIcon(flags)
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user