Exemplo n.º 1
0
  private void updateComboBoxContent() {
    ignoreUiUpdates = true;
    Object selected = this.getSelectedItem();
    this.removeAllItems();
    this.addItem(NONE);
    this.addItem(ONE_PROFILE_FOR_EVERYTHING);
    MappingManager.getInstance().generateDefaultMappings().forEach(this::addItem);
    List<MappingSet> all = MappingManager.getInstance().getAll();
    if (all.size() > 0) {
      this.addItem(PREDEFINED_MAPPINGS);
      all.forEach(this::addItem);
    }

    if (VisicutModel.getInstance().getSelectedPart() != null) {
      Iterable<String> props =
          VisicutModel.getInstance()
              .getSelectedPart()
              .getGraphicObjects()
              .getInterestingAttributes();
      if (props.iterator().hasNext()) {
        this.addItem(BY_PROPERTY);
        int count = 0;
        for (String att : props) {
          if (++count > 4) {
            break;
          }
          this.addItem(new MapByPropertyEntry(att));
        }
      }
    }
    this.addItem(CUSTOM);
    this.setSelectedItem(selected);
    ignoreUiUpdates = false;
  }
    public int contextMatchCheck() {
      final Iterable<String> contextLines = myContext.getPreviousLinesIterable();

      // we ignore spaces.. at least at start/end, since some version controls could ignore their
      // changes when doing annotate
      final Iterator<String> iterator = contextLines.iterator();
      if (iterator.hasNext()) {
        String contextLine = iterator.next().trim();

        while (myChangedLinesIterator.hasNext()) {
          final Pair<Integer, String> pair = myChangedLinesIterator.next();
          if (pair.getSecond().trim().equals(contextLine)) {
            if (!iterator.hasNext()) break;
            contextLine = iterator.next().trim();
          }
        }
        if (iterator.hasNext()) {
          return -1;
        }
      }
      if (!myChangedLinesIterator.hasNext()) return -1;

      final String targetLine = myContext.getTargetString().trim();
      while (myChangedLinesIterator.hasNext()) {
        final Pair<Integer, String> pair = myChangedLinesIterator.next();
        if (pair.getSecond().trim().equals(targetLine)) {
          return pair.getFirst();
        }
      }
      return -1;
    }
        private boolean hasTypeParametersToInfer(PsiClassType classType) {
          final PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics();
          PsiClass aClass = resolveResult.getElement();
          if (aClass == null) return false;

          final Iterable<PsiTypeParameter> iterable =
              com.intellij.psi.util.PsiUtil.typeParametersIterable(aClass);
          if (!iterable.iterator().hasNext()) {
            return false;
          }

          for (PsiTypeParameter parameter : iterable) {
            PsiType type = resolveResult.getSubstitutor().substitute(parameter);
            if (type != null) {
              if (!(type instanceof PsiWildcardType)
                  || ((PsiWildcardType) type).getBound() != null) {
                return false;
              }
            }
          }
          return true;
        }