-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When overlay fails expects, report position of matches #91
Conversation
7b40145
to
3ead411
Compare
@@ -66,7 +66,12 @@ func (a ArrayItemMatchAnnotation) Indexes(leftArray *yamlmeta.Array) ([]int, err | |||
return nil, err | |||
} | |||
|
|||
return idxs, a.expects.Check(len(idxs)) | |||
nodes := MatchingNodes{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cppforlife one "draft" aspect of the PR is that — all things being equal — would expect MatchNodes
to return the collection of matching nodes. However, there is downstream logic that expects a collection of indexes.
A question I'm exploring: what made passing around indexes of matches a suitable tactic, to date? ... does this PR/feature now make passing around references more suitable (or not)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indexes are used to reference a node within its parent (eg array item within array). since things can be removed you need stable ref to what to remove.
3ead411
to
272209d
Compare
272209d
to
29b6f36
Compare
@cppforlife this PR is ready for a proper review / merge (I don't have permissions to mark it as ready for review). |
|
||
expectedErr := "Overlaying (in following order: overlay.yml): " + | ||
"Document on line overlay.yml:4: " + | ||
"Expected number of matched nodes to be 1, but was 2\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably just use parenthesis with commas (e.g. but was 2 (line tpl.yml:2, line tpl.yml:6)
). multiline errors for now arent formatted properly in nested errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I invested the least attention to this aspect having no real idea of what would work. The format you suggest reads better than one-per-line.
if lastErr == nil { | ||
return nil | ||
} | ||
} | ||
return lastErr | ||
} | ||
|
||
func formatPositions(pos []*filepos.Position) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets place formatPositions on MatchAnnotationExpectsKwarg. you can use func (MatchAnnotationExpectsKwarg) formatPositions(...
sig with naming MatchAnnotationExpectsKwarg
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, not sure why I didn't do that: it's an implementation detail of #Check()
.
left a few comments. otherwise look good. |
... to keep nested errors readable -- multiline output breaks formatting. - and scope `formatPositions()` as a member function of `MatchAnnotationExpectsKwarg`: it is an implementation detail of output from `Check()`.
merged. minor fixes added: a3c0f3d...1227be5 |
(this is a sketch, intended to spark dialogue and critique)
aimed at #76