Fixed KT-5077 Code completion inserts FQ names inside lambda

#KT-5077 Fixed
This commit is contained in:
Valentin Kipyatkov
2014-05-23 16:02:04 +04:00
parent b2858e5b82
commit 2ddcae68e8
9 changed files with 50 additions and 11 deletions
@@ -61,19 +61,24 @@ public object ShortenReferences {
if (rangeMarker.isValid()) {
val range = TextRange(rangeMarker.getStartOffset(), rangeMarker.getEndOffset())
var elementRange = element.getTextRange()!!
// for qualified call expression take only the part without parenthesis
val calleeExpression = ((element as? JetDotQualifiedExpression)
?.getSelectorExpression() as? JetCallExpression)
?.getCalleeExpression()
if (calleeExpression != null) {
elementRange = TextRange(elementRange.getStartOffset(), calleeExpression.getTextRange()!!.getEndOffset())
}
val elementRange = element.getTextRange()!!
when {
range.contains(elementRange) -> FilterResult.PROCESS
range.intersects(elementRange) -> FilterResult.GO_INSIDE
range.intersects(elementRange) -> {
// for qualified call expression allow to shorten only the part without parenthesis
val calleeExpression = ((element as? JetDotQualifiedExpression)
?.getSelectorExpression() as? JetCallExpression)
?.getCalleeExpression()
if (calleeExpression != null) {
val rangeWithoutParenthesis = TextRange(elementRange.getStartOffset(), calleeExpression.getTextRange()!!.getEndOffset())
if (range.contains(rangeWithoutParenthesis)) FilterResult.PROCESS else FilterResult.GO_INSIDE
}
else {
FilterResult.GO_INSIDE
}
}
else -> FilterResult.SKIP
}
}