mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
more optimisations
This commit is contained in:
@@ -39,7 +39,8 @@ public class InheritanceImplUtil {
|
||||
public static boolean isInheritor(@NotNull final PsiClass candidateClass, @NotNull PsiClass baseClass, final boolean checkDeep) {
|
||||
if (baseClass instanceof PsiAnonymousClass) return false;
|
||||
if (!checkDeep) return isInheritor(candidateClass, baseClass, false, null);
|
||||
|
||||
|
||||
if (CommonClassNames.JAVA_LANG_OBJECT.equals(candidateClass.getQualifiedName())) return false;
|
||||
if (CommonClassNames.JAVA_LANG_OBJECT.equals(baseClass.getQualifiedName())) return true;
|
||||
Map<PsiClass, Boolean> map = CachedValuesManager.getManager(candidateClass.getProject()).
|
||||
getCachedValue(candidateClass, new CachedValueProvider<Map<PsiClass, Boolean>>() {
|
||||
@@ -50,7 +51,7 @@ public class InheritanceImplUtil {
|
||||
return Result.create(map, candidateClass);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Boolean computed = map.get(baseClass);
|
||||
if (computed == null) {
|
||||
computed = isInheritor(candidateClass, baseClass, true, null);
|
||||
|
||||
@@ -193,7 +193,7 @@ public class JavaResolveUtil {
|
||||
if (placeParent instanceof PsiClass && !(placeParent instanceof PsiAnonymousClass)) {
|
||||
final boolean isTypeParameter = placeParent instanceof PsiTypeParameter;
|
||||
if (isTypeParameter && isAtLeast17 == null) {
|
||||
isAtLeast17 = JavaVersionService.getInstance().isAtLeast(place, JavaSdkVersion.JDK_1_7);
|
||||
isAtLeast17 = JavaVersionService.getInstance().isAtLeast(placeParent, JavaSdkVersion.JDK_1_7);
|
||||
}
|
||||
if (!isTypeParameter || isAtLeast17) {
|
||||
PsiClass aClass = (PsiClass)placeParent;
|
||||
|
||||
+1
-1
@@ -3,5 +3,5 @@ import java.util.List;
|
||||
|
||||
interface A
|
||||
{
|
||||
<<error descr="'add(E)' in 'java.util.List' clashes with 'add(E)' in 'java.util.Collection'; both methods have same erasure, yet neither overrides the other"></error>T extends List<?> & Collection<? extends Cloneable>> void foo(T x);
|
||||
<<error descr="'java.util.Collection' cannot be inherited with different type arguments: 'capture<?>' and 'capture<? extends java.lang.Cloneable>'"></error>T extends List<?> & Collection<? extends Cloneable>> void foo(T x);
|
||||
}
|
||||
@@ -254,9 +254,9 @@ public class HighlightInfo implements Segment {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static HighlightInfoFilter[] getFilters() {
|
||||
return ApplicationManager.getApplication().getExtensions(HighlightInfoFilter.EXTENSION_POINT_NAME);
|
||||
}
|
||||
private static final HighlightInfoFilter[] FILTERS =
|
||||
ApplicationManager.getApplication().getExtensions(HighlightInfoFilter.EXTENSION_POINT_NAME);
|
||||
|
||||
|
||||
public boolean needUpdateOnTyping() {
|
||||
return isFlagSet(NEEDS_UPDATE_ON_TYPING_FLAG);
|
||||
@@ -588,7 +588,7 @@ public class HighlightInfo implements Segment {
|
||||
"Custom type demands element to detect its text attributes");
|
||||
|
||||
PsiFile file = psiElement == null ? null : psiElement.getContainingFile();
|
||||
for (HighlightInfoFilter filter : getFilters()) {
|
||||
for (HighlightInfoFilter filter : FILTERS) {
|
||||
if (!filter.accept(info, file)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public class ModuleUtilCore {
|
||||
|
||||
public static String getModuleNameInReadAction(@NotNull final Module module) {
|
||||
return new ReadAction<String>(){
|
||||
@Override
|
||||
protected void run(final Result<String> result) throws Throwable {
|
||||
result.setResult(module.getName());
|
||||
}
|
||||
@@ -79,16 +80,21 @@ public class ModuleUtilCore {
|
||||
|
||||
@Nullable
|
||||
public static Module findModuleForPsiElement(@NotNull PsiElement element) {
|
||||
if (!element.isValid()) return null;
|
||||
PsiFile containingFile = element.getContainingFile();
|
||||
if (containingFile == null) {
|
||||
if (!element.isValid()) return null;
|
||||
}
|
||||
else {
|
||||
if (!containingFile.isValid()) return null;
|
||||
}
|
||||
|
||||
Project project = element.getProject();
|
||||
Project project = (containingFile == null ? element : containingFile).getProject();
|
||||
if (project.isDefault()) return null;
|
||||
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
|
||||
if (element instanceof PsiFileSystemItem && (!(element instanceof PsiFile) || element.getContext() == null)) {
|
||||
VirtualFile vFile = ((PsiFileSystemItem)element).getVirtualFile();
|
||||
if (vFile == null) {
|
||||
PsiFile containingFile = element.getContainingFile();
|
||||
vFile = containingFile == null ? null : containingFile.getOriginalFile().getVirtualFile();
|
||||
if (vFile == null) {
|
||||
return element.getUserData(KEY_MODULE);
|
||||
@@ -112,7 +118,6 @@ public class ModuleUtilCore {
|
||||
}
|
||||
return fileIndex.getModuleForFile(vFile);
|
||||
}
|
||||
PsiFile containingFile = element.getContainingFile();
|
||||
if (containingFile != null) {
|
||||
PsiElement context;
|
||||
while ((context = containingFile.getContext()) != null) {
|
||||
|
||||
Reference in New Issue
Block a user