correctly implement JetSimpleNameReference.getTextRange() so that it doesn't include the @ character for references in labels
#KT-7560 Fixed
This commit is contained in:
committed by
Alexey Sedunov
parent
ca8fb53ccd
commit
093878bd06
+5
-1
@@ -61,7 +61,11 @@ public class JetSimpleNameReference(
|
||||
return super.isReferenceTo(element)
|
||||
}
|
||||
|
||||
override fun getRangeInElement(): TextRange = TextRange(0, getElement().getTextLength())
|
||||
override fun getRangeInElement(): TextRange {
|
||||
val element = getElement().getReferencedNameElement()
|
||||
val startOffset = getElement().getTextRange().getStartOffset()
|
||||
return element.getTextRange().shiftRight(-startOffset)
|
||||
}
|
||||
|
||||
override fun canRename(): Boolean {
|
||||
if (expression.getParentOfTypeAndBranch<JetWhenConditionInRange>(strict = true){ getOperationReference() } != null) return false
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
fun xyzzy(): Any {
|
||||
fun b<caret>ar(): Int {
|
||||
return@bar 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun xyzzy(): Any {
|
||||
fun foo(): Int {
|
||||
return@foo 1
|
||||
}
|
||||
}
|
||||
@@ -124,6 +124,10 @@ public class InplaceRenameTest : LightPlatformCodeInsightTestCase() {
|
||||
doTestInplaceRename(null)
|
||||
}
|
||||
|
||||
public fun testLabelFromFunction() {
|
||||
doTestInplaceRename("foo")
|
||||
}
|
||||
|
||||
private fun doTestInplaceRename(newName: String?) {
|
||||
configureByFile(getTestName(false) + ".kt")
|
||||
val element = TargetElementUtilBase.findTargetElement(
|
||||
|
||||
Reference in New Issue
Block a user