Stop using deprecated APIs

This commit is contained in:
Ilya Ryzhenkov
2014-12-02 15:41:22 +03:00
parent 2b8ffeda28
commit be717f48f8
45 changed files with 111 additions and 112 deletions
@@ -30,7 +30,7 @@ public class JsFunctionScope(parent: JsScope, description: String) : JsScope(par
private val labelScopes = Stack<LabelScope>()
private val topLabelScope: LabelScope?
get() = if (labelScopes.notEmpty) labelScopes.peek() else null
get() = if (labelScopes.isNotEmpty()) labelScopes.peek() else null
override fun declareName(identifier: String): JsName = super.declareFreshName(identifier)
@@ -45,7 +45,7 @@ public class JsFunctionScope(parent: JsScope, description: String) : JsScope(par
}
public fun exitLabel() {
assert(labelScopes.notEmpty) { "No scope to exit from" }
assert(labelScopes.isNotEmpty()) { "No scope to exit from" }
labelScopes.pop()
}
@@ -96,7 +96,7 @@ private fun isNameInitialized(
initializer: JsStatement
): Boolean {
val thenStmt = (initializer as JsIf).getThenStatement()!!
val lastThenStmt = flattenStatement(thenStmt).last
val lastThenStmt = flattenStatement(thenStmt).last()
val expr = (lastThenStmt as? JsExpressionStatement)?.getExpression()
if (expr !is JsBinaryOperation) return false
@@ -88,7 +88,7 @@ public fun isCallInvocation(invocation: JsInvocation): Boolean {
val qualifier = invocation.getQualifier() as? JsNameRef
val arguments = invocation.getArguments()
return qualifier?.getIdent() == Namer.CALL_FUNCTION && arguments.notEmpty
return qualifier?.getIdent() == Namer.CALL_FUNCTION && arguments.isNotEmpty()
}
/**
@@ -34,7 +34,7 @@ public fun aliasArgumentsIfNeeded(
arguments: List<JsExpression>,
parameters: List<JsParameter>
) {
assertTrue { arguments.size <= parameters.size }
assertTrue { arguments.size() <= parameters.size() }
for ((arg, param) in arguments zip parameters) {
val paramName = param.getName()
@@ -50,7 +50,7 @@ public fun aliasArgumentsIfNeeded(
context.replaceName(paramName, replacement)
}
val defaultParams = parameters.subList(arguments.size, parameters.size)
val defaultParams = parameters.subList(arguments.size(), parameters.size())
for (defaultParam in defaultParams) {
val paramName = defaultParam.getName()
val freshName = context.getFreshName(paramName)
+1 -1
View File
@@ -8,7 +8,7 @@ public inline fun String.indexOf(ch : Char, fromIndex : Int) : Int = indexOf(ch.
public inline fun String.matches(regex : String) : Boolean {
val result = this.match(regex)
return result != null && result.size > 0
return result != null && result.size() > 0
}
/**
@@ -73,7 +73,7 @@ public fun UsageTracker.getNameForCapturedDescriptor(descriptor: CallableDescrip
public fun UsageTracker.hasCapturedExceptContaining(): Boolean {
val hasNotCaptured =
capturedDescriptorToJsName.isEmpty() ||
(capturedDescriptorToJsName.size == 1 && capturedDescriptorToJsName.containsKey(containingDescriptor))
(capturedDescriptorToJsName.size() == 1 && capturedDescriptorToJsName.containsKey(containingDescriptor))
return !hasNotCaptured
}
@@ -67,9 +67,9 @@ class CatchTranslator(
* }
*/
public fun translate(): JsCatch? {
if (catches.empty) return null
if (catches.isEmpty()) return null
val firstCatch = catches.first!!
val firstCatch = catches.first()
val catchParameter = firstCatch.getCatchParameter()
val parameterName = context().getNameForElement(catchParameter!!)
val parameterRef = parameterName.makeRef()