mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inspection tool window: do not make a mess from RefClass and RefImplicitConstructor
This commit is contained in:
@@ -34,12 +34,16 @@ import org.jetbrains.annotations.NotNull;
|
||||
public abstract class RefJavaManager implements RefManagerExtension<RefJavaManager> {
|
||||
@NonNls public static final String CLASS = "class";
|
||||
@NonNls public static final String METHOD = "method";
|
||||
@NonNls public static final String IMPLICIT_CONSTRUCTOR = "implicit.constructor";
|
||||
@NonNls public static final String FIELD = "field";
|
||||
@NonNls public static final String PARAMETER = "parameter";
|
||||
//used in OfflineProjectDescriptor
|
||||
@NonNls public static final String PACKAGE = "package";
|
||||
public static final Key<RefJavaManager> MANAGER = Key.create("RefJavaManager");
|
||||
|
||||
|
||||
public abstract RefImplicitConstructor getImplicitConstructor(String classFQName);
|
||||
|
||||
/**
|
||||
* Creates (if necessary) and returns the reference graph node for the package
|
||||
* with the specified name.
|
||||
|
||||
+35
-3
@@ -23,14 +23,15 @@ import com.intellij.codeInspection.deadCode.UnusedDeclarationInspectionBase;
|
||||
import com.intellij.codeInspection.ex.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.NullableFactory;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ConcurrentFactoryMap;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -52,6 +53,7 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
private PsiClass myServlet;
|
||||
private RefPackage myDefaultPackage;
|
||||
private THashMap<String, RefPackage> myPackages;
|
||||
private THashMap<String, RefImplicitConstructor> myImplicitConstructors;
|
||||
private final RefManagerImpl myRefManager;
|
||||
private PsiElementVisitor myProjectIterator;
|
||||
private EntryPointsManager myEntryPointsManager;
|
||||
@@ -75,6 +77,29 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefImplicitConstructor getImplicitConstructor(String classFQName) {
|
||||
if (myImplicitConstructors == null) {
|
||||
myImplicitConstructors = new THashMap<>();
|
||||
}
|
||||
|
||||
RefImplicitConstructor constructor = myImplicitConstructors.get(classFQName);
|
||||
if (constructor == null) {
|
||||
final RefEntity entity = getReference(CLASS, classFQName);
|
||||
if (entity == null) return null;
|
||||
final RefClass refClass = (RefClass)entity;
|
||||
for (RefMethod method : refClass.getConstructors()) {
|
||||
if (method instanceof RefImplicitConstructor) {
|
||||
constructor = (RefImplicitConstructor)method;
|
||||
myImplicitConstructors.put(classFQName, constructor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return constructor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefPackage getPackage(String packageName) {
|
||||
if (myPackages == null) {
|
||||
@@ -192,6 +217,7 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
myEntryPointsManager = null;
|
||||
}
|
||||
myPackages = null;
|
||||
myImplicitConstructors = null;
|
||||
myApplet = null;
|
||||
myAppMainPattern = null;
|
||||
myAppPremainPattern = null;
|
||||
@@ -241,6 +267,9 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
@Override
|
||||
@Nullable
|
||||
public RefEntity getReference(final String type, final String fqName) {
|
||||
if (IMPLICIT_CONSTRUCTOR.equals(type)) {
|
||||
return getImplicitConstructor(fqName);
|
||||
}
|
||||
if (METHOD.equals(type)) {
|
||||
return RefMethodImpl.methodFromExternalName(myRefManager, fqName);
|
||||
}
|
||||
@@ -262,7 +291,10 @@ public class RefJavaManagerImpl extends RefJavaManager {
|
||||
@Override
|
||||
@Nullable
|
||||
public String getType(final RefEntity ref) {
|
||||
if (ref instanceof RefMethod) {
|
||||
if (ref instanceof RefImplicitConstructor) {
|
||||
return IMPLICIT_CONSTRUCTOR;
|
||||
}
|
||||
else if (ref instanceof RefMethod) {
|
||||
return METHOD;
|
||||
}
|
||||
else if (ref instanceof RefClass) {
|
||||
|
||||
-1
@@ -41,7 +41,6 @@ public class SmartRefElementPointerImpl implements SmartRefElementPointer {
|
||||
public SmartRefElementPointerImpl(RefEntity ref, boolean isPersistent) {
|
||||
myIsPersistent = isPersistent;
|
||||
myRefElement = ref;
|
||||
ref = ref.getRefManager().getRefinedElement(ref);
|
||||
myFQName = ref.getExternalName();
|
||||
myType = ref.getRefManager().getType(ref);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user