Ejemplo n.º 1
0
 /**
  * Called after top level methods (and other items) have been moved from entries to
  * ruleInstanceList. Task now is to scan ruleInstanceList looking for MethodEntry objects with
  * dependent (related, extracted) methods. Move these from the entries list to the correct place
  * in the ruleInstanceList list.
  *
  * @param entries Remaining (unarranged) items, including all dependent (extracted) methods.
  * @param ruleInstance Rule containing parents (callers) of potentially related methods
  */
 public static void rearrangeRelatedItems(
     List<ClassContentsEntry> entries, RuleInstance ruleInstance, RelatedMethodsSettings rms) {
   List<RangeEntry> parentEntries = new ArrayList<RangeEntry>(ruleInstance.getMatches());
   for (RangeEntry o : parentEntries) {
     if (o instanceof RelatableEntry) {
       MethodEntry me = (MethodEntry) o;
       if (me.isGetter()) {
         if (me.myKeptWithProperty) {
           if (me.getMatchedRule() != null && me.getMatchedRule().getMatches() != null) {
             // prevent the getter from appearing under a rule it matches; it will be placed under
             // the property
             me.getMatchedRule().getMatches().remove(me);
           }
         }
         for (MethodEntry theSetter : me.myCorrespondingGetterSetters) {
           final RuleInstance theRule = theSetter.getMatchedRule();
           LOG.debug(
               "rearrangeRelatedItems: for getter method "
                   + me
                   + ", corresponding setter is "
                   + theSetter);
           if (theRule != null && theRule.getMatches() != null) {
             LOG.debug(
                 "remove entry "
                             + theSetter.myEnd
                             + " from matched rule"
                             + theRule
                             + "; matches = "
                             + ((java.util.List) theRule.getMatches())
                         == null
                     ? "null"
                     : "");
             theRule.getMatches().remove(theSetter);
           }
         }
       }
       if (me.myCalledMethods.size() > 0) {
         List<MethodEntry> parents = new LinkedList<MethodEntry>();
         parents.add(me);
         moveRelatedItems(
             entries,
             parents,
             rms,
             ((PsiMethod) me.myEnd).getName(),
             ((PsiMethod) me.myEnd).getName() + "()",
             1);
         if (LOG.isDebugEnabled()) {
           // dump sorted children recursively
           me.dumpChild(0);
         }
         me.assignComments(rms);
       }
     }
   }
 }
Ejemplo n.º 2
0
 void dumpChild(int level) {
   LOG.debug(level + ": " + ((PsiMethod) myEnd).getName());
   for (MethodEntry methodEntry : sortedMethods) {
     methodEntry.dumpChild(level + 1);
   }
 }