Repository navigation
Description
Problem
dimensions.json is thousands of lines. A diagnostic that names a mistyped identifier but not where it is written leaves the reader to go and search for it — which is most of the work.
SEM004 was fixed in #182: it now reports at the position in dimensions.json where the offending unit name appears, via MetadataFile.FindLocation.
context.ReportAt(
SemanticsDiagnostics.UnknownUnitReference,
dimensionsFile?.FindLocation(unitName),
unitName,
dim.Name);SEM001 (a relationship naming a dimension that does not exist) and SEM003 (a relationship requesting a vector form a participant does not declare) still report at Location.None. Both are typo-catchers, so they are exactly the diagnostics that most want a position.
Why they were left
They are raised from static collectors — CollectAllOperators → CollectIntegrals/CollectDerivatives → AddIntegralOpsForForm, and the CollectDotProducts/CollectCrossProducts pair — none of which currently receive the MetadataFile. Threading it through is about six call levels. That is a mechanical but wide change, and #182 was already large, so it was deliberately deferred rather than bundled in.
Suggested approach
Thread the MetadataFile? through the collectors the same way dimensionsFile is already threaded into ReportUnknownUnitReferences, then swap ReportUnknownReference and the SEM003 site from context.Report(...) to context.ReportAt(..., file?.FindLocation(name), ...).
FindLocation matches the first occurrence of the literal text, so a name appearing in several entries points at the first. That is approximate, and it is what SEM004 already does — navigable and slightly imprecise beats precise and unnavigable.
Acceptance criteria
- SEM001 and SEM003 report at a position in
dimensions.json. -
GeneratorDiagnosticTestsgains location assertions for both, matching the existingSem004_PointsAtWhereTheUnitIsWrittenRatherThanAtNothing.
Activity
refactor: clear the Sonar findings the wider analyzer reach exposed […
fix: point SEM001 and SEM003 at the metadata they are complaining abo…