mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-05 00:39:59 +00:00
b966d3b157
Bumps [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) from 1.8.1 to 1.8.2. - [Release notes](https://github.com/gin-gonic/gin/releases) - [Changelog](https://github.com/gin-gonic/gin/blob/master/CHANGELOG.md) - [Commits](https://github.com/gin-gonic/gin/compare/v1.8.1...v1.8.2) --- updated-dependencies: - dependency-name: github.com/gin-gonic/gin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
108 lines
1.8 KiB
Go
108 lines
1.8 KiB
Go
package toml
|
|
|
|
import (
|
|
"github.com/pelletier/go-toml/v2/internal/danger"
|
|
"github.com/pelletier/go-toml/v2/internal/tracker"
|
|
"github.com/pelletier/go-toml/v2/unstable"
|
|
)
|
|
|
|
type strict struct {
|
|
Enabled bool
|
|
|
|
// Tracks the current key being processed.
|
|
key tracker.KeyTracker
|
|
|
|
missing []unstable.ParserError
|
|
}
|
|
|
|
func (s *strict) EnterTable(node *unstable.Node) {
|
|
if !s.Enabled {
|
|
return
|
|
}
|
|
|
|
s.key.UpdateTable(node)
|
|
}
|
|
|
|
func (s *strict) EnterArrayTable(node *unstable.Node) {
|
|
if !s.Enabled {
|
|
return
|
|
}
|
|
|
|
s.key.UpdateArrayTable(node)
|
|
}
|
|
|
|
func (s *strict) EnterKeyValue(node *unstable.Node) {
|
|
if !s.Enabled {
|
|
return
|
|
}
|
|
|
|
s.key.Push(node)
|
|
}
|
|
|
|
func (s *strict) ExitKeyValue(node *unstable.Node) {
|
|
if !s.Enabled {
|
|
return
|
|
}
|
|
|
|
s.key.Pop(node)
|
|
}
|
|
|
|
func (s *strict) MissingTable(node *unstable.Node) {
|
|
if !s.Enabled {
|
|
return
|
|
}
|
|
|
|
s.missing = append(s.missing, unstable.ParserError{
|
|
Highlight: keyLocation(node),
|
|
Message: "missing table",
|
|
Key: s.key.Key(),
|
|
})
|
|
}
|
|
|
|
func (s *strict) MissingField(node *unstable.Node) {
|
|
if !s.Enabled {
|
|
return
|
|
}
|
|
|
|
s.missing = append(s.missing, unstable.ParserError{
|
|
Highlight: keyLocation(node),
|
|
Message: "missing field",
|
|
Key: s.key.Key(),
|
|
})
|
|
}
|
|
|
|
func (s *strict) Error(doc []byte) error {
|
|
if !s.Enabled || len(s.missing) == 0 {
|
|
return nil
|
|
}
|
|
|
|
err := &StrictMissingError{
|
|
Errors: make([]DecodeError, 0, len(s.missing)),
|
|
}
|
|
|
|
for _, derr := range s.missing {
|
|
derr := derr
|
|
err.Errors = append(err.Errors, *wrapDecodeError(doc, &derr))
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
func keyLocation(node *unstable.Node) []byte {
|
|
k := node.Key()
|
|
|
|
hasOne := k.Next()
|
|
if !hasOne {
|
|
panic("should not be called with empty key")
|
|
}
|
|
|
|
start := k.Node().Data
|
|
end := k.Node().Data
|
|
|
|
for k.Next() {
|
|
end = k.Node().Data
|
|
}
|
|
|
|
return danger.BytesRange(start, end)
|
|
}
|