mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inplace refactorings: check reference at caret according to editor offset
This commit is contained in:
+7
-3
@@ -270,7 +270,7 @@ public abstract class InplaceRefactoring {
|
||||
|
||||
boolean subrefOnPrimaryElement = false;
|
||||
for (PsiReference ref : refs) {
|
||||
if (isReferenceAtCaret(selectedElement, ref)) {
|
||||
if (isReferenceAtCaret(nameIdentifier, ref, offset)) {
|
||||
builder.replaceElement(ref, PRIMARY_VARIABLE_NAME, createLookupExpression(), true);
|
||||
subrefOnPrimaryElement = true;
|
||||
continue;
|
||||
@@ -327,8 +327,12 @@ public abstract class InplaceRefactoring {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean isReferenceAtCaret(PsiElement nameIdentifier, PsiReference ref) {
|
||||
return nameIdentifier != null && ref.getElement() == nameIdentifier.getParent();
|
||||
protected boolean isReferenceAtCaret(PsiElement nameIdentifier, PsiReference ref, int offset) {
|
||||
if (nameIdentifier != null && ref.getElement() == nameIdentifier.getParent()) {
|
||||
final TextRange textRange = nameIdentifier.getTextRange();
|
||||
return textRange != null && contains(textRange, offset);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void beforeTemplateStart() {
|
||||
|
||||
Reference in New Issue
Block a user