Java: render string literal with colon correctly in structure view (IDEA-138681)

GitOrigin-RevId: c1f6b7872d3b6f556582b84df35892f0ef2aa6d3
This commit is contained in:
Bas Leijdekkers
2025-10-12 17:20:37 +00:00
committed by intellij-monorepo-bot
parent 278fba7b9b
commit b6e7af0698
2 changed files with 17 additions and 5 deletions
@@ -25,11 +25,11 @@ public abstract class JavaVariableBaseTreeElement<T extends PsiVariable> extends
if (field == null) return "";
final boolean dumb = DumbService.isDumb(field.getProject());
return StringUtil.replace(formatVariable(
field,
SHOW_NAME | (dumb ? 0 : SHOW_TYPE) | TYPE_AFTER | (dumb ? 0 : SHOW_INITIALIZER),
PsiSubstitutor.EMPTY
), ":", ": ");
final String text = formatVariable(field,
SHOW_NAME | (dumb ? 0 : SHOW_TYPE) | TYPE_AFTER | (dumb ? 0 : SHOW_INITIALIZER),
PsiSubstitutor.EMPTY);
final int colon = text.indexOf(':');
return colon >= 0 ? text.substring(0, colon + 1) + ' ' + text.substring(colon + 1) : text;
}
@Override