Skip to content

Commit df9e776

Browse files
committed
don't let the following nasty angle braces spoil the qualifier casting
1 parent 08eab41 commit df9e776

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,12 @@ public void beforeCompletion(@NotNull final CompletionInitializationContext cont
509509
return;
510510
}
511511

512+
final PsiJavaCodeReferenceElement ref = PsiTreeUtil.findElementOfClassAtOffset(file, context.getStartOffset(), PsiJavaCodeReferenceElement.class, false);
513+
if (ref != null && !(ref instanceof PsiReferenceExpression)) {
514+
context.setDummyIdentifier(CompletionInitializationContext.DUMMY_IDENTIFIER.trim() + ";");
515+
return;
516+
}
517+
512518
final PsiElement element = file.findElementAt(context.getStartOffset());
513519

514520
if (psiElement().inside(PsiAnnotation.class).accepts(element)) {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2000-2011 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import javax.swing.*;
17+
import java.awt.*;
18+
19+
public class Bar {
20+
21+
static class CellWrapper {
22+
public boolean isSeparator() {
23+
return true;
24+
}
25+
}
26+
27+
static class MyRenderer extends DefaultListCellRenderer {
28+
public Component getListCellRendererComponent(JList list, Object value, int index, boolean s, boolean focus) {
29+
assert value instanceof CellWrapper;
30+
31+
value.is<caret><car>
32+
33+
}
34+
}
35+
36+
}
37+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2000-2011 JetBrains s.r.o.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import javax.swing.*;
17+
import java.awt.*;
18+
19+
public class Bar {
20+
21+
static class CellWrapper {
22+
public boolean isSeparator() {
23+
return true;
24+
}
25+
}
26+
27+
static class MyRenderer extends DefaultListCellRenderer {
28+
public Component getListCellRendererComponent(JList list, Object value, int index, boolean s, boolean focus) {
29+
assert value instanceof CellWrapper;
30+
31+
((CellWrapper) value).isSeparator()<caret><car>
32+
33+
}
34+
}
35+
36+
}
37+

java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
788788
public void testCastTooComplexInstanceofedQualifier() throws Throwable { doAntiTest(); }
789789
public void testDontCastInstanceofedQualifier() throws Throwable { doTest(); }
790790
public void testQualifierCastingWithUnknownAssignments() throws Throwable { doTest(); }
791+
public void testQualifierCastingBeforeLt() throws Throwable { doTest(); }
791792
792793
public void testWildcardsInLookup() throws Exception {
793794
configure()

0 commit comments

Comments
 (0)