mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
javafx: inplace rename for custom components called by qualified name fixed (IDEA-101227)
This commit is contained in:
@@ -20,7 +20,9 @@ import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase;
|
||||
import com.intellij.openapi.application.PluginPathManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.rename.RenameProcessor;
|
||||
import com.intellij.refactoring.rename.inplace.MemberInplaceRenameHandler;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JavaFXRenameTest extends DaemonAnalyzerTestCase {
|
||||
@@ -47,15 +49,23 @@ public class JavaFXRenameTest extends DaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
public void testCustomComponentTag() throws Exception {
|
||||
doTest("Foo");
|
||||
doTest("Foo", true);
|
||||
}
|
||||
|
||||
private void doTest(final String newName) throws Exception {
|
||||
doTest(newName, false);
|
||||
}
|
||||
|
||||
private void doTest(final String newName, boolean inline) throws Exception {
|
||||
configureByFiles(null, getTestName(true) + ".fxml", getTestName(false) + ".java");
|
||||
PsiElement element = TargetElementUtilBase
|
||||
.findTargetElement(myEditor, TargetElementUtilBase.ELEMENT_NAME_ACCEPTED | TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED);
|
||||
assertNotNull(element);
|
||||
new RenameProcessor(getProject(), element, newName, true, true).run();
|
||||
if (inline) {
|
||||
CodeInsightTestUtil.doInlineRename(new MemberInplaceRenameHandler(), newName, getEditor(), element);
|
||||
} else {
|
||||
new RenameProcessor(getProject(), element, newName, true, true).run();
|
||||
}
|
||||
checkResultByFile(getTestName(true) + "_after.fxml");
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.codeInsight.quickfix.UnresolvedReferenceQuickFixProvider;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -35,6 +36,20 @@ public class JavaFxTagNameReference extends TagNameReference{
|
||||
super(element, startTagFlag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextRange getRangeInElement() {
|
||||
final TextRange rangeInElement = super.getRangeInElement();
|
||||
final XmlTag tagElement = getTagElement();
|
||||
if (tagElement != null) {
|
||||
final String tagElementName = tagElement.getName();
|
||||
final int dotIdx = tagElementName.indexOf(".");
|
||||
if (dotIdx > -1 && dotIdx + 2 < rangeInElement.getEndOffset()) {
|
||||
return new TextRange(rangeInElement.getStartOffset() + dotIdx + 1, rangeInElement.getEndOffset());
|
||||
}
|
||||
}
|
||||
return rangeInElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
if (element instanceof PsiClass) {
|
||||
|
||||
Reference in New Issue
Block a user