// ContextInfo takes a path and a line number and returns a slice of strings
// that represent the line in self, the preceding and the proceding lines. It
// also returns the offset for the actual line in the context.
485043
func ContextInfo(path string, lineNumber int) ([]string, int, error) {
	file, err := os.Open(path)
	if err != nil {
		return nil, -1, err
	}

	data, err := ioutil.ReadAll(file)
	if err != nil {
		return nil, -1, err
	}

	// We split on linebreak to get the lines.
	lines := strings.Split(string(data), "\n")

	// We try to get at most the 7 preceding lines.
	start := lineNumber - 7
	if start < 0 {
		start = 0
	}

	// Similar to the preceding lines, we also try for at most the 7 proceding
	// lines.
	end := lineNumber + 7
	if end >= len(lines) {
		end = len(lines) - 1
	}

	return lines[start:end], lineNumber - start, nil
}
193296
func (c *RetryCall) Context(ctx context.Context) *RetryCall {
	c.ctx_ = ctx
	return c
}
1366547
func Contexts() HandlerFunc {
	return func(ctx *Context) {
		if action := ctx.Action(); action != nil {
			if a, ok := action.(Contexter); ok {
				a.SetContext(ctx)
			}
		}
		ctx.Next()
	}
}
157209
func (o *GetDebuginfoParams) WithContext(ctx context.Context) *GetDebuginfoParams {
	o.SetContext(ctx)
	return o
}
385149
func NotifierFromContext(ctx context.Context) (*Notifier, bool) {
	n, ok := ctx.Value(notifierKey{}).(*Notifier)
	return n, ok
}
829893
func getContextAroundOffset(contents []byte, offset, lines int64) (context []byte, onLineOffset, lineOffset int64) {
	// get the end of the line previous to the one the error is on
	var start = getOffsetXLineBack(contents[:offset], 1)
	onLineOffset = offset - start
	// calculate the correct start of the context
	start = getOffsetXLineBack(contents[:start], lines)
	// get the end of the line the error is on
	var end = getOffsetXLineForward(contents[offset:], 1) + offset
	// correct lineOffset for the context
	lineOffset = end - start
	end = getOffsetXLineForward(contents[min(len(contents), int(end+1)):], lines) + end
	context = contents[start:min(len(contents), int(end+1))]
	return
}
280687
func (f *RelationalFieldDefinition) Context() string {
	if f.FieldName != "" {
		return fmt.Sprintf("RelationalField %#v", f.FieldName)
	}
	return "unnamed RelationalField"
}
182085
func (c *LeaseCall) Context(ctx context.Context) *LeaseCall {
	c.ctx_ = ctx
	return c
}
746285
func (c *TasksRequestsCall) Context(ctx context.Context) *TasksRequestsCall {
	c.ctx_ = ctx
	return c
}
53931
func (c *TaskResultCall) Context(ctx context.Context) *TaskResultCall {
	c.ctx_ = ctx
	return c
}
466753
func (r *RepoStatus) GetContext() string {
	if r == nil || r.Context == nil {
		return ""
	}
	return *r.Context
}
730678
func Info(ctx context.Context, msg string, logCtx ...interface{}) {
	FromContext(ctx).Info(msg, logCtx...)
}
1031716
func (c *GetConfigSetsCall) Context(ctx context.Context) *GetConfigSetsCall {
	c.ctx_ = ctx
	return c
}
715716
func Context(c *cli.Context) source.Option {
	return func(o *source.Options) {
		if o.Context == nil {
			o.Context = context.Background()
		}
		o.Context = context.WithValue(o.Context, contextKey{}, c)
	}
}
841098
func (a *APIDefinition) Context() string {
	if a.Name != "" {
		return fmt.Sprintf("API %#v", a.Name)
	}
	return "unnamed API"
}
909145
func (c *ContactDefinition) Context() string {
	if c.Name != "" {
		return fmt.Sprintf("contact %s", c.Name)
	}
	return "unnamed contact"
}
798651
func (c *GroupInsertCall) Context(ctx context.Context) *GroupInsertCall {
	c.ctx_ = ctx
	return c
}