mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-17 07:20:53 +07:00
IJ-CR-138822 [java-highlighting] IDEA-355777 Support JEP 477: implicit imports
- cache implicit static references - extract ImplicitlyImportedStaticMember into a separate file GitOrigin-RevId: 105a69ce72b4722f0d32d1d858c426e96b73f9c5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
dc2f88d484
commit
ecff6e161b
@@ -0,0 +1,41 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Class representing a static member represented implicitly imported static members.
|
||||
* if memberName is `*`, it is on demand import
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public final class ImplicitlyImportedStaticMember {
|
||||
public static final @NotNull ImplicitlyImportedStaticMember @NotNull [] EMPTY_ARRAY = new ImplicitlyImportedStaticMember[0];
|
||||
|
||||
private final @NotNull String myContainingClass;
|
||||
private final @NotNull String myMemberName;
|
||||
|
||||
private ImplicitlyImportedStaticMember(@NotNull String containingClass, @NotNull String memberName) {
|
||||
myContainingClass = containingClass;
|
||||
myMemberName = memberName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getContainingClass() {
|
||||
return myContainingClass;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getMemberName() {
|
||||
return myMemberName;
|
||||
}
|
||||
|
||||
public boolean isOnDemand() {
|
||||
return "*".equals(myMemberName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ImplicitlyImportedStaticMember create(@NotNull String containingClass, @NotNull String memberName) {
|
||||
return new ImplicitlyImportedStaticMember(containingClass, memberName);
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,10 @@ public interface PsiJavaFile extends PsiImportHolder, PsiClassOwner, AbstractBas
|
||||
* implicitly imported packages (for example, java.lang).
|
||||
*
|
||||
* @return the array of implicitly imported package reference elements.
|
||||
* @deprecated Use {@link PsiJavaFile#getImplicitlyImportedPackages()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval
|
||||
PsiJavaCodeReferenceElement @NotNull [] getImplicitlyImportedPackageReferences();
|
||||
|
||||
/**
|
||||
@@ -94,43 +97,7 @@ public interface PsiJavaFile extends PsiImportHolder, PsiClassOwner, AbstractBas
|
||||
* @return the array of implicitly imported static members.
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
default @NotNull StaticMember @NotNull [] getImplicitlyImportedStaticMembers() {
|
||||
return StaticMember.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class representing a static member represented implicitly imported static members.
|
||||
* if memberName is `*`, it is on demand import
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
class StaticMember {
|
||||
public static final @NotNull StaticMember @NotNull [] EMPTY_ARRAY = new StaticMember[0];
|
||||
|
||||
private final @NotNull String myContainingClass;
|
||||
private final @NotNull String myMemberName;
|
||||
|
||||
private StaticMember(@NotNull String containingClass, @NotNull String memberName) {
|
||||
myContainingClass = containingClass;
|
||||
myMemberName = memberName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getContainingClass() {
|
||||
return myContainingClass;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getMemberName() {
|
||||
return myMemberName;
|
||||
}
|
||||
|
||||
public boolean isOnDemand() {
|
||||
return "*".equals(myMemberName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static StaticMember create(@NotNull String containingClass, @NotNull String memberName) {
|
||||
return new StaticMember(containingClass, memberName);
|
||||
}
|
||||
default @NotNull ImplicitlyImportedStaticMember @NotNull [] getImplicitlyImportedStaticMembers() {
|
||||
return ImplicitlyImportedStaticMember.EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user