Skip to content

Commit 533c134

Browse files
committed
Remove id from paths to instances in style warnings
1 parent 049b464 commit 533c134

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

shared/src/main/scala/io/kaitai/struct/precompile/StyleCheckIds.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@ class StyleCheckIds(specs: ClassSpecs) extends PrecompileStep {
4444
val existingName = sizeRefAttr.id.humanReadable
4545
val goodName = s"len_${attr.id.humanReadable}"
4646
if (existingName != goodName) {
47+
// Add `id` for attributes in `seq`, do not add for instances
48+
val path = attr match {
49+
case _: AttrSpec => sizeRefAttr.path ++ List("id")
50+
case _ => sizeRefAttr.path
51+
}
4752
Some(StyleWarningSizeLen(
4853
goodName,
4954
existingName,
5055
attr.id.humanReadable,
51-
ProblemCoords(path = Some(sizeRefAttr.path ++ List("id")))
56+
ProblemCoords(path = Some(path))
5257
))
5358
} else {
5459
None
@@ -61,11 +66,16 @@ class StyleCheckIds(specs: ClassSpecs) extends PrecompileStep {
6166
val existingName = repeatExprRefAttr.id.humanReadable
6267
val goodName = s"num_${attr.id.humanReadable}"
6368
if (existingName != goodName) {
69+
// Add `id` for attributes in `seq`, do not add for instances
70+
val path = attr match {
71+
case _: AttrSpec => repeatExprRefAttr.path ++ List("id")
72+
case _ => repeatExprRefAttr.path
73+
}
6474
Some(StyleWarningRepeatExprNum(
6575
goodName,
6676
existingName,
6777
attr.id.humanReadable,
68-
ProblemCoords(path = Some(repeatExprRefAttr.path ++ List("id")))
78+
ProblemCoords(path = Some(path))
6979
))
7080
} else {
7181
None

0 commit comments

Comments
 (0)