Code cleanup: several inspections applied

This commit is contained in:
Mikhail Glukhikh
2017-06-27 14:26:19 +03:00
committed by Mikhail Glukhikh
parent fdca96634e
commit 840847e47c
76 changed files with 121 additions and 147 deletions
@@ -71,7 +71,7 @@ class NondeterministicJumpInstruction(
override fun toString(): String {
val inVal = if (inputValue != null) "|$inputValue" else ""
val labels = targetLabels.map { it.name }.joinToString(", ")
val labels = targetLabels.joinToString(", ") { it.name }
return "jmp?($labels$inVal)"
}
@@ -285,7 +285,7 @@ private object DebugTextBuildingVisitor : KtVisitor<String, Unit>() {
fun render(element: KtElementImplStub<*>, vararg relevantChildren: KtElement?): String? {
if (element.stub == null) return element.text
return relevantChildren.filterNotNull().map { it.getDebugText() }.joinToString("", "", "")
return relevantChildren.filterNotNull().joinToString("", "", "") { it.getDebugText() }
}
}
@@ -97,7 +97,7 @@ private val SUPPORTED_ARGUMENT_TYPES = listOf(
fun <TElement : KtElement> createByPattern(pattern: String, vararg args: Any, reformat: Boolean = true, factory: (String) -> TElement): TElement {
val argumentTypes = args.map { arg ->
SUPPORTED_ARGUMENT_TYPES.firstOrNull { it.klass.isInstance(arg) }
?: throw IllegalArgumentException("Unsupported argument type: ${arg::class.java}, should be one of: ${SUPPORTED_ARGUMENT_TYPES.map { it.klass.simpleName }.joinToString()}")
?: throw IllegalArgumentException("Unsupported argument type: ${arg::class.java}, should be one of: ${SUPPORTED_ARGUMENT_TYPES.joinToString { it.klass.simpleName }}")
}
// convert arguments that can be converted into plain text
@@ -33,7 +33,7 @@ val STUB_TO_STRING_PREFIX = "KotlinStub$"
open class KotlinStubBaseImpl<T : KtElementImplStub<*>>(parent: StubElement<*>?, elementType: IStubElementType<*, *>) : StubBase<T>(parent, elementType) {
override fun toString(): String {
val stubInterface = this::class.java.interfaces.filter { it.name.contains("Stub") }.single()
val stubInterface = this::class.java.interfaces.single { it.name.contains("Stub") }
val propertiesValues = renderPropertyValues(stubInterface)
if (propertiesValues.isEmpty()) {
return "$STUB_TO_STRING_PREFIX$stubType"
@@ -377,7 +377,7 @@ class CallCompleter(
expression = deparenthesizeOrGetSelector(expression)
}
var shouldBeMadeNullable: Boolean = false
var shouldBeMadeNullable = false
expressions.asReversed().forEach { expression ->
if (!(expression is KtParenthesizedExpression || expression is KtLabeledExpression || expression is KtAnnotatedExpression)) {
shouldBeMadeNullable = hasNecessarySafeCall(expression, trace)
@@ -198,12 +198,12 @@ class NewResolutionOldInference(
tracing: TracingStrategy,
candidates: Collection<ResolutionCandidate<D>>
): OverloadResolutionResultsImpl<D> {
val resolvedCandidates = candidates.mapNotNull { candidate ->
val resolvedCandidates = candidates.map { candidate ->
val candidateTrace = TemporaryBindingTrace.create(basicCallContext.trace, "Context for resolve candidate")
val resolvedCall = ResolvedCallImpl.create(candidate, candidateTrace, tracing, basicCallContext.dataFlowInfoForArguments)
if (candidate.descriptor.isHiddenInResolution(languageVersionSettings, basicCallContext.isSuperCall)) {
return@mapNotNull MyCandidate(ResolutionCandidateStatus(listOf(HiddenDescriptor)), resolvedCall)
return@map MyCandidate(ResolutionCandidateStatus(listOf(HiddenDescriptor)), resolvedCall)
}
val callCandidateResolutionContext = CallCandidateResolutionContext.create(
@@ -238,7 +238,7 @@ class NewResolutionOldInference(
basicCallContext: BasicCallResolutionContext,
languageVersionSettings: LanguageVersionSettings
): OverloadResolutionResultsImpl<D> {
val resolvedCalls = candidates.mapNotNull {
val resolvedCalls = candidates.map {
val (status, resolvedCall) = it
if (resolvedCall is VariableAsFunctionResolvedCallImpl) {
// todo hacks