mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 08:06:56 +07:00
[java] Implement getName for implicit classes
GitOrigin-RevId: 069362cff5ebee9eaf5e75d566097a2deaed8e8f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7a3729260a
commit
0232d76e56
@@ -984,7 +984,8 @@ public class JavaKeywordCompletion {
|
||||
String name = file.getName();
|
||||
if (!StringUtil.endsWithIgnoreCase(name, JavaFileType.DOT_DEFAULT_EXTENSION)) return null;
|
||||
String candidate = name.substring(0, name.length() - JavaFileType.DOT_DEFAULT_EXTENSION.length());
|
||||
if (StringUtil.isJavaIdentifier(candidate) && !ContainerUtil.exists(file.getClasses(), c -> candidate.equals(c.getName()))) {
|
||||
if (StringUtil.isJavaIdentifier(candidate)
|
||||
&& !ContainerUtil.exists(file.getClasses(), c -> !(c instanceof PsiImplicitClass) && candidate.equals(c.getName()))) {
|
||||
return candidate;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -372,7 +372,7 @@ public final class JavaMemberNameCompletionContributor extends CompletionContrib
|
||||
private static void completeMethodName(Set<LookupElement> set, PsiElement element, PrefixMatcher matcher){
|
||||
if (element instanceof PsiMethod method && method.isConstructor()) {
|
||||
PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
if (containingClass != null && !(containingClass instanceof PsiImplicitClass)) {
|
||||
String name = containingClass.getName();
|
||||
if (StringUtil.isNotEmpty(name)) {
|
||||
addLookupItems(set, null, matcher, element.getProject(), name);
|
||||
|
||||
@@ -150,6 +150,10 @@ public final class JavaCompletionProcessor implements PsiScopeProcessor, Element
|
||||
return true;
|
||||
}
|
||||
|
||||
if (element instanceof PsiImplicitClass) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (element instanceof PsiMember && !PsiNameHelper.getInstance(element.getProject()).isIdentifier(((PsiMember)element).getName())) {
|
||||
// The member could be defined in another JVM language where its name is not a legal name in Java.
|
||||
// In this case, just skip such the member. We cannot legally reference it from Java source.
|
||||
|
||||
@@ -86,7 +86,7 @@ public final class ClassesTreeStructureProvider implements SelectableTreeStructu
|
||||
}
|
||||
|
||||
private static boolean isClassForTreeNode(VirtualFile file, PsiClass psiClass) {
|
||||
if (psiClass == null || psiClass instanceof SyntheticElement) return false;
|
||||
if (psiClass == null || psiClass instanceof SyntheticElement || psiClass instanceof PsiImplicitClass) return false;
|
||||
if (file == null || file.getNameWithoutExtension().equals(psiClass.getName())) return true;
|
||||
TemplateManager templateManager = TemplateManager.getInstance(psiClass.getProject());
|
||||
return ContainerUtil.exists(EditorFactory.getInstance().getAllEditors(), editor -> templateManager.getActiveTemplate(editor) != null);
|
||||
|
||||
Reference in New Issue
Block a user