// WithFileContextForFile will try to add a file context with lines matching the given matcher.
// If no match could be found, the original error is returned with false as the second return value.
767715
func WithFileContext(e error, realFilename string, r io.Reader, matcher LineMatcherFn) (error, bool) {
	if e == nil {
		panic("error missing")
	}
	le := UnwrapFileError(e)

	if le == nil {
		var ok bool
		if le, ok = ToFileError("", e).(FileError); !ok {
			return e, false
		}
	}

	var errCtx ErrorContext

	posle := le.Position()

	if posle.Offset != -1 {
		errCtx = locateError(r, le, func(m LineMatcher) bool {
			if posle.Offset >= m.Offset && posle.Offset < m.Offset+len(m.Line) {
				lno := posle.LineNumber - m.Position.LineNumber + m.LineNumber
				m.Position = text.Position{LineNumber: lno}
			}
			return matcher(m)
		})
	} else {
		errCtx = locateError(r, le, matcher)
	}

	pos := &errCtx.position

	if pos.LineNumber == -1 {
		return e, false
	}

	pos.Filename = realFilename

	if le.Type() != "" {
		errCtx.ChromaLexer = chromaLexerFromType(le.Type())
	} else {
		errCtx.ChromaLexer = chromaLexerFromFilename(realFilename)
	}

	return &ErrorWithFileContext{cause: e, ErrorContext: errCtx}, true
}
212595
func (o *PatchConfigParams) WithContext(ctx context.Context) *PatchConfigParams {
	o.SetContext(ctx)
	return o
}
789751
func (o *UploadTaskFileParams) WithContext(ctx context.Context) *UploadTaskFileParams {
	o.SetContext(ctx)
	return o
}
573681
func (o *GetVersionParams) WithContext(ctx context.Context) *GetVersionParams {
	o.SetContext(ctx)
	return o
}
1036432
func (o *PatchEndpointIDConfigParams) WithContext(ctx context.Context) *PatchEndpointIDConfigParams {
	o.SetContext(ctx)
	return o
}
30865
func (b *Batch) WithContext(ctx context.Context) *Batch {
	b2 := *b
	b2.context = ctx
	return &b2
}
947501
func (o *CreateParams) WithContext(ctx context.Context) *CreateParams {
	o.SetContext(ctx)
	return o
}
1293299
func (o *PetListParams) WithContext(ctx context.Context) *PetListParams {
	o.SetContext(ctx)
	return o
}
1041165
func (c *Ctx) WithContext(ctx context.Context) {
	c.request = c.request.WithContext(ctx)
}
1157596
func ContextWithDescriptor(ctx context.Context, d *Descriptor) context.Context {
	return context.WithValue(ctx, descriptorContextKey, d)
}
600890
func (o *GetFqdnCacheParams) WithContext(ctx context.Context) *GetFqdnCacheParams {
	o.SetContext(ctx)
	return o
}
879494
func (call *BulkLinkRichMenuCall) WithContext(ctx context.Context) *BulkLinkRichMenuCall {
	call.ctx = ctx
	return call
}
451694
func (call *DownloadRichMenuImageCall) WithContext(ctx context.Context) *DownloadRichMenuImageCall {
	call.ctx = ctx
	return call
}
213974
func (call *DeleteLIFFCall) WithContext(ctx context.Context) *DeleteLIFFCall {
	call.ctx = ctx
	return call
}
828306
func (call *ReplyMessageCall) WithContext(ctx context.Context) *ReplyMessageCall {
	call.ctx = ctx
	return call
}
1286175
func (o *GetMapParams) WithContext(ctx context.Context) *GetMapParams {
	o.SetContext(ctx)
	return o
}
740575
func (builder *UpdateGSetCommandBuilder) WithContext(context []byte) *UpdateGSetCommandBuilder {
	builder.protobuf.Context = context
	return builder
}