// TaskComments gets all taskComments for all lists.
775921
func (c oauthClient) TaskComments() ([]wl.TaskComment, error) {
	lists, err := c.Lists()
	if err != nil {
		return nil, err
	}

	listCount := len(lists)
	c.logger.Debug(
		"taskComments",
		map[string]interface{}{"listCount": listCount},
	)

	taskCommentsChan := make(chan []wl.TaskComment, listCount)
	idErrChan := make(chan idErr, listCount)
	for _, l := range lists {
		go func(list wl.List) {
			c.logger.Debug(
				"taskComments - getting taskComments for list",
				map[string]interface{}{"listID": list.ID},
			)
			taskComments, err := c.TaskCommentsForListID(list.ID)
			idErrChan <- idErr{idType: "list", id: list.ID, err: err}
			taskCommentsChan <- taskComments
		}(l)
	}

	e := multiIDErr{}
	for i := 0; i < listCount; i++ {
		idErr := <-idErrChan
		if idErr.err != nil {
			c.logger.Debug(
				"taskComments - error received getting taskComments for list",
				map[string]interface{}{"listID": idErr.id, "err": err},
			)
			e.addError(idErr)
		}
	}

	totalTaskComments := []wl.TaskComment{}
	for i := 0; i < listCount; i++ {
		taskComments := <-taskCommentsChan
		totalTaskComments = append(totalTaskComments, taskComments...)
	}

	if len(e.errors()) > 0 {
		return totalTaskComments, e
	}

	return totalTaskComments, nil
}
877603
func (r *marathonClient) AllTasks(opts *AllTasksOpts) (*Tasks, error) {
	path, err := addOptions(marathonAPITasks, opts)
	if err != nil {
		return nil, err
	}

	tasks := new(Tasks)
	if err := r.apiGet(path, nil, tasks); err != nil {
		return nil, err
	}

	return tasks, nil
}
307685
func (c *Comments) MarkComments(position CommentPosition) {
	for _, comment := range c.Comments {
		if comment.Position == TBD {
			comment.Position = position
		}
	}
	for _, c := range c.future {
		if c.Position == TBD {
			c.Position = position
		}
	}
}
991614
func (s *TeamsService) ListComments(ctx context.Context, teamID int64, discussionNumber int, options *DiscussionCommentListOptions) ([]*DiscussionComment, *Response, error) {
	u := fmt.Sprintf("teams/%v/discussions/%v/comments", teamID, discussionNumber)
	u, err := addOptions(u, options)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	// TODO: remove custom Accept header when this API fully launches.
	req.Header.Set("Accept", mediaTypeTeamDiscussionsPreview)

	var comments []*DiscussionComment
	resp, err := s.client.Do(ctx, req, &comments)
	if err != nil {
		return nil, resp, err
	}

	return comments, resp, nil
}
706999
func (a *Client) GetTaskComments(params *GetTaskCommentsParams) (*GetTaskCommentsOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetTaskCommentsParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "getTaskComments",
		Method:             "GET",
		PathPattern:        "/tasks/{id}/comments",
		ProducesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
		ConsumesMediaTypes: []string{"application/vnd.goswagger.examples.task-tracker.v1+json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetTaskCommentsReader{formats: a.formats},
		Context:            params.Context,
		Client:             params.HTTPClient,
	})
	if err != nil {
		return nil, err
	}
	return result.(*GetTaskCommentsOK), nil

}
1368881
func (h *helper) buildComments(inf interface{}) {
	switch tp := inf.(type) {
	case []interface{}: //Maybe array for base comments
		for _, k := range tp {
			h.buildComments(k)
		}
	case map[string]interface{}: //Maybe comment data
		if tp["body"] == nil {
			for _, k := range tp {
				h.buildComments(k)
			}
		} else {
			h.comments = append(h.comments, makeComment(tp))
		}
	}
}
1202310
func RemoveComments(s string) string {
	pos := strings.Index(s, "#")
	if pos == -1 {
		return s
	}
	return strings.TrimSpace(s[0:pos])
}
706193
func LineComments(b bool) option {
	return func(c *sass) error {
		c.cmt = b
		return nil
	}
}
1335249
func workItemIncludeComments(request *http.Request, wi *workitem.WorkItem, wi2 *app.WorkItem) {
	wi2.Relationships.Comments = CreateCommentsRelation(request, wi)
}
296168
func (operation *Operation) ParseTagsComment(commentLine string) {
	tags := strings.Split(commentLine, ",")
	for _, tag := range tags {
		operation.Tags = append(operation.Tags, strings.TrimSpace(tag))
	}
}
223172
func (s *globalTaskService) TaskInspect(taskID int) *types.Task {
	s.RLock()
	defer s.RUnlock()
	if t, ok := s.tasks[taskID]; ok {
		return &t.Task
	}
	return nil
}
867397
func ToComments(wdst io.Writer, rsrc io.Reader) (fps []*Failpoint, err error) {
	src := bufio.NewReader(rsrc)
	dst := bufio.NewWriter(wdst)
	ws := ""
	unmatchedBraces := 0
	for err == nil {
		l, rerr := src.ReadString('\n')
		err = rerr
		lTrim := strings.TrimSpace(l)

		if unmatchedBraces > 0 {
			opening, closing := numBraces(l)
			unmatchedBraces += opening - closing
			if unmatchedBraces == 0 {
				// strip off badType footer
				lTrim = strings.Split(lTrim, "; __badType")[0]
			}
			s := ws + "//" + wsPrefix(l, ws)[1:] + lTrim + "\n"
			dst.WriteString(s)
			continue
		}

		isHdr := strings.Contains(l, ", __fpErr := __fp_") && strings.HasPrefix(lTrim, "if")
		if isHdr {
			ws = strings.Split(l, "i")[0]
			n := strings.Split(strings.Split(l, "__fp_")[1], ".")[0]
			t := strings.Split(strings.Split(l, ".(")[1], ")")[0]
			dst.WriteString(ws + "// gofail: var " + n + " " + t + "\n")
			if !strings.Contains(l, "; __badType") {
				// not single liner
				unmatchedBraces = 1
			}
			fps = append(fps, &Failpoint{name: n, varType: t})
			continue
		}

		if isLabel := strings.Contains(l, "\t/* gofail-label */"); isLabel {
			l = strings.Replace(l, "/* gofail-label */", "// gofail:", 1)
		}

		if _, werr := dst.WriteString(l); werr != nil {
			return fps, werr
		}
	}
	if err == io.EOF {
		err = nil
	}
	dst.Flush()
	return
}
221195
func TaskInspect(ctx types.Context, taskID int) *types.Task {
	return getTaskService(ctx).TaskInspect(taskID)
}
142474
func (t TaskService) FindTasks(ctx context.Context, filter platform.TaskFilter) ([]*platform.Task, int, error) {
	span, _ := tracing.StartSpanFromContext(ctx)
	defer span.Finish()

	u, err := newURL(t.Addr, tasksPath)
	if err != nil {
		return nil, 0, err
	}

	val := url.Values{}
	if filter.After != nil {
		val.Add("after", filter.After.String())
	}
	if filter.OrganizationID != nil {
		val.Add("orgID", filter.OrganizationID.String())
	}
	if filter.Organization != "" {
		val.Add("org", filter.Organization)
	}
	if filter.User != nil {
		val.Add("user", filter.User.String())
	}
	if filter.Limit != 0 {
		val.Add("limit", strconv.Itoa(filter.Limit))
	}

	u.RawQuery = val.Encode()

	req, err := http.NewRequest("GET", u.String(), nil)
	if err != nil {
		return nil, 0, err
	}
	SetToken(t.Token, req)
	tracing.InjectToHTTPRequest(span, req)

	hc := newClient(u.Scheme, t.InsecureSkipVerify)
	resp, err := hc.Do(req)
	if err != nil {
		return nil, 0, err
	}
	defer resp.Body.Close()

	if err := CheckError(resp); err != nil {
		return nil, 0, err
	}

	var tr tasksResponse
	if err := json.NewDecoder(resp.Body).Decode(&tr); err != nil {
		return nil, 0, err
	}

	tasks := make([]*platform.Task, len(tr.Tasks))
	for i := range tr.Tasks {
		tasks[i] = &tr.Tasks[i].Task
	}
	return tasks, len(tasks), nil
}
685140
func (p *PullRequest) GetComments() int {
	if p == nil || p.Comments == nil {
		return 0
	}
	return *p.Comments
}
474753
func (c oauthClient) CreateTaskComment(text string, taskID uint) (wl.TaskComment, error) {
	if taskID == 0 {
		return wl.TaskComment{}, errors.New("taskID must be > 0")
	}

	body := []byte(fmt.Sprintf(`{"text":"%s","task_id":%d}`, text, taskID))

	url := fmt.Sprintf("%s/task_comments", c.apiURL)

	req, err := c.newPostRequest(url, body)
	if err != nil {
		return wl.TaskComment{}, err
	}

	resp, err := c.do(req)
	if err != nil {
		return wl.TaskComment{}, err
	}

	if resp.StatusCode != http.StatusCreated {
		return wl.TaskComment{}, fmt.Errorf("Unexpected response code %d - expected %d", resp.StatusCode, http.StatusCreated)
	}

	taskComment := wl.TaskComment{}
	err = json.NewDecoder(resp.Body).Decode(&taskComment)
	if err != nil {
		return wl.TaskComment{}, err
	}
	return taskComment, nil
}
1068416
func (s *globalTaskService) Tasks() <-chan *types.Task {
	tasks := []*types.Task{}
	s.RLock()
	for _, v := range s.tasks {
		tasks = append(tasks, &v.Task)
	}
	s.RUnlock()

	c := make(chan *types.Task)
	go func() {
		for _, t := range tasks {
			c <- t
		}
		close(c)
	}()
	return c
}