From a0da632f3eb8ee307b265115f5226eafdddeffbc Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Mon, 12 Sep 2011 19:04:58 +0200 Subject: [PATCH] Cleanup --- .../com/intellij/psi/impl/PsiClassImplUtil.java | 13 ++++++------- .../src/com/intellij/codeInsight/ClassUtil.java | 14 ++++++++++---- java/openapi/src/com/intellij/psi/PsiMethod.java | 3 ++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/java/java-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java b/java/java-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java index 8f9a72133703..8109869ed686 100644 --- a/java/java-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java +++ b/java/java-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java @@ -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) { diff --git a/java/openapi/src/com/intellij/codeInsight/ClassUtil.java b/java/openapi/src/com/intellij/codeInsight/ClassUtil.java index 8abe35cb1ddd..dc6d33ec4594 100644 --- a/java/openapi/src/com/intellij/codeInsight/ClassUtil.java +++ b/java/openapi/src/com/intellij/codeInsight/ClassUtil.java @@ -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 alreadyImplemented = new THashSet(); 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; diff --git a/java/openapi/src/com/intellij/psi/PsiMethod.java b/java/openapi/src/com/intellij/psi/PsiMethod.java index e06d79cfefd2..0d009e081538 100644 --- a/java/openapi/src/com/intellij/psi/PsiMethod.java +++ b/java/openapi/src/com/intellij/psi/PsiMethod.java @@ -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(); }