@NotNull
 @Override
 public FileStatus getElementStatus(final RefEntity element) {
   final GlobalInspectionContextImpl context = getContext();
   if (!isDisposed() && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN) {
     if (myOldProblemElements != null) {
       final boolean old = RefUtil.contains(element, myOldProblemElements.keySet());
       final boolean current = RefUtil.contains(element, getProblemElements().keySet());
       return calcStatus(old, current);
     }
   }
   return FileStatus.NOT_CHANGED;
 }
 @Override
 public Map<String, Set<RefEntity>> getOldContent() {
   if (myOldProblemElements == null) return null;
   final Map<String, Set<RefEntity>> oldContents =
       new com.intellij.util.containers.HashMap<String, Set<RefEntity>>();
   final Set<RefEntity> elements = myOldProblemElements.keySet();
   for (RefEntity element : elements) {
     String groupName =
         element instanceof RefElement
             ? element.getRefManager().getGroupName((RefElement) element)
             : element.getName();
     final Set<RefEntity> collection = myContents.get(groupName);
     if (collection != null) {
       final Set<RefEntity> currentElements = new HashSet<RefEntity>(collection);
       if (RefUtil.contains(element, currentElements)) continue;
     }
     Set<RefEntity> oldContent = oldContents.get(groupName);
     if (oldContent == null) {
       oldContent = new HashSet<RefEntity>();
       oldContents.put(groupName, oldContent);
     }
     oldContent.add(element);
   }
   return oldContents;
 }
コード例 #3
0
  @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;
  }