Inspect exposes recoverable fields alongside all syntax diagnostics. A nil commit means structural recovery was unsafe.
(input string)
| 24 | // Inspect exposes recoverable fields alongside all syntax diagnostics. |
| 25 | // A nil commit means structural recovery was unsafe. |
| 26 | func Inspect(input string) (Commit, []error) { |
| 27 | result := syntax.Inspect(input) |
| 28 | var diagnostics []error |
| 29 | if len(result.Diagnostics) > 0 { |
| 30 | diagnostics = make([]error, len(result.Diagnostics)) |
| 31 | for i := range diagnostics { |
| 32 | diagnostics[i] = &result.Diagnostics[i] |
| 33 | } |
| 34 | } |
| 35 | if !result.Structured { |
| 36 | return nil, diagnostics |
| 37 | } |
| 38 | return &defaultCommit{Commit: result.Commit}, diagnostics |
| 39 | } |
| 40 | |
| 41 | type defaultCommit struct { |
| 42 | syntax.Commit |
no outgoing calls