mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
introduce variable: ensure first conflicts are resolved and then type assignability is checked (IDEA-159366)
This commit is contained in:
+3
-3
@@ -212,12 +212,12 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
if (psiVariable.getInitializer() != null) {
|
||||
appendTypeCasts(getOccurrenceMarkers(), file, myProject, psiVariable);
|
||||
}
|
||||
if (myConflictResolver != null && myInsertedName != null && isIdentifier(myInsertedName, psiVariable.getLanguage())) {
|
||||
myConflictResolver.apply(psiVariable.getName());
|
||||
}
|
||||
if (psiVariable.getInitializer() != null) {
|
||||
appendTypeCasts(getOccurrenceMarkers(), file, myProject, psiVariable);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
|
||||
private int[][] weights;
|
||||
|
||||
public void out(int u) {
|
||||
System.out.println(weig<caret>hts);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
|
||||
private int[][] weights;
|
||||
|
||||
public void out(int u) {
|
||||
int[][] weights = this.weights;
|
||||
System.out.println(weights);
|
||||
}
|
||||
}
|
||||
@@ -143,6 +143,15 @@ public class InplaceIntroduceVariableTest extends AbstractJavaInplaceIntroduceTe
|
||||
});
|
||||
}
|
||||
|
||||
public void testConflictWithFieldNoCast() throws Exception {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer introducer) {
|
||||
type("weights");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testCast() throws Exception {
|
||||
doTestTypeChange("Integer");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user