/------------------------- Link Build methods---------------------------///
355318
protected String getUrl() {
        String shortUrl = null;
        if (branchReferral_ != null) {
            ServerRequestCreateUrl req = new ServerRequestCreateUrl(context_, alias_, type_, duration_, tags_,
                    channel_, feature_, stage_, campaign_,
                    BranchUtil.formatLinkParam(params_), null, false, defaultToLongUrl_);
            shortUrl = branchReferral_.generateShortLinkInternal(req);
        }
        return shortUrl;
    }
724444
func (b *base) link(from string) error {
	debug("symlinking %s to %s", from, b.Path())
	return os.Symlink(from, b.Path())
}
600961
func makeLocalLink(sn *session, isSender bool, setting ...LinkOption) (linkSettings, error) {
	l := linkSettings{
		isSender: isSender,
		capacity: 1,
		prefetch: false,
		session:  sn,
	}
	for _, set := range setting {
		set(&l)
	}
	if l.linkName == "" {
		l.linkName = l.session.connection.container.nextLinkName()
	}
	if l.IsSender() {
		l.pLink = l.session.pSession.Sender(l.linkName)
	} else {
		l.pLink = l.session.pSession.Receiver(l.linkName)
	}
	if l.pLink.IsNil() {
		return l, fmt.Errorf("cannot create link %s", l.pLink)
	}
	l.pLink.Source().SetAddress(l.source)

	if len(l.filter) > 0 {
		if err := l.pLink.Source().Filter().Marshal(l.filter); err != nil {
			panic(err) // Shouldn't happen
		}
	}
	l.pLink.Source().SetDurability(l.sourceSettings.Durability)
	l.pLink.Source().SetExpiryPolicy(l.sourceSettings.Expiry)
	l.pLink.Source().SetTimeout(l.sourceSettings.Timeout)
	l.pLink.Source().SetDynamic(l.sourceSettings.Dynamic)

	l.pLink.Target().SetAddress(l.target)
	l.pLink.Target().SetDurability(l.targetSettings.Durability)
	l.pLink.Target().SetExpiryPolicy(l.targetSettings.Expiry)
	l.pLink.Target().SetTimeout(l.targetSettings.Timeout)
	l.pLink.Target().SetDynamic(l.targetSettings.Dynamic)

	l.pLink.SetSndSettleMode(proton.SndSettleMode(l.sndSettle))
	l.pLink.SetRcvSettleMode(proton.RcvSettleMode(l.rcvSettle))
	l.pLink.Open()
	return l, nil
}
394974
func MakeBuildBugLink(bt *config.BugTemplate, data interface{}) (string, error) {
	summary, err := summary(bt, data)
	if err != nil {
		return "", errors.Annotate(err, "Unable to make summary for build bug link.").Err()
	}
	description, err := description(bt, data)
	if err != nil {
		return "", errors.Annotate(err, "Unable to make description for build bug link.").Err()
	}

	query := url.Values{
		"summary":     {summary},
		"description": {description},
	}

	if len(bt.Components) > 0 {
		query.Add("components", strings.Join(bt.Components, ","))
	}

	link := url.URL{
		Scheme:   "https",
		Host:     "bugs.chromium.org",
		Path:     fmt.Sprintf("/p/%s/issues/entry", bt.MonorailProject),
		RawQuery: query.Encode(),
	}

	return link.String(), nil
}
633098
func BuilderIDLink(b, project string) string {
	parts := strings.Split(b, "/")
	if len(parts) != 3 {
		return InvalidBuilderIDURL
	}

	switch source := parts[0]; source {
	case "buildbot":
		return fmt.Sprintf("/buildbot/%s/%s", parts[1], parts[2])
	case "buildbucket":
		return fmt.Sprintf("/p/%s/builders/%s/%s", project, parts[1], parts[2])
	default:
		return InvalidBuilderIDURL
	}
}
11731
func (o *LoginUserURL) Build() (*url.URL, error) {
	var _result url.URL

	var _path = "/users/login"

	_basePath := o._basePath
	if _basePath == "" {
		_basePath = "/v2"
	}
	_result.Path = golangswaggerpaths.Join(_basePath, _path)

	qs := make(url.Values)

	var password string
	if o.Password != nil {
		password = *o.Password
	}
	if password != "" {
		qs.Set("password", password)
	}

	var username string
	if o.Username != nil {
		username = *o.Username
	}
	if username != "" {
		qs.Set("username", username)
	}

	_result.RawQuery = qs.Encode()

	return &_result, nil
}
810246
func (c ConstantInt) Link(scope Scope, t TypeSpec) (ConstantValue, error) {
	rt := RootTypeSpec(t)
	switch spec := rt.(type) {
	case *I8Spec, *I16Spec, *I32Spec, *I64Spec:
		// TODO bounds checks?
		return c, nil
	case *DoubleSpec:
		return ConstantDouble(float64(c)).Link(scope, t)
	case *BoolSpec:
		switch v := int64(c); v {
		case 0, 1:
			return ConstantBool(v == 1).Link(scope, t)
		default:
			return nil, constantValueCastError{
				Value:  c,
				Type:   t,
				Reason: errors.New("the value must be 0 or 1"),
			}
		}
	case *EnumSpec:
		for _, item := range spec.Items {
			if item.Value == int32(c) {
				return EnumItemReference{Enum: spec, Item: &item}, nil
			}
		}

		return nil, constantValueCastError{
			Value: c,
			Type:  t,
			Reason: fmt.Errorf(
				"%v is not a valid value for enum %q", int32(c), spec.ThriftName()),
		}
	}

	return nil, constantValueCastError{Value: c, Type: t}
	// TODO: AST for constants will need to track positions for us to
	// include them in the error messages.
}
1168076
func (s *SetSpec) Link(scope Scope) (TypeSpec, error) {
	if s.linked() {
		return s, nil
	}

	var err error
	s.ValueSpec, err = s.ValueSpec.Link(scope)
	return s, err
}
399660
func (f *Food) Link(pkg *Package) error {
	barrelDir := filepath.Join(home.Home(home.HomePath).Barrel(), f.Name, f.Version)
	for _, r := range pkg.Resources {
		// TODO: run this in parallel
		destPath := filepath.Join(home.HomePrefix, r.InstallPath)
		if err := os.MkdirAll(filepath.Dir(destPath), 0755); err != nil && !os.IsExist(err) {
			return err
		}
		if r.Executable {
			if err := os.Chmod(filepath.Join(barrelDir, r.Path), 0755); err != nil {
				return err
			}
		}
		if err := os.Symlink(filepath.Join(barrelDir, r.Path), destPath); err != nil {
			return err
		}
	}
	return nil
}
11258
func (c ConstantBool) Link(scope Scope, t TypeSpec) (ConstantValue, error) {
	if _, ok := RootTypeSpec(t).(*BoolSpec); !ok {
		return nil, constantValueCastError{Value: c, Type: t}
	}
	return c, nil
}
221767
func recipeLink(r *buildbucketpb.BuildInfra_Recipe) (result template.HTML) {
	if r == nil {
		return
	}
	// We don't know location of recipes within the repo and getting that
	// information is not trivial, so use code search, which is precise enough.
	csHost := "cs.chromium.org"
	if strings.HasPrefix(r.CipdPackage, "infra_internal") {
		csHost = "cs.corp.google.com"
	}
	recipeURL := fmt.Sprintf("https://%s/search/?q=file:recipes/%s.py", csHost, r.Name)
	return ui.NewLink(r.Name, recipeURL, fmt.Sprintf("recipe %s", r.Name)).HTML()
}
1273719
func (o *GetMapNameURL) Build() (*url.URL, error) {
	var _result url.URL

	var _path = "/map/{name}"

	name := o.Name
	if name != "" {
		_path = strings.Replace(_path, "{name}", name, -1)
	} else {
		return nil, errors.New("name is required on GetMapNameURL")
	}

	_basePath := o._basePath
	if _basePath == "" {
		_basePath = "/v1"
	}
	_result.Path = golangswaggerpaths.Join(_basePath, _path)

	return &_result, nil
}
482814
func (m *MapSpec) Link(scope Scope) (TypeSpec, error) {
	if m.linked() {
		return m, nil
	}

	var err error
	m.KeySpec, err = m.KeySpec.Link(scope)
	if err != nil {
		return m, err
	}

	m.ValueSpec, err = m.ValueSpec.Link(scope)
	if err != nil {
		return m, err
	}

	return m, nil
}
1285512
func (s *UpdateByQueryService) buildURL() (string, url.Values, error) {
	// Build URL
	var err error
	var path string
	if len(s.typ) > 0 {
		path, err = uritemplates.Expand("/{index}/{type}/_update_by_query", map[string]string{
			"index": strings.Join(s.index, ","),
			"type":  strings.Join(s.typ, ","),
		})
	} else {
		path, err = uritemplates.Expand("/{index}/_update_by_query", map[string]string{
			"index": strings.Join(s.index, ","),
		})
	}
	if err != nil {
		return "", url.Values{}, err
	}

	// Add query string parameters
	params := url.Values{}
	if s.pretty {
		params.Set("pretty", "true")
	}
	if len(s.xSource) > 0 {
		params.Set("_source", strings.Join(s.xSource, ","))
	}
	if len(s.xSourceExclude) > 0 {
		params.Set("_source_excludes", strings.Join(s.xSourceExclude, ","))
	}
	if len(s.xSourceInclude) > 0 {
		params.Set("_source_includes", strings.Join(s.xSourceInclude, ","))
	}
	if s.allowNoIndices != nil {
		params.Set("allow_no_indices", fmt.Sprintf("%v", *s.allowNoIndices))
	}
	if s.analyzer != "" {
		params.Set("analyzer", s.analyzer)
	}
	if s.analyzeWildcard != nil {
		params.Set("analyze_wildcard", fmt.Sprintf("%v", *s.analyzeWildcard))
	}
	if s.conflicts != "" {
		params.Set("conflicts", s.conflicts)
	}
	if s.defaultOperator != "" {
		params.Set("default_operator", s.defaultOperator)
	}
	if s.df != "" {
		params.Set("df", s.df)
	}
	if s.expandWildcards != "" {
		params.Set("expand_wildcards", s.expandWildcards)
	}
	if s.explain != nil {
		params.Set("explain", fmt.Sprintf("%v", *s.explain))
	}
	if len(s.storedFields) > 0 {
		params.Set("stored_fields", strings.Join(s.storedFields, ","))
	}
	if len(s.docvalueFields) > 0 {
		params.Set("docvalue_fields", strings.Join(s.docvalueFields, ","))
	}
	if len(s.fielddataFields) > 0 {
		params.Set("fielddata_fields", strings.Join(s.fielddataFields, ","))
	}
	if s.from != nil {
		params.Set("from", fmt.Sprintf("%d", *s.from))
	}
	if s.ignoreUnavailable != nil {
		params.Set("ignore_unavailable", fmt.Sprintf("%v", *s.ignoreUnavailable))
	}
	if s.lenient != nil {
		params.Set("lenient", fmt.Sprintf("%v", *s.lenient))
	}
	if s.lowercaseExpandedTerms != nil {
		params.Set("lowercase_expanded_terms", fmt.Sprintf("%v", *s.lowercaseExpandedTerms))
	}
	if s.pipeline != "" {
		params.Set("pipeline", s.pipeline)
	}
	if s.preference != "" {
		params.Set("preference", s.preference)
	}
	if s.q != "" {
		params.Set("q", s.q)
	}
	if s.refresh != "" {
		params.Set("refresh", s.refresh)
	}
	if s.requestCache != nil {
		params.Set("request_cache", fmt.Sprintf("%v", *s.requestCache))
	}
	if len(s.routing) > 0 {
		params.Set("routing", strings.Join(s.routing, ","))
	}
	if s.scroll != "" {
		params.Set("scroll", s.scroll)
	}
	if s.scrollSize != nil {
		params.Set("scroll_size", fmt.Sprintf("%d", *s.scrollSize))
	}
	if s.searchTimeout != "" {
		params.Set("search_timeout", s.searchTimeout)
	}
	if s.searchType != "" {
		params.Set("search_type", s.searchType)
	}
	if s.size != nil {
		params.Set("size", fmt.Sprintf("%d", *s.size))
	}
	if s.slices != nil {
		params.Set("slices", fmt.Sprintf("%v", s.slices))
	}
	if len(s.sort) > 0 {
		params.Set("sort", strings.Join(s.sort, ","))
	}
	if len(s.stats) > 0 {
		params.Set("stats", strings.Join(s.stats, ","))
	}
	if s.suggestField != "" {
		params.Set("suggest_field", s.suggestField)
	}
	if s.suggestMode != "" {
		params.Set("suggest_mode", s.suggestMode)
	}
	if s.suggestSize != nil {
		params.Set("suggest_size", fmt.Sprintf("%v", *s.suggestSize))
	}
	if s.suggestText != "" {
		params.Set("suggest_text", s.suggestText)
	}
	if s.terminateAfter != nil {
		params.Set("terminate_after", fmt.Sprintf("%v", *s.terminateAfter))
	}
	if s.timeout != "" {
		params.Set("timeout", s.timeout)
	}
	if s.trackScores != nil {
		params.Set("track_scores", fmt.Sprintf("%v", *s.trackScores))
	}
	if s.version != nil {
		params.Set("version", fmt.Sprintf("%v", *s.version))
	}
	if s.versionType != nil {
		params.Set("version_type", fmt.Sprintf("%v", *s.versionType))
	}
	if s.waitForActiveShards != "" {
		params.Set("wait_for_active_shards", s.waitForActiveShards)
	}
	if s.waitForCompletion != nil {
		params.Set("wait_for_completion", fmt.Sprintf("%v", *s.waitForCompletion))
	}
	if s.requestsPerSecond != nil {
		params.Set("requests_per_second", fmt.Sprintf("%v", *s.requestsPerSecond))
	}
	return path, params, nil
}
322446
func (b *Builder) Build() (abbrev, aranges, frame, info, line, pubnames, ranges, str, loc []byte, err error) {
	b.TagClose()

	if len(b.tagStack) > 0 {
		err = fmt.Errorf("unbalanced TagOpen/TagClose %d", len(b.tagStack))
		return
	}

	abbrev = b.makeAbbrevTable()
	info = b.info.Bytes()
	binary.LittleEndian.PutUint32(info, uint32(len(info)-4))
	loc = b.loc.Bytes()

	return
}
845605
func (w *Writer) Link(oldname, newname string) error {
	if err := w.finishInode(); err != nil {
		return err
	}
	newdir, existing, newchildname, err := w.lookup(newname, false)
	if err != nil {
		return err
	}
	if existing != nil && (existing.IsDir() || existing.LinkCount < 2) {
		return fmt.Errorf("%s: cannot orphan existing file or directory", newname)
	}

	_, oldfile, _, err := w.lookup(oldname, true)
	if err != nil {
		return err
	}
	switch oldfile.Mode & format.TypeMask {
	case format.S_IFDIR, format.S_IFLNK:
		return fmt.Errorf("%s: link target cannot be a directory or symlink: %s", newname, oldname)
	}

	if existing != oldfile && oldfile.LinkCount >= format.MaxLinks {
		return fmt.Errorf("%s: link target would exceed maximum link count: %s", newname, oldname)
	}

	if existing != nil {
		existing.LinkCount--
	}
	oldfile.LinkCount++
	newdir.Children[newchildname] = oldfile
	return nil
}
1254849
func (t *TypedefSpec) Link(scope Scope) (TypeSpec, error) {
	if t.linked() {
		return t, nil
	}

	var err error
	t.Target, err = t.Target.Link(scope)
	if err == nil {
		t.root = RootTypeSpec(t.Target)
	}
	return t, err
}