Skip to content

Commit b105aac

Browse files
committed
internal/lsp: use regexp to add go mod edit -go quick fix
Fixes golang/go#51086 Change-Id: Iebe51355e016809442af37debf140d9ba2f3317a Reviewed-on: https://go-review.googlesource.com/c/tools/+/390615 Reviewed-by: Robert Findley <[email protected]> Trust: Suzy Mueller <[email protected]>
1 parent 03d333a commit b105aac

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

internal/lsp/cache/errors.go

+5-7
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func parseErrorDiagnostics(snapshot *snapshot, pkg *pkg, errList scanner.ErrorLi
101101
}
102102

103103
var importErrorRe = regexp.MustCompile(`could not import ([^\s]+)`)
104-
var unsupportedFeatureRe = regexp.MustCompile(`.*require go(\d+\.\d+) or later`)
104+
var unsupportedFeatureRe = regexp.MustCompile(`.*require.* go(\d+\.\d+) or later`)
105105

106106
func typeErrorDiagnostics(snapshot *snapshot, pkg *pkg, e extendedError) ([]*source.Diagnostic, error) {
107107
code, spn, err := typeErrorData(snapshot.FileSet(), pkg, e.primary)
@@ -146,12 +146,10 @@ func typeErrorDiagnostics(snapshot *snapshot, pkg *pkg, e extendedError) ([]*sou
146146
return nil, err
147147
}
148148
}
149-
if code == typesinternal.UnsupportedFeature {
150-
if match := unsupportedFeatureRe.FindStringSubmatch(e.primary.Msg); match != nil {
151-
diag.SuggestedFixes, err = editGoDirectiveQuickFix(snapshot, spn.URI(), match[1])
152-
if err != nil {
153-
return nil, err
154-
}
149+
if match := unsupportedFeatureRe.FindStringSubmatch(e.primary.Msg); match != nil {
150+
diag.SuggestedFixes, err = editGoDirectiveQuickFix(snapshot, spn.URI(), match[1])
151+
if err != nil {
152+
return nil, err
155153
}
156154
}
157155
return []*source.Diagnostic{diag}, nil

0 commit comments

Comments
 (0)