Migrate kotlin sources, maven projects and stdlib to new lambda syntax

This commit is contained in:
Stanislav Erokhin
2015-04-01 16:36:44 +03:00
parent e0988de707
commit b703f59e04
74 changed files with 136 additions and 140 deletions
@@ -96,7 +96,7 @@ public abstract class CoveringTryCatchNodeProcessor<T: IntervalWithHandler>() {
}
public fun sortTryCatchBlocks() {
val comp = Comparator {(t1: T, t2: T): Int ->
val comp = Comparator { t1: T, t2: T ->
var result = instructionIndex(t1.handler) - instructionIndex(t2.handler)
if (result == 0) {
result = instructionIndex(t1.startLabel) - instructionIndex(t2.startLabel)
@@ -44,7 +44,7 @@ public class SMAPBuilder(val source: String,
return null;
}
val fileIds = "*F" + realMappings.mapIndexed {(id, file) -> "\n${file.toSMAPFile(id + 1)}" }.join("")
val fileIds = "*F" + realMappings.mapIndexed { id, file -> "\n${file.toSMAPFile(id + 1)}" }.join("")
val lineMappings = "*L" + realMappings.map { it.toSMAPMapping() }.join("")
return "$header\n$fileIds\n$lineMappings\n*E\n"
@@ -72,7 +72,7 @@ public open class NestedSourceMapper(parent: SourceMapper, val ranges: List<Rang
override fun visitLineNumber(iv: MethodVisitor, lineNumber: Int, start: Label) {
val index = Collections.binarySearch(ranges, RangeMapping(lineNumber, lineNumber, 1)) {
(value, key) ->
value, key ->
if (value.contains(key.dest)) 0 else RangeMapping.Comparator.compare(value, key)
}
if (index < 0) {
@@ -107,7 +107,7 @@ public open class InlineLambdaSourceMapper(parent: SourceMapper, smap: SMAPAndMe
override fun visitLineNumber(iv: MethodVisitor, lineNumber: Int, start: Label) {
val index = Collections.binarySearch(ranges, RangeMapping(lineNumber, lineNumber, 1)) {
(value, key) ->
value, key ->
if (value.contains(key.dest)) 0 else RangeMapping.Comparator.compare(value, key)
}
if (index >= 0) {
@@ -31,7 +31,7 @@ class SMAPAndMethodNode(val node: MethodNode, val classSMAP: SMAP) {
val lineNumbers =
InsnStream(node.instructions.getFirst(), null).stream().filterIsInstance<LineNumberNode>().map {
val index = Collections.binarySearch(classSMAP.intervals, RangeMapping(it.line, it.line, 1)) {
(value, key) ->
value, key ->
if (value.contains(key.dest)) 0 else RangeMapping.Comparator.compare(value, key)
}
if (index < 0)
@@ -33,7 +33,7 @@ public fun OutputFileCollection.writeAll(outputDir: File, report: (sources: List
}
}
private val REPORT_NOTHING = { (sources: List<File>, output: File) -> }
private val REPORT_NOTHING = { sources: List<File>, output: File -> }
public fun OutputFileCollection.writeAllTo(outputDir: File) {
writeAll(outputDir, REPORT_NOTHING)
@@ -43,7 +43,7 @@ public class PseudocodeVariableDataCollector(
//see KT-4605
instructionDataMergeStrategy as
(Instruction, Collection<Map<VariableDescriptor, D>>) -> Edges<Map<VariableDescriptor, D>>,
{ (from, to, data) -> filterOutVariablesOutOfScope(from, to, data)},
{ from, to, data -> filterOutVariablesOutOfScope(from, to, data)},
Collections.emptyMap<VariableDescriptor, D>())
//see KT-4605
return result as MutableMap<Instruction, Edges<MutableMap<VariableDescriptor, D>>>
@@ -84,4 +84,4 @@ fun JetType.getSubtypesPredicate(): TypePredicate {
private fun JetType.render(): String = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(this)
public fun <T> TypePredicate.expectedTypeFor(keys: Iterable<T>): Map<T, TypePredicate> =
keys.fold(SmartFMap.emptyMap<T, TypePredicate>()) { (map, key) -> map.plus(key, this) }
keys.fold(SmartFMap.emptyMap<T, TypePredicate>()) { map, key -> map.plus(key, this) }
@@ -49,7 +49,7 @@ public object Renderers {
private val LOG = Logger.getInstance(javaClass<Renderers>())
public val TO_STRING: Renderer<Any> = Renderer {
(element) ->
element ->
if (element is DeclarationDescriptor) {
LOG.warn("Diagnostic renderer TO_STRING was used to render an instance of DeclarationDescriptor.\n"
+ "This is usually a bad idea, because descriptors' toString() includes some debug information, "
@@ -67,7 +67,7 @@ public object Renderers {
public val DECLARATION_NAME: Renderer<JetNamedDeclaration> = Renderer { it.getNameAsSafeName().asString() }
public val RENDER_CLASS_OR_OBJECT: Renderer<JetClassOrObject> = Renderer {
(classOrObject: JetClassOrObject) ->
classOrObject: JetClassOrObject ->
val name = if (classOrObject.getName() != null) " '" + classOrObject.getName() + "'" else ""
if (classOrObject is JetClass) "Class" + name else "Object" + name
}
@@ -77,7 +77,7 @@ public object Renderers {
public val RENDER_TYPE: Renderer<JetType> = Renderer { DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(it) }
public val RENDER_POSITION_VARIANCE: Renderer<Variance> = Renderer {
(variance: Variance) ->
variance: Variance ->
when (variance) {
Variance.INVARIANT -> "invariant"
Variance.IN_VARIANCE -> "in"
@@ -86,7 +86,7 @@ public object Renderers {
}
public val AMBIGUOUS_CALLS: Renderer<Collection<ResolvedCall<*>>> = Renderer {
(argument: Collection<ResolvedCall<*>>) ->
argument: Collection<ResolvedCall<*>> ->
val stringBuilder = StringBuilder("\n")
for (call in argument) {
stringBuilder.append(DescriptorRenderer.FQ_NAMES_IN_TYPES.render(call.getResultingDescriptor())).append("\n")
@@ -356,7 +356,7 @@ public object Renderers {
public val RENDER_CONSTRAINT_SYSTEM: Renderer<ConstraintSystem> = Renderer { renderConstraintSystem(it) }
private fun renderTypeBounds(typeBounds: TypeBounds): String {
val renderBound = { (bound: Bound) ->
val renderBound = { bound: Bound ->
val arrow = if (bound.kind == LOWER_BOUND) ">: " else if (bound.kind == UPPER_BOUND) "<: " else ":= "
arrow + RENDER_TYPE.render(bound.constrainingType) + '(' + bound.position + ')'
}
@@ -368,13 +368,13 @@ public fun JetExpression.isFunctionLiteralOutsideParentheses(): Boolean {
}
public fun PsiElement.siblings(forward: Boolean = true, withItself: Boolean = true): Stream<PsiElement> {
val stepFun = if (forward) { (e: PsiElement) -> e.getNextSibling() } else { (e: PsiElement) -> e.getPrevSibling() }
val stepFun = if (forward) { e: PsiElement -> e.getNextSibling() } else { e: PsiElement -> e.getPrevSibling() }
val stream = stream(this, stepFun)
return if (withItself) stream else stream.drop(1)
}
public fun ASTNode.siblings(forward: Boolean = true, withItself: Boolean = true): Stream<ASTNode> {
val stepFun = if (forward) { (node: ASTNode) -> node.getTreeNext() } else { (e: ASTNode) -> e.getTreeNext() }
val stepFun = if (forward) { node: ASTNode -> node.getTreeNext() } else { e: ASTNode -> e.getTreeNext() }
val stream = stream(this, stepFun)
return if (withItself) stream else stream.drop(1)
}
@@ -72,7 +72,7 @@ object DescriptorEquivalenceForOverrides {
if (!ownersEquivalent(a, b, {x, y -> false})) return false
val overridingUtil = OverridingUtil.createWithEqualityAxioms @eq {
(c1, c2): Boolean ->
c1, c2 ->
if (c1 == c2) return@eq true
val d1 = c1.getDeclarationDescriptor()
@@ -81,7 +81,7 @@ private class ExplicitTypeBinding(
jetType.isError() || !sizeIsEqual
}
return psiTypeArguments.indices.map { (index: Int): TypeArgumentBinding<JetTypeElement>? ->
return psiTypeArguments.indices.map { index: Int ->
// todo fix for List<*>
val jetTypeReference = psiTypeArguments[index]
val jetTypeElement = jetTypeReference?.getTypeElement()
@@ -53,7 +53,7 @@ public class LazyAnnotations(
override fun isEmpty() = annotationEntries.isEmpty()
private val annotation = c.storageManager.createMemoizedFunction {
(entry: JetAnnotationEntry) ->
entry: JetAnnotationEntry ->
LazyAnnotationDescriptor(c, entry)
}
@@ -79,7 +79,7 @@ public class LoggingStorageManager(
}
val containingField = if (outerInstance == null) null
else outerClass?.getAllDeclaredFields()?.firstOrNull {
(field): Boolean ->
field ->
field.setAccessible(true)
val value = field.get(outerInstance)
if (value == null) return@firstOrNull false
@@ -146,7 +146,7 @@ public class CapturedTypeApproximationTest() : JetLiteFixture() {
addRandomVariants("00200", "22213", "12114", "20304", "34014", "41333", "11214", "02004", "43244", "03004")
addRandomVariants("021022", "124230", "210030", "202344", "043234", "024400", "102121", "423143", "132121", "233001")
return variants.map { it.fold("#T#") {(type, index) -> type.replace("#T#", typePatterns[index]) } }
return variants.map { it.fold("#T#") { type, index -> type.replace("#T#", typePatterns[index]) } }
}
private fun getTestTypesForTwoTypeVariables(): List<String> {
@@ -119,11 +119,11 @@ public object LibraryUtils {
for (lib in libs) {
when {
lib.isDirectory() ->
traverseDirectory(lib) { (file, path) ->
traverseDirectory(lib) { file, path ->
files.add(FileUtil.loadFile(file))
}
FileUtil.isJarOrZip(lib) ->
traverseArchive(lib) { (content, path) ->
traverseArchive(lib) { content, path ->
files.add(content)
}
lib.getName().endsWith(KotlinJavascriptMetadataUtils.JS_EXT) ->