代码拉取完成,页面将自动刷新
package compiler
import (
"gitee.com/jackytse/tabtoy/v3/model"
"gitee.com/jackytse/tabtoy/v3/report"
)
func checkRepeat(globals *model.Globals) {
for _, tab := range globals.Datas.AllTables() {
// 遍历输入数据的每一列
for _, header := range tab.Headers {
// 输入的列头,为空表示改列被注释
if header.TypeInfo == nil {
continue
}
// 这列需要建立索引
if header.TypeInfo.MakeIndex {
checker := map[string]*model.Cell{}
for row := 1; row < len(tab.Rows); row++ {
inputCell := tab.GetCell(row, header.Cell.Col)
// 这行被注释,无效行
if inputCell == nil {
break
}
if _, ok := checker[inputCell.Value]; ok {
report.ReportError("DuplicateValueInMakingIndex", inputCell.String())
} else {
checker[inputCell.Value] = inputCell
}
}
}
}
}
}
// 枚举值的解析是放在输出端处理的, 例如json中, 所以在这里提前检查
func checkEnumValue(globals *model.Globals) {
for _, tab := range globals.Datas.AllTables() {
// 遍历输入数据的每一列
for _, header := range tab.Headers {
// 输入的列头,为空表示改列被注释
if header.TypeInfo == nil {
continue
}
if !globals.Types.IsEnumKind(header.TypeInfo.FieldType) {
continue
}
for row := 1; row < len(tab.Rows); row++ {
inputCell := tab.GetCell(row, header.Cell.Col)
// 这行被注释,无效行
if inputCell == nil {
break
}
resolvedType := globals.Types.ResolveEnumValue(header.TypeInfo.FieldType, inputCell.Value)
if resolvedType == "" {
report.ReportError("UnknownEnumValue", header.TypeInfo.FieldType, inputCell.String())
}
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。