This commit is contained in:
Roman Shevchenko
2011-09-13 16:09:21 +02:00
parent eaffde8f5d
commit a0da632f3e
3 changed files with 18 additions and 12 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -784,26 +784,25 @@ public class PsiClassImplUtil {
}
public static PsiClass[] getInterfaces(PsiClass psiClass) {
final PsiClassType[] extendsListTypes = psiClass.getExtendsListTypes();
if (psiClass.isInterface()) {
final PsiClassType[] extendsListTypes = psiClass.getExtendsListTypes();
return resolveClassReferenceList(extendsListTypes, psiClass.getManager(), psiClass.getResolveScope(), false);
}
if (psiClass instanceof PsiAnonymousClass) {
PsiClassType baseClassReference = ((PsiAnonymousClass)psiClass).getBaseClassType();
PsiClass baseClass = baseClassReference.resolve();
if (baseClass != null && baseClass.isInterface()) return new PsiClass[]{baseClass};
return PsiClass.EMPTY_ARRAY;
return baseClass != null && baseClass.isInterface() ? new PsiClass[]{baseClass} : PsiClass.EMPTY_ARRAY;
}
final PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes();
return resolveClassReferenceList(implementsListTypes, psiClass.getManager(), psiClass.getResolveScope(), false);
}
private static PsiClass[] resolveClassReferenceList(final PsiClassType[] listOfTypes,
final PsiManager manager, final GlobalSearchScope resolveScope, boolean includeObject)
{
final PsiManager manager,
final GlobalSearchScope resolveScope,
boolean includeObject) {
PsiClass objectClass = JavaPsiFacade.getInstance(manager.getProject()).findClass("java.lang.Object", resolveScope);
if (objectClass == null) includeObject = false;
if (listOfTypes == null || listOfTypes.length == 0) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,11 +22,15 @@ package com.intellij.codeInsight;
import com.intellij.psi.*;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Set;
public class ClassUtil {
private ClassUtil() { }
@Nullable
public static PsiMethod getAnyAbstractMethod(@NotNull PsiClass aClass) {
PsiMethod methodToImplement = getAnyMethodToImplement(aClass);
if (methodToImplement != null) {
@@ -40,7 +44,8 @@ public class ClassUtil {
return null;
}
public static PsiMethod getAnyMethodToImplement(PsiClass aClass) {
@Nullable
public static PsiMethod getAnyMethodToImplement(@NotNull PsiClass aClass) {
Set<PsiMethod> alreadyImplemented = new THashSet<PsiMethod>();
for (HierarchicalMethodSignature signatureHierarchical : aClass.getVisibleSignatures()) {
for (PsiMethod superS : signatureHierarchical.getMethod().findSuperMethods()) {
@@ -73,8 +78,9 @@ public class ClassUtil {
return checkPackageLocalInSuperClass(aClass);
}
private static PsiMethod checkPackageLocalInSuperClass(PsiClass aClass) {
// super class can have package local sbstract methods not accessible for overriding
@Nullable
private static PsiMethod checkPackageLocalInSuperClass(@NotNull PsiClass aClass) {
// super class can have package local abstract methods not accessible for overriding
PsiClass superClass = aClass.getSuperClass();
if (superClass == null) return null;
if ("java.lang.Object".equals(aClass.getQualifiedName())) return null;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -181,5 +181,6 @@ public interface PsiMethod extends PsiMember, PsiNameIdentifierOwner, PsiModifie
@Nullable PsiMethodReceiver getMethodReceiver();
@Nullable
PsiType getReturnTypeNoResolve();
}