@SuppressWarnings({"HardCodedStringLiteral"})
  public void dumpStatistics() {
    System.out.println("Statistics:");
    final TObjectIntHashMap<Object> map = new TObjectIntHashMap<Object>();

    final PsiElementVisitor psiRecursiveElementVisitor =
        new XmlRecursiveElementVisitor() {
          @NonNls private static final String TOKENS_KEY = "Tokens";
          @NonNls private static final String ELEMENTS_KEY = "Elements";

          @Override
          public void visitXmlToken(XmlToken token) {
            inc(TOKENS_KEY);
          }

          @Override
          public void visitElement(PsiElement element) {
            inc(ELEMENTS_KEY);
            super.visitElement(element);
          }

          private void inc(final String key) {
            map.put(key, map.get(key) + 1);
          }
        };

    accept(psiRecursiveElementVisitor);

    final Object[] keys = map.keys();
    for (final Object key : keys) {
      System.out.println(key + ": " + map.get(key));
    }
  }
 private TIntArrayList getParametersToRemove() {
   TIntArrayList list = new TIntArrayList();
   for (Object o : toRemoveCBs.keys()) {
     if (((JCheckBox) o).isSelected()) {
       list.add(toRemoveCBs.get((JCheckBox) o));
     }
   }
   return list;
 }
    @Override
    public void dispose() {
      synchronized (ourInstances) {
        ourInstances.remove(myParent);

        for (Object o : myCounts.keys()) {
          VirtualFilePointerImpl pointer = (VirtualFilePointerImpl) o;
          int disposeCount = myCounts.get(pointer);
          int after = pointer.myNode.incrementUsageCount(-disposeCount + 1);
          LOG.assertTrue(after > 0, after);
          pointer.dispose();
        }
      }
    }
  private void createCheckBoxes(JPanel panel) {
    myDeclareFinalCheckBox = new JCheckBox(UIUtil.replaceMnemonicAmpersand("Declare &final"));
    myDeclareFinalCheckBox.setFocusable(false);
    panel.add(myDeclareFinalCheckBox);

    myDelegateViaOverloadingMethodCheckBox =
        new JCheckBox(UIUtil.replaceMnemonicAmpersand("De&legate via overloading method"));
    myDelegateViaOverloadingMethodCheckBox.setFocusable(false);
    panel.add(myDelegateViaOverloadingMethodCheckBox);

    for (Object o : toRemoveCBs.keys()) {
      final JCheckBox cb = (JCheckBox) o;
      cb.setFocusable(false);
      panel.add(cb);
    }
  }
예제 #5
0
  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();

    if (myVarIndex.size() != myVarSizes.size()) {
      return "inconsistent";
    }

    List<Trinity<DeclarationDescriptor, Integer, Integer>> descriptors = Lists.newArrayList();

    for (Object descriptor0 : myVarIndex.keys()) {
      DeclarationDescriptor descriptor = (DeclarationDescriptor) descriptor0;
      int varIndex = myVarIndex.get(descriptor);
      int varSize = myVarSizes.get(descriptor);
      descriptors.add(Trinity.create(descriptor, varIndex, varSize));
    }

    Collections.sort(
        descriptors,
        new Comparator<Trinity<DeclarationDescriptor, Integer, Integer>>() {
          @Override
          public int compare(
              Trinity<DeclarationDescriptor, Integer, Integer> left,
              Trinity<DeclarationDescriptor, Integer, Integer> right) {
            return left.second - right.second;
          }
        });

    sb.append("size=").append(myMaxIndex);

    boolean first = true;
    for (Trinity<DeclarationDescriptor, Integer, Integer> t : descriptors) {
      if (!first) {
        sb.append(", ");
      }
      first = false;
      sb.append(t.first).append(",i=").append(t.second).append(",s=").append(t.third);
    }

    return sb.toString();
  }
  public GrIntroduceParameterDialog(IntroduceParameterInfo info) {
    super(info.getProject(), true);
    myInfo = info;
    myProject = info.getProject();
    myCanIntroduceSimpleParameter =
        GroovyIntroduceParameterUtil.findExpr(myInfo) != null
            || GroovyIntroduceParameterUtil.findVar(myInfo) != null
            || findStringPart() != null;

    TObjectIntHashMap<GrParameter> parametersToRemove =
        GroovyIntroduceParameterUtil.findParametersToRemove(info);
    toRemoveCBs = new TObjectIntHashMap<JCheckBox>(parametersToRemove.size());
    for (Object p : parametersToRemove.keys()) {
      JCheckBox cb =
          new JCheckBox(
              GroovyRefactoringBundle.message(
                  "remove.parameter.0.no.longer.used", ((GrParameter) p).getName()));
      toRemoveCBs.put(cb, parametersToRemove.get((GrParameter) p));
      cb.setSelected(true);
    }

    init();
  }