本文整理汇总了Java中com.intellij.util.StringLenComparator类的典型用法代码示例。如果您正苦于以下问题:Java StringLenComparator类的具体用法?Java StringLenComparator怎么用?Java StringLenComparator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringLenComparator类属于com.intellij.util包,在下文中一共展示了StringLenComparator类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.intellij.util.StringLenComparator; //导入依赖的package包/类
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());
}
示例2: getSuggestions
import com.intellij.util.StringLenComparator; //导入依赖的package包/类
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);
}