mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
basic completion of class keyword after primitive types and arrays (IDEA-72265)
This commit is contained in:
@@ -524,13 +524,7 @@ public class JavaCompletionData extends JavaAwareCompletionData{
|
||||
|
||||
addPrimitiveTypes(result, position);
|
||||
|
||||
if (psiElement().afterLeaf(psiElement().withText(".").inside(PsiExpression.class).afterLeaf(or(
|
||||
psiElement().withParent(psiElement().referencing(psiClass())),
|
||||
psiElement().withText(string().oneOf("]", PsiKeyword.VOID)),
|
||||
psiElement().withText(string().oneOf(PRIMITIVE_TYPES))
|
||||
))).accepts(position)) {
|
||||
result.addElement(createKeyword(position, PsiKeyword.CLASS));
|
||||
}
|
||||
addClassLiteral(result, position);
|
||||
|
||||
final ProcessingContext context = new ProcessingContext();
|
||||
if (psiElement().afterLeaf(
|
||||
@@ -563,6 +557,19 @@ public class JavaCompletionData extends JavaAwareCompletionData{
|
||||
}
|
||||
}
|
||||
|
||||
private static void addClassLiteral(CompletionResultSet result, PsiElement position) {
|
||||
if (psiElement().afterLeaf(psiElement().withText(".").afterLeaf(
|
||||
or(
|
||||
psiElement().withParent(psiElement().referencing(psiClass())),
|
||||
psiElement().withText(string().oneOf("]", PsiKeyword.VOID)),
|
||||
psiElement().withText(string().oneOf(PRIMITIVE_TYPES))
|
||||
))).accepts(position) &&
|
||||
!INSIDE_PARAMETER_LIST.accepts(position) &&
|
||||
!(position.getContainingFile() instanceof PsiJavaCodeReferenceCodeFragment)) {
|
||||
result.addElement(createKeyword(position, PsiKeyword.CLASS));
|
||||
}
|
||||
}
|
||||
|
||||
private static void addPrimitiveTypes(CompletionResultSet result, PsiElement position) {
|
||||
boolean declaration = DECLARATION_START.isAcceptable(position, position) ||
|
||||
psiElement().withParents(PsiJavaCodeReferenceElement.class, PsiTypeElement.class, PsiMember.class).accepts(position);
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
private class Zooooooo {
|
||||
{
|
||||
Class<?> cls = byte[].cla<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
private class Zooooooo {
|
||||
{
|
||||
Class<?> cls = byte[].class<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
private class Zooooooo {
|
||||
{
|
||||
Class<?> cls = byte.cla<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
private class Zooooooo {
|
||||
{
|
||||
Class<?> cls = byte.class<caret>
|
||||
}
|
||||
}
|
||||
@@ -994,6 +994,8 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
public void testNoDotOverwrite() throws Exception { doTest('.') }
|
||||
|
||||
public void testStaticInnerExtendingOuter() throws Exception { doTest() }
|
||||
public void testPrimitiveClass() throws Exception { doTest() }
|
||||
public void testPrimitiveArrayClass() throws Exception { doTest() }
|
||||
|
||||
public void testSaxParserCommonPrefix() throws Exception {
|
||||
myFixture.addClass("public class SAXParser {}")
|
||||
|
||||
Reference in New Issue
Block a user