Prepare scene extraction and deterministic normalization in core
This commit is contained in:
@@ -63,15 +63,15 @@ func (n *Normalizer) ReferenceSlots() []contracts.ReferenceSlot {
|
||||
return referenceSlots()
|
||||
}
|
||||
|
||||
func (n *Normalizer) Normalize(ctx context.Context, req contracts.TypedNormalizeRequest[dnd.SpellList]) (contracts.TypedNormalizeResult[dnd.SpellList], error) {
|
||||
func (n *Normalizer) PrepareNormalize(ctx context.Context, req contracts.NormalizeInput[dnd.SpellList]) (contracts.PreparedOperation[dnd.SpellList], error) {
|
||||
if n == nil {
|
||||
return contracts.TypedNormalizeResult[dnd.SpellList]{}, normalizerErrorf("normalizer must not be nil")
|
||||
return nil, normalizerErrorf("normalizer must not be nil")
|
||||
}
|
||||
if ctx == nil {
|
||||
return contracts.TypedNormalizeResult[dnd.SpellList]{}, normalizerErrorf("context must not be nil")
|
||||
return nil, normalizerErrorf("context must not be nil")
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
return contracts.TypedNormalizeResult[dnd.SpellList]{}, normalizerErrorf("context error before normalize: %w", err)
|
||||
return nil, normalizerErrorf("context error before normalize: %w", err)
|
||||
}
|
||||
|
||||
index := source.NewDocumentIndex(req.Source)
|
||||
@@ -81,9 +81,9 @@ func (n *Normalizer) Normalize(ctx context.Context, req contracts.TypedNormalize
|
||||
findings = append(findings, duplicateFindings...)
|
||||
diagnosticGroups, err := diagnostics.NormalizationDiagnostics(findings, ReasonCodeSpellNameUnresolved)
|
||||
if err != nil {
|
||||
return contracts.TypedNormalizeResult[dnd.SpellList]{}, normalizerErrorf("collect diagnostics: %w", err)
|
||||
return nil, normalizerErrorf("collect diagnostics: %w", err)
|
||||
}
|
||||
return contracts.TypedNormalizeResult[dnd.SpellList]{Value: value, Diagnostics: diagnosticGroups}, nil
|
||||
return contracts.DeterministicOperation[dnd.SpellList]{Evaluation: contracts.CandidateEvaluation[dnd.SpellList]{Result: contracts.EvaluationView[dnd.SpellList]{Candidate: &value, Diagnostics: diagnosticGroups}}}, nil
|
||||
}
|
||||
|
||||
func normalizeSpellList(input dnd.SpellList, catalog spellcatalog.EffectiveCatalog, order shared.SourceRefOrder) (dnd.SpellList, []diagnostics.Finding) {
|
||||
|
||||
Reference in New Issue
Block a user