private static boolean hasNonInvertedCalls(final RefMethod refMethod) { final Boolean alwaysInverted = refMethod.getUserData(ALWAYS_INVERTED); if (alwaysInverted == null) return true; if (refMethod.isExternalOverride()) return true; if (refMethod.isReferenced() && !alwaysInverted.booleanValue()) return true; final Collection<RefMethod> superMethods = refMethod.getSuperMethods(); for (RefMethod superMethod : superMethods) { if (hasNonInvertedCalls(superMethod)) return true; } return false; }
@Nullable public CommonProblemDescriptor[] checkElement( final RefEntity refEntity, final AnalysisScope scope, final InspectionManager manager, final GlobalInspectionContext globalContext, final ProblemDescriptionsProcessor processor) { if (refEntity instanceof RefMethod) { final RefMethod refMethod = (RefMethod) refEntity; if (refMethod.isSyntheticJSP()) return null; if (refMethod.isExternalOverride()) return null; if (!(refMethod.isStatic() || refMethod.isConstructor()) && !refMethod.getSuperMethods().isEmpty()) return null; if ((refMethod.isAbstract() || refMethod.getOwnerClass().isInterface()) && refMethod.getDerivedMethods().isEmpty()) return null; if (RefUtil.isEntryPoint(refMethod)) return null; if (refMethod.isAppMain()) return null; final ArrayList<RefParameter> unusedParameters = getUnusedParameters(refMethod); if (unusedParameters.isEmpty()) return null; final List<ProblemDescriptor> result = new ArrayList<ProblemDescriptor>(); for (RefParameter refParameter : unusedParameters) { final PsiIdentifier psiIdentifier = refParameter.getElement().getNameIdentifier(); if (psiIdentifier != null) { result.add( manager.createProblemDescriptor( psiIdentifier, refMethod.isAbstract() ? InspectionsBundle.message("inspection.unused.parameter.composer") : InspectionsBundle.message("inspection.unused.parameter.composer1"), new AcceptSuggested( globalContext.getRefManager(), processor, refParameter.toString()), ProblemHighlightType.LIKE_UNUSED_SYMBOL, false)); } } return result.toArray(new CommonProblemDescriptor[result.size()]); } return null; }
@Override @Nullable public CommonProblemDescriptor[] checkElement( @NotNull final RefEntity refEntity, @NotNull final AnalysisScope scope, @NotNull final InspectionManager manager, @NotNull final GlobalInspectionContext globalContext, @NotNull final ProblemDescriptionsProcessor processor) { if (refEntity instanceof RefJavaElement) { final RefJavaElement refElement = (RefJavaElement) refEntity; if (refElement instanceof RefParameter) return null; if (refElement.isSyntheticJSP()) return null; // ignore entry points. if (refElement.isEntry()) return null; // ignore implicit constructors. User should not be able to see them. if (refElement instanceof RefImplicitConstructor) return null; if (refElement instanceof RefField && ((RefField) refElement).getElement() instanceof PsiEnumConstant) return null; // ignore library override methods. if (refElement instanceof RefMethod) { RefMethod refMethod = (RefMethod) refElement; if (refMethod.isExternalOverride()) return null; if (refMethod.isEntry()) return null; } // ignore anonymous classes. They do not have access modifiers. if (refElement instanceof RefClass) { RefClass refClass = (RefClass) refElement; if (refClass.isAnonymous() || refClass.isEntry() || refClass.isTestCase() || refClass.isServlet() || refClass.isApplet() || refClass.isLocalClass()) return null; if (isTopLevelClass(refClass) && !SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES) return null; } // ignore unreferenced code. They could be a potential entry points. if (refElement.getInReferences().isEmpty()) return null; // ignore interface members. They always have public access modifier. if (refElement.getOwner() instanceof RefClass) { RefClass refClass = (RefClass) refElement.getOwner(); if (refClass.isInterface()) return null; } String access = getPossibleAccess(refElement); if (access != refElement.getAccessModifier() && access != null) { final PsiElement element = refElement.getElement(); final PsiElement nameIdentifier = element != null ? HighlightUsagesHandler.getNameIdentifier(element) : null; if (nameIdentifier != null) { return new ProblemDescriptor[] { manager.createProblemDescriptor( nameIdentifier, access.equals(PsiModifier.PRIVATE) ? CAN_BE_PRIVATE : access.equals(PsiModifier.PACKAGE_LOCAL) ? CAN_BE_PACKAGE_LOCAL : CAN_BE_PROTECTED, new AcceptSuggestedAccess(globalContext.getRefManager(), access), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false) }; } } } return null; }