This commit is contained in:
@@ -223,43 +223,73 @@ public class WeComNotifier {
|
||||
: colorComment(desc);
|
||||
|
||||
switch (change.getKind()) {
|
||||
case ADDED:
|
||||
return quoteLine(tagAdded() + " " + fieldName + " 说明: " + descPart);
|
||||
case REMOVED:
|
||||
return quoteLine(tagRemoved() + " " + fieldName + " 说明: " + descPart);
|
||||
case RENAMED:
|
||||
case ADDED: {
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(tagAdded()).append(" ").append(fieldName)
|
||||
.append(" 说明: ").append(descPart);
|
||||
appendFieldType(line, change);
|
||||
return quoteLine(line.toString());
|
||||
}
|
||||
case REMOVED: {
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(tagRemoved()).append(" ").append(fieldName)
|
||||
.append(" 说明: ").append(descPart);
|
||||
appendFieldType(line, change);
|
||||
return quoteLine(line.toString());
|
||||
}
|
||||
case RENAMED: {
|
||||
StringBuilder renameLine = new StringBuilder();
|
||||
renameLine.append(tagRenamed()).append(" ")
|
||||
.append(colorComment(safe(change.getOldFieldName()))).append(" → ")
|
||||
.append(colorInfo(safe(change.getFieldName())))
|
||||
.append(" 说明: ").append(descPart);
|
||||
String renameTypeDetail = change.getDetail();
|
||||
if (renameTypeDetail != null && !renameTypeDetail.isBlank()) {
|
||||
renameLine.append(" 类型: ").append(formatTypeChange(renameTypeDetail));
|
||||
}
|
||||
appendFieldType(renameLine, change);
|
||||
return quoteLine(renameLine.toString());
|
||||
}
|
||||
case MODIFIED:
|
||||
default:
|
||||
default: {
|
||||
StringBuilder line = new StringBuilder();
|
||||
line.append(tagModified()).append(" ").append(fieldName)
|
||||
.append(" 说明: ").append(descPart);
|
||||
String detail = change.getDetail();
|
||||
if (detail != null && !detail.isBlank()) {
|
||||
line.append(" 类型: ").append(formatTypeChange(detail));
|
||||
}
|
||||
appendFieldType(line, change);
|
||||
return quoteLine(line.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 类型变化:旧 warning → 新 info */
|
||||
/** 追加字段类型:新增/重命名(仅改名)用 info,删除用 warning,修改/重命名(改类型)用 old → new */
|
||||
private void appendFieldType(StringBuilder line, FieldChange change) {
|
||||
if (change.getKind() == FieldChange.ChangeKind.RENAMED
|
||||
|| change.getKind() == FieldChange.ChangeKind.MODIFIED) {
|
||||
String typeDetail = change.getDetail();
|
||||
if (typeDetail != null && !typeDetail.isBlank()) {
|
||||
line.append(" 类型: ").append(formatTypeChange(typeDetail));
|
||||
return;
|
||||
}
|
||||
}
|
||||
String singleType = change.getKind() == FieldChange.ChangeKind.REMOVED
|
||||
? change.getOldType()
|
||||
: change.getNewType();
|
||||
if (singleType == null || singleType.isBlank()) {
|
||||
return;
|
||||
}
|
||||
line.append(" 类型: ");
|
||||
if (change.getKind() == FieldChange.ChangeKind.REMOVED) {
|
||||
line.append(colorWarning(singleType));
|
||||
} else {
|
||||
line.append(colorInfo(singleType));
|
||||
}
|
||||
}
|
||||
|
||||
/** 类型变化:旧 warning → 新 info;泛型尖括号原样展示,不做 HTML 转义 */
|
||||
private String formatTypeChange(String detail) {
|
||||
int arrow = detail.indexOf(" → ");
|
||||
if (arrow < 0) {
|
||||
return colorWarning(safe(detail));
|
||||
return colorWarning(detail);
|
||||
}
|
||||
String oldType = detail.substring(0, arrow).trim();
|
||||
String newType = detail.substring(arrow + 3).trim();
|
||||
return colorWarning(safe(oldType)) + " → " + colorInfo(safe(newType));
|
||||
return colorWarning(oldType) + " → " + colorInfo(newType);
|
||||
}
|
||||
|
||||
private String tagAdded() {
|
||||
|
||||
Reference in New Issue
Block a user