Java 类com.intellij.util.StringLenComparator 实例源码

项目:intellij-ce-playground    文件:VcsRootIterator.java   
private void init(final VcsRoot[] allRoots) {
  final String ourPath = myRoot.getUrl();

  for (VcsRoot root : allRoots) {
    final AbstractVcs vcs = root.getVcs();
    if (vcs == null || Comparing.equal(vcs.getName(), myVcsName)) continue;
    final VirtualFile path = root.getPath();
    if (path != null) {
      final String url = path.getUrl();
      if (url.startsWith(ourPath)) {
        myExcludedByOthers.add(url);
      }
    }
  }

  Collections.sort(myExcludedByOthers, StringLenComparator.getDescendingInstance());
}
项目:tools-idea    文件:VcsRootIterator.java   
private void init(final VcsRoot[] allRoots) {
  final String ourPath = myRoot.getUrl();

  for (VcsRoot root : allRoots) {
    final AbstractVcs vcs = root.getVcs();
    if (vcs == null || Comparing.equal(vcs.getName(), myVcsName)) continue;
    final VirtualFile path = root.getPath();
    if (path != null) {
      final String url = path.getUrl();
      if (url.startsWith(ourPath)) {
        myExcludedByOthers.add(url);
      }
    }
  }

  Collections.sort(myExcludedByOthers, StringLenComparator.getDescendingInstance());
}
项目:consulo    文件:VcsRootIterator.java   
private void init(final VcsRoot[] allRoots) {
  final String ourPath = myRoot.getUrl();

  for (VcsRoot root : allRoots) {
    final AbstractVcs vcs = root.getVcs();
    if (vcs == null || Comparing.equal(vcs.getName(), myVcsName)) continue;
    final VirtualFile path = root.getPath();
    if (path != null) {
      final String url = path.getUrl();
      if (url.startsWith(ourPath)) {
        myExcludedByOthers.add(url);
      }
    }
  }

  Collections.sort(myExcludedByOthers, StringLenComparator.getDescendingInstance());
}
项目:intellij-ce-playground    文件:IntroducePropertyDialog.java   
private String[] getSuggestions(int level) {
  Collection<String> result = new THashSet<String>();

  String value = mySelectedString.trim();
  boolean addUnqualifiedForm = true;

  XmlTag parent = PsiTreeUtil.getParentOfType(myContext, XmlTag.class, false);

  DomElement domParent = DomUtil.getDomElement(parent);
  if (domParent != null) {
    DomElement domSuperParent = domParent.getParent();
    DomFileElement<DomElement> domFile = DomUtil.getFileElement(domParent);
    if (domSuperParent != null && domFile != null && domFile.getRootElement() == domSuperParent) {
      value = domSuperParent.getXmlElementName();
      addUnqualifiedForm = false;
    }
    else {
      MavenDomShortArtifactCoordinates coordinates = DomUtil.getParentOfType(domParent, MavenDomShortArtifactCoordinates.class, false);
      if (coordinates != null && !(coordinates instanceof MavenDomProjectModel) && domParent != coordinates.getArtifactId()) {
        String artifactId = coordinates.getArtifactId().getStringValue();
        if (!StringUtil.isEmptyOrSpaces(artifactId)) {
          value = artifactId;
          addUnqualifiedForm = false;
        }
      }
    }
  }

  while (true) {
    String newValue = value.replaceAll("  ", " ");
    if (newValue.equals(value)) break;
    value = newValue;
  }

  value = value.replaceAll(" ", ".");
  List<String> parts = StringUtil.split(value, ".");
  String shortValue = parts.get(parts.size() - 1);

  if (addUnqualifiedForm) {
    result.add(value);
    result.add(shortValue);
  }

  String suffix = "";
  while (parent != null && level != 0) {
    suffix = parent.getName() + suffix;
    result.add(suffix);
    result.add(value + "." + suffix);
    result.add(shortValue + "." + suffix);
    suffix = "." + suffix;
    parent = parent.getParentTag();
    level--;
  }

  result = new ArrayList<String>(result);
  Collections.sort((List)result, CodeStyleSettingsManager.getSettings(myProject).PREFER_LONGER_NAMES ?
                                 StringLenComparator.getDescendingInstance() : StringLenComparator.getInstance());
  return ArrayUtil.toStringArray(result);
}
项目:tools-idea    文件:IntroducePropertyDialog.java   
private String[] getSuggestions(int level) {
  Collection<String> result = new THashSet<String>();

  String value = mySelectedString.trim();
  boolean addUnqualifiedForm = true;

  XmlTag parent = PsiTreeUtil.getParentOfType(myContext, XmlTag.class, false);

  DomElement domParent = DomUtil.getDomElement(parent);
  if (domParent != null) {
    DomElement domSuperParent = domParent.getParent();
    DomFileElement<DomElement> domFile = DomUtil.getFileElement(domParent);
    if (domSuperParent != null && domFile != null && domFile.getRootElement() == domSuperParent) {
      value = domSuperParent.getXmlElementName();
      addUnqualifiedForm = false;
    }
    else {
      MavenDomShortArtifactCoordinates coordinates = DomUtil.getParentOfType(domParent, MavenDomShortArtifactCoordinates.class, false);
      if (coordinates != null && !(coordinates instanceof MavenDomProjectModel) && domParent != coordinates.getArtifactId()) {
        String artifactId = coordinates.getArtifactId().getStringValue();
        if (!StringUtil.isEmptyOrSpaces(artifactId)) {
          value = artifactId;
          addUnqualifiedForm = false;
        }
      }
    }
  }

  while (true) {
    String newValue = value.replaceAll("  ", " ");
    if (newValue.equals(value)) break;
    value = newValue;
  }

  value = value.replaceAll(" ", ".");
  List<String> parts = StringUtil.split(value, ".");
  String shortValue = parts.get(parts.size() - 1);

  if (addUnqualifiedForm) {
    result.add(value);
    result.add(shortValue);
  }

  String suffix = "";
  while (parent != null && level != 0) {
    suffix = parent.getName() + suffix;
    result.add(suffix);
    result.add(value + "." + suffix);
    result.add(shortValue + "." + suffix);
    suffix = "." + suffix;
    parent = parent.getParentTag();
    level--;
  }

  result = new ArrayList<String>(result);
  Collections.sort((List)result, CodeStyleSettingsManager.getSettings(myProject).PREFER_LONGER_NAMES ?
                                 StringLenComparator.getDescendingInstance() : StringLenComparator.getInstance());
  return ArrayUtil.toStringArray(result);
}