mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git tests] shorten test names
* test name is used in application and project folders * Introduce one more shortenText-utility method to let specify arbitrary ellipsis symbol (to avoid "..." in directory names not to confuse any FS or Git).
This commit is contained in:
@@ -2513,10 +2513,9 @@ public class StringUtil extends StringUtilRt {
|
||||
public static String shortenTextWithEllipsis(@NotNull final String text,
|
||||
final int maxLength,
|
||||
final int suffixLength,
|
||||
boolean useEllipsisSymbol) {
|
||||
@NotNull String symbol) {
|
||||
final int textLength = text.length();
|
||||
if (textLength > maxLength) {
|
||||
String symbol = useEllipsisSymbol ? "\u2026" : "...";
|
||||
final int prefixLength = maxLength - suffixLength - symbol.length();
|
||||
assert prefixLength > 0;
|
||||
return text.substring(0, prefixLength) + symbol + text.substring(textLength - suffixLength);
|
||||
@@ -2526,6 +2525,15 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String shortenTextWithEllipsis(@NotNull final String text,
|
||||
final int maxLength,
|
||||
final int suffixLength,
|
||||
boolean useEllipsisSymbol) {
|
||||
String symbol = useEllipsisSymbol ? "\u2026" : "...";
|
||||
return shortenTextWithEllipsis(text, maxLength, suffixLength, symbol);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String shortenPathWithEllipsis(@NotNull final String path, final int maxLength, boolean useEllipsisSymbol) {
|
||||
return shortenTextWithEllipsis(path, maxLength, (int)(maxLength * 0.7), useEllipsisSymbol);
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
|
||||
@@ -112,9 +113,9 @@ public abstract class GitPlatformTest extends UsefulTestCase {
|
||||
@NotNull
|
||||
public String getTestName(boolean lowercaseFirstLetter) {
|
||||
String name = super.getTestName(lowercaseFirstLetter);
|
||||
name = name.trim().replace(' ', '_');
|
||||
if (name.length() > 50) {
|
||||
name = name.substring(0, 50);
|
||||
name = StringUtil.shortenTextWithEllipsis(name.trim().replace(" ", "_"), 12, 6, "_");
|
||||
if (name.startsWith("_")) {
|
||||
name = name.substring(1);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user