IDEA-64612 Autocasting from completion is not inserted after "assert X instanceof T" (and before another assignment)

This commit is contained in:
peter
2011-01-25 19:28:58 +01:00
parent 427ab9cbb6
commit 9f4efe0e8f
4 changed files with 51 additions and 2 deletions
@@ -680,8 +680,8 @@ public class JavaCompletionUtil {
final Document document = context.getEditor().getDocument();
PsiDocumentManager.getInstance(project).commitDocument(document);
final PsiFile file = context.getFile();
final PsiReferenceExpression ref =
PsiTreeUtil.findElementOfClassAtOffset(file, context.getStartOffset(), PsiReferenceExpression.class, false);
final PsiJavaCodeReferenceElement ref =
PsiTreeUtil.findElementOfClassAtOffset(file, context.getStartOffset(), PsiJavaCodeReferenceElement.class, false);
if (ref != null) {
final PsiElement qualifier = ref.getQualifier();
if (qualifier != null) {
@@ -0,0 +1,24 @@
import javax.swing.*;
import java.awt.*;
public class Bar {
static class CellWrapper {
public boolean isSeparator() {
return true;
}
}
static class MyRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean s, boolean focus) {
assert value instanceof CellWrapper;
value.is<caret>
mySelected = isSelected;
}
}
}
@@ -0,0 +1,24 @@
import javax.swing.*;
import java.awt.*;
public class Bar {
static class CellWrapper {
public boolean isSeparator() {
return true;
}
}
static class MyRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean s, boolean focus) {
assert value instanceof CellWrapper;
((CellWrapper) value).isSeparator()<caret>
mySelected = isSelected;
}
}
}
@@ -787,6 +787,7 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
public void testCastTooComplexInstanceofedQualifier() throws Throwable { doAntiTest(); }
public void testDontCastInstanceofedQualifier() throws Throwable { doTest(); }
public void testQualifierCastingWithUnknownAssignments() throws Throwable { doTest(); }
public void testWildcardsInLookup() throws Exception {
configure()