mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
introduce variable: ensure initialize conflict resolver over code ready to rename (IDEA-141634)
This commit is contained in:
+4
@@ -109,6 +109,10 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
}
|
||||
}
|
||||
super.beforeTemplateStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRenameTemplateStarted() {
|
||||
final ResolveSnapshotProvider resolveSnapshotProvider = VariableInplaceRenamer.INSTANCE.forLanguage(myScope.getLanguage());
|
||||
myConflictResolver = resolveSnapshotProvider != null ? resolveSnapshotProvider.createSnapshot(myScope) : null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
class OuterClass {
|
||||
private MyComp myComp;
|
||||
|
||||
private class MyComp extends JPanel {
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
int a = myComp.get<caret>Height();
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
class OuterClass {
|
||||
private MyComp myComp;
|
||||
|
||||
private class MyComp extends JPanel {
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
int height = myComp.getHeight();
|
||||
int a = height;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,15 @@ public class InplaceIntroduceVariableTest extends AbstractJavaInplaceIntroduceTe
|
||||
});
|
||||
}
|
||||
|
||||
public void testConflictWithField() throws Exception {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer introducer) {
|
||||
type("height");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testCast() throws Exception {
|
||||
doTestTypeChange("Integer");
|
||||
}
|
||||
|
||||
+3
@@ -230,6 +230,7 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
|
||||
updateTitle(getVariable());
|
||||
started = AbstractInplaceIntroducer.super.performInplaceRefactoring(nameSuggestions);
|
||||
if (started) {
|
||||
onRenameTemplateStarted();
|
||||
myDocumentAdapter = new DocumentAdapter() {
|
||||
@Override
|
||||
public void documentChanged(DocumentEvent e) {
|
||||
@@ -260,6 +261,8 @@ public abstract class AbstractInplaceIntroducer<V extends PsiNameIdentifierOwner
|
||||
return result.get();
|
||||
}
|
||||
|
||||
protected void onRenameTemplateStarted() {}
|
||||
|
||||
protected int getCaretOffset() {
|
||||
RangeMarker r;
|
||||
if (myLocalMarker != null) {
|
||||
|
||||
Reference in New Issue
Block a user