~james/core

core/api/org_tangled/tempsearchsearchCode.go -rw-r--r-- 3.0 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 14 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.

package org_tangled

// schema: org.tangled.temp.search.searchCode

import (
	"context"

	"github.com/bluesky-social/indigo/lex/util"
)

const (
	TempSearchSearchCodeNSID = "org.tangled.temp.search.searchCode"
)

// TempSearchSearchCode_Chunk is a "chunk" in the org.tangled.temp.search.searchCode schema.
type TempSearchSearchCode_Chunk struct {
	// content: Source lines for this match chunk.
	Content string `json:"content" cborgen:"content"`
	// highlights: Byte-offset ranges within content that match the query.
	Highlights []*TempSearchSearchCode_Highlight `json:"highlights,omitempty" cborgen:"highlights,omitempty"`
	// lineStart: 1-based line number of the first line in content.
	LineStart int64 `json:"lineStart" cborgen:"lineStart"`
}

// TempSearchSearchCode_FileResult is a "fileResult" in the org.tangled.temp.search.searchCode schema.
type TempSearchSearchCode_FileResult struct {
	Branches []string `json:"branches,omitempty" cborgen:"branches,omitempty"`
	// chunks: set for content matches
	Chunks []*TempSearchSearchCode_Chunk `json:"chunks,omitempty" cborgen:"chunks,omitempty"`
	Commit string                        `json:"commit" cborgen:"commit"`
	// language: Detected programming language.
	Language *string `json:"language,omitempty" cborgen:"language,omitempty"`
	// path: File path relative to repository root.
	Path string `json:"path" cborgen:"path"`
	// ranges: set for a filename match
	Ranges []*TempSearchSearchCode_Highlight `json:"ranges,omitempty" cborgen:"ranges,omitempty"`
	Repo   *RepoDefs_RepoViewBasic           `json:"repo" cborgen:"repo"`
}

// TempSearchSearchCode_Highlight is a "highlight" in the org.tangled.temp.search.searchCode schema.
type TempSearchSearchCode_Highlight struct {
	// end: End byte offset (exclusive) within the chunk content string.
	End int64 `json:"end" cborgen:"end"`
	// start: Start byte offset within the chunk content string.
	Start int64 `json:"start" cborgen:"start"`
}

// TempSearchSearchCode_Output is the output of a org.tangled.temp.search.searchCode call.
type TempSearchSearchCode_Output struct {
	Cursor  *string                            `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
	Results []*TempSearchSearchCode_FileResult `json:"results" cborgen:"results"`
}

// TempSearchSearchCode calls the XRPC method "org.tangled.temp.search.searchCode".
//
// q: Search query string.
// repo: Restrict search to a specific repository, by its DID.
func TempSearchSearchCode(ctx context.Context, c util.LexClient, cursor string, limit int64, q string, repo string) (*TempSearchSearchCode_Output, error) {
	var out TempSearchSearchCode_Output

	params := map[string]interface{}{}
	if cursor != "" {
		params["cursor"] = cursor
	}
	if limit != 0 {
		params["limit"] = limit
	}
	params["q"] = q
	if repo != "" {
		params["repo"] = repo
	}
	if err := c.LexDo(ctx, util.Query, "", "org.tangled.temp.search.searchCode", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}