Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 9e517be

Browse files
committed
more exact feedback cleaning including at EOF
1 parent 2825708 commit 9e517be

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

base.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ func (pd *ParseData) CleanFeedback() {
109109
if pd.Result.HasError() || len(pd.Result.Feedback) == 0 { // in error case we need all information
110110
return
111111
}
112-
pos := pd.Result.Pos + len(pd.Result.Text) // clean until here
112+
start := pd.Result.Pos
113+
end := start + len(pd.Result.Text) // clean until here
113114
cleanFeedback := make([]*FeedbackItem, 0, len(pd.Result.Feedback))
114115
for _, fb := range pd.Result.Feedback {
115-
if fb.Kind != FeedbackPotentialProblem || fb.Pos >= pos {
116+
if fb.Kind != FeedbackPotentialProblem || fb.Pos < start || fb.Pos >= end {
116117
cleanFeedback = append(cleanFeedback, fb)
117118
}
118119
}

simple_parser.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,23 @@ func ParseEOF(
169169
)
170170
} else {
171171
createMatchedResult(pd, 0)
172+
cleanEOFFeedback(pd.Result)
172173
}
173174
return handleSemantics(pluginSemantics, pd, ctx)
174175
}
176+
func cleanEOFFeedback(pr *ParseResult) {
177+
if pr.HasError() || len(pr.Feedback) == 0 { // in error case we need all information
178+
return
179+
}
180+
pos := pr.Pos
181+
cleanFeedback := make([]*FeedbackItem, 0, len(pr.Feedback))
182+
for _, fb := range pr.Feedback {
183+
if fb.Kind != FeedbackPotentialProblem || fb.Pos != pos {
184+
cleanFeedback = append(cleanFeedback, fb)
185+
}
186+
}
187+
pr.Feedback = cleanFeedback
188+
}
175189

176190
// NewParseEOFPlugin creates a plugin sporting an EOF parser.
177191
func NewParseEOFPlugin(pluginSemantics SemanticsOp) SubparserOp {

0 commit comments

Comments
 (0)