IDEA-188425 Add getInstance option in completion popup

This commit is contained in:
peter
2018-05-02 11:37:04 +02:00
parent 9bfea28eb1
commit df915d8685
4 changed files with 16 additions and 0 deletions
@@ -364,6 +364,14 @@ public class JavaMemberNameCompletionContributor extends CompletionContributor {
.withInsertHandler(ParenthesesInsertHandler.NO_PARAMETERS));
}
if (element instanceof PsiField && ((PsiField)element).hasModifierProperty(PsiModifier.STATIC) &&
ourClassParent.equals(PsiUtil.resolveClassInClassTypeOnly(((PsiField)element).getType()))) {
set.add(LookupElementBuilder.create("getInstance")
.withIcon(PlatformIcons.METHOD_ICON)
.withTailText("()")
.withInsertHandler(ParenthesesInsertHandler.WITH_PARAMETERS));
}
addLookupItems(set, null, matcher, element.getProject(), getUnresolvedReferences(ourClassParent, true));
addLookupItems(set, null, matcher, element.getProject(), getPropertiesHandlersNames(
@@ -0,0 +1,3 @@
public class Util {
static Util getI<caret>
}
@@ -0,0 +1,3 @@
public class Util {
static Util getInstance(<caret>)
}
@@ -1850,4 +1850,6 @@ class Bar {{
doTest('\n')
}
void testSuggestGetInstanceMethodName() { doTest() }
}