"casted" -> "cast"

This commit is contained in:
Valentin Kipyatkov
2014-11-19 22:00:01 +03:00
parent 3e437adbb4
commit 6230ba7310
23 changed files with 36 additions and 36 deletions
@@ -122,8 +122,8 @@ class PartialBodyResolveFilter(
map.getOrPut(name, { ArrayList(places.size) }).addAll(places) map.getOrPut(name, { ArrayList(places.size) }).addAll(places)
} }
fun addIfCanBeSmartCasted(expression: JetExpression) { fun addIfCanBeSmartCast(expression: JetExpression) {
val name = expression.smartCastedExpressionName() ?: return val name = expression.smartCastExpressionName() ?: return
if (filter(name)) { if (filter(name)) {
addPlace(name, expression) addPlace(name, expression)
} }
@@ -134,7 +134,7 @@ class PartialBodyResolveFilter(
expression.acceptChildren(this) expression.acceptChildren(this)
if (expression.getOperationToken() == JetTokens.EXCLEXCL) { if (expression.getOperationToken() == JetTokens.EXCLEXCL) {
addIfCanBeSmartCasted(expression.getBaseExpression()) addIfCanBeSmartCast(expression.getBaseExpression())
} }
} }
@@ -142,7 +142,7 @@ class PartialBodyResolveFilter(
expression.acceptChildren(this) expression.acceptChildren(this)
if (expression.getOperationReference()?.getReferencedNameElementType() == JetTokens.AS_KEYWORD) { if (expression.getOperationReference()?.getReferencedNameElementType() == JetTokens.AS_KEYWORD) {
addIfCanBeSmartCasted(expression.getLeft()) addIfCanBeSmartCast(expression.getLeft())
} }
} }
@@ -151,11 +151,11 @@ class PartialBodyResolveFilter(
val thenBranch = expression.getThen() val thenBranch = expression.getThen()
val elseBranch = expression.getElse() val elseBranch = expression.getElse()
val smartCastedNames = collectPossiblySmartCastedInCondition(condition).filter(filter) val smartCastNames = collectPossiblySmartCastInCondition(condition).filter(filter)
if (smartCastedNames.isNotEmpty()) { if (smartCastNames.isNotEmpty()) {
val exits = collectAlwaysExitPoints(thenBranch) + collectAlwaysExitPoints(elseBranch) val exits = collectAlwaysExitPoints(thenBranch) + collectAlwaysExitPoints(elseBranch)
if (exits.isNotEmpty()) { if (exits.isNotEmpty()) {
for (name in smartCastedNames) { for (name in smartCastNames) {
addPlaces(name, exits) addPlaces(name, exits)
} }
} }
@@ -204,7 +204,7 @@ class PartialBodyResolveFilter(
return map return map
} }
private fun collectPossiblySmartCastedInCondition(condition: JetExpression?): Set<String> { private fun collectPossiblySmartCastInCondition(condition: JetExpression?): Set<String> {
val result = HashSet<String>() val result = HashSet<String>()
condition?.accept(object : ControlFlowVisitor() { condition?.accept(object : ControlFlowVisitor() {
override fun visitBinaryExpression(expression: JetBinaryExpression) { override fun visitBinaryExpression(expression: JetBinaryExpression) {
@@ -212,15 +212,15 @@ class PartialBodyResolveFilter(
val operation = expression.getOperationToken() val operation = expression.getOperationToken()
if (operation == JetTokens.EQEQ || operation == JetTokens.EXCLEQ) { if (operation == JetTokens.EQEQ || operation == JetTokens.EXCLEQ) {
result.addIfNotNull(expression.getLeft()?.smartCastedExpressionName()) result.addIfNotNull(expression.getLeft()?.smartCastExpressionName())
result.addIfNotNull(expression.getRight()?.smartCastedExpressionName()) result.addIfNotNull(expression.getRight()?.smartCastExpressionName())
} }
} }
override fun visitIsExpression(expression: JetIsExpression) { override fun visitIsExpression(expression: JetIsExpression) {
expression.acceptChildren(this) expression.acceptChildren(this)
result.addIfNotNull(expression.getLeftHandSide()?.smartCastedExpressionName()) result.addIfNotNull(expression.getLeftHandSide()?.smartCastExpressionName())
} }
}) })
return result return result
@@ -342,15 +342,15 @@ class PartialBodyResolveFilter(
private fun PsiElement.isStatement() = this is JetExpression && getParent() is JetBlockExpression private fun PsiElement.isStatement() = this is JetExpression && getParent() is JetBlockExpression
private fun JetExpression.smartCastedExpressionName(): String? { private fun JetExpression.smartCastExpressionName(): String? {
return when (this) { return when (this) {
is JetSimpleNameExpression -> this.getReferencedName() is JetSimpleNameExpression -> this.getReferencedName()
is JetQualifiedExpression -> { is JetQualifiedExpression -> {
val selectorName = getSelectorExpression().smartCastedExpressionName() ?: return null val selectorName = getSelectorExpression().smartCastExpressionName() ?: return null
val receiver = getReceiverExpression() val receiver = getReceiverExpression()
if (receiver is JetThisExpression) return selectorName if (receiver is JetThisExpression) return selectorName
val receiverName = receiver.smartCastedExpressionName() ?: return null val receiverName = receiver.smartCastExpressionName() ?: return null
return selectorName + "." + receiverName return selectorName + "." + receiverName
} }
@@ -1,4 +1,4 @@
Resolve target: value-parameter val p: kotlin.Any smart-casted to kotlin.String Resolve target: value-parameter val p: kotlin.Any smart-cast to kotlin.String
Skipped statements: Skipped statements:
y(p as? Int) y(p as? Int)
z(f() as String) z(f() as String)
@@ -1,4 +1,4 @@
Resolve target: value-parameter val p: kotlin.String? smart-casted to kotlin.String Resolve target: value-parameter val p: kotlin.String? smart-cast to kotlin.String
Skipped statements: Skipped statements:
y(f()!!) y(f()!!)
p1!! p1!!
@@ -1,3 +1,3 @@
Resolve target: value-parameter val p: kotlin.Boolean? smart-casted to kotlin.Boolean Resolve target: value-parameter val p: kotlin.Boolean? smart-cast to kotlin.Boolean
Skipped statements: Skipped statements:
print(p1!!.hashCode()) print(p1!!.hashCode())
@@ -1,3 +1,3 @@
Resolve target: value-parameter val p: kotlin.Any? smart-casted to kotlin.String Resolve target: value-parameter val p: kotlin.Any? smart-cast to kotlin.String
Skipped statements: Skipped statements:
print(p1!!) print(p1!!)
@@ -1,4 +1,4 @@
Resolve target: value-parameter val p1: kotlin.Any? smart-casted to kotlin.Any Resolve target: value-parameter val p1: kotlin.Any? smart-cast to kotlin.Any
Skipped statements: Skipped statements:
print(p!!) print(p!!)
print(p2!!) print(p2!!)
@@ -1,2 +1,2 @@
Resolve target: value-parameter val o: kotlin.Any? smart-casted to kotlin.Any Resolve target: value-parameter val o: kotlin.Any? smart-cast to kotlin.Any
Skipped statements: Skipped statements:
@@ -1,2 +1,2 @@
Resolve target: value-parameter val o: kotlin.String? smart-casted to kotlin.String Resolve target: value-parameter val o: kotlin.String? smart-cast to kotlin.String
Skipped statements: Skipped statements:
@@ -1,2 +1,2 @@
Resolve target: value-parameter val p: kotlin.Any smart-casted to kotlin.String Resolve target: value-parameter val p: kotlin.Any smart-cast to kotlin.String
Skipped statements: Skipped statements:
@@ -1,2 +1,2 @@
Resolve target: value-parameter val p: kotlin.Any smart-casted to kotlin.String Resolve target: value-parameter val p: kotlin.Any smart-cast to kotlin.String
Skipped statements: Skipped statements:
@@ -1,2 +1,2 @@
Resolve target: value-parameter val p: kotlin.Any smart-casted to kotlin.String Resolve target: value-parameter val p: kotlin.Any smart-cast to kotlin.String
Skipped statements: Skipped statements:
@@ -1,2 +1,2 @@
Resolve target: value-parameter val p: kotlin.Any smart-casted to kotlin.String Resolve target: value-parameter val p: kotlin.Any smart-cast to kotlin.String
Skipped statements: Skipped statements:
@@ -1,3 +1,3 @@
Resolve target: value-parameter val p: kotlin.Any? smart-casted to kotlin.String Resolve target: value-parameter val p: kotlin.Any? smart-cast to kotlin.String
Skipped statements: Skipped statements:
print("null") print("null")
@@ -1,2 +1,2 @@
Resolve target: val v: kotlin.Any smart-casted to kotlin.String Resolve target: val v: kotlin.Any smart-cast to kotlin.String
Skipped statements: Skipped statements:
@@ -1,2 +1,2 @@
Resolve target: value-parameter val p: kotlin.Any smart-casted to kotlin.String Resolve target: value-parameter val p: kotlin.Any smart-cast to kotlin.String
Skipped statements: Skipped statements:
@@ -1,3 +1,3 @@
Resolve target: value-parameter val p: kotlin.Any? smart-casted to kotlin.Any Resolve target: value-parameter val p: kotlin.Any? smart-cast to kotlin.Any
Skipped statements: Skipped statements:
print("not null") print("not null")
@@ -1,2 +1,2 @@
Resolve target: val x: kotlin.Any? smart-casted to kotlin.Any Resolve target: val x: kotlin.Any? smart-cast to kotlin.Any
Skipped statements: Skipped statements:
@@ -1,2 +1,2 @@
Resolve target: val x: kotlin.Any? smart-casted to kotlin.Any Resolve target: val x: kotlin.Any? smart-cast to kotlin.Any
Skipped statements: Skipped statements:
@@ -1,3 +1,3 @@
Resolve target: value-parameter val p: kotlin.Any? smart-casted to kotlin.Any Resolve target: value-parameter val p: kotlin.Any? smart-cast to kotlin.Any
Skipped statements: Skipped statements:
print("null") print("null")
@@ -1,2 +1,2 @@
Resolve target: value-parameter val p: kotlin.String? smart-casted to kotlin.String Resolve target: value-parameter val p: kotlin.String? smart-cast to kotlin.String
Skipped statements: Skipped statements:
@@ -1,2 +1,2 @@
Resolve target: val s: kotlin.String? smart-casted to kotlin.String Resolve target: val s: kotlin.String? smart-cast to kotlin.String
Skipped statements: Skipped statements:
@@ -1,3 +1,3 @@
Resolve target: value-parameter val p: kotlin.Any? smart-casted to kotlin.Any Resolve target: value-parameter val p: kotlin.Any? smart-cast to kotlin.Any
Skipped statements: Skipped statements:
print(p1!!) print(p1!!)
@@ -109,7 +109,7 @@ public abstract class AbstractPartialBodyResolveTest : JetLightCodeInsightFixtur
val renderType = this is VariableDescriptor && type != this.getReturnType() val renderType = this is VariableDescriptor && type != this.getReturnType()
if (!renderType) return s if (!renderType) return s
return s + " smart-casted to " + if (type != null) DescriptorRenderer.COMPACT.renderType(type) else "unknown type" return s + " smart-cast to " + if (type != null) DescriptorRenderer.COMPACT.renderType(type) else "unknown type"
} }
private fun JetExpression.presentation(): String { private fun JetExpression.presentation(): String {