forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeintel.go
More file actions
202 lines (171 loc) · 5.41 KB
/
Copy pathcodeintel.go
File metadata and controls
202 lines (171 loc) · 5.41 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package types
import (
"fmt"
"time"
)
// CodeIntelAggregatedEvent represents the total events and unique users within
// the current week for a single event. The events are split again by language id
// code intel action (e.g. defintions, references, hovers), and the code intel
// data source (e.g. precise, search).
type CodeIntelAggregatedEvent struct {
Name string
LanguageID *string
Week time.Time
TotalWeek int32
UniquesWeek int32
}
// CodeIntelAggregatedEvent represents the total events and unique users within
// the current week for a single investigation event (user-CTAs on code intel badges).
// data source (e.g. precise, search).
type CodeIntelAggregatedInvestigationEvent struct {
Name string
Week time.Time
TotalWeek int32
UniquesWeek int32
}
// NewCodeIntelUsageStatistics is the type used within the updatecheck handler.
// This is sent from private instances to the cloud frontends, where it is further
// massaged and inserted into a BigQuery.
type NewCodeIntelUsageStatistics struct {
StartOfWeek time.Time
WAUs *int32
PreciseWAUs *int32
SearchBasedWAUs *int32
CrossRepositoryWAUs *int32
PreciseCrossRepositoryWAUs *int32
SearchBasedCrossRepositoryWAUs *int32
EventSummaries []CodeIntelEventSummary
NumRepositories *int32
NumRepositoriesWithUploadRecords *int32
NumRepositoriesWithoutUploadRecords *int32 // Deprecated, no longer sent
NumRepositoriesWithFreshUploadRecords *int32
NumRepositoriesWithIndexRecords *int32
NumRepositoriesWithFreshIndexRecords *int32
NumRepositoriesWithAutoIndexConfigurationRecords *int32
CountsByLanguage map[string]CodeIntelRepositoryCountsByLanguage
SettingsPageViewCount *int32
UsersWithRefPanelRedesignEnabled *int32
LanguageRequests []LanguageRequest
InvestigationEvents []CodeIntelInvestigationEvent
}
type CodeIntelRepositoryCountsByLanguage struct {
NumRepositoriesWithUploadRecords *int32
NumRepositoriesWithFreshUploadRecords *int32
NumRepositoriesWithIndexRecords *int32
NumRepositoriesWithFreshIndexRecords *int32
}
type CodeIntelEventSummary struct {
Action CodeIntelAction
Source CodeIntelSource
LanguageID string
CrossRepository bool
WAUs int32
TotalActions int32
}
type CodeIntelAction int
const (
UnknownAction CodeIntelAction = iota
HoverAction
DefinitionsAction
ReferencesAction
)
type CodeIntelSource int
const (
UnknownSource CodeIntelSource = iota
PreciseSource
SearchSource
)
type LanguageRequest struct {
LanguageID string
NumRequests int32
}
type CodeIntelInvestigationEvent struct {
Type CodeIntelInvestigationType
WAUs int32
Total int32
}
type CodeIntelInvestigationType int
const (
CodeIntelUnknownInvestigationType CodeIntelInvestigationType = iota
CodeIntelIndexerSetupInvestigationType
CodeIntelUploadErrorInvestigationType
CodeIntelIndexErrorInvestigationType
)
// OldCodeIntelUsageStatistics is an old version the code intelligence
// usage statics we can receive from a pre-3.22 Sourcegraph instance.
type OldCodeIntelUsageStatistics struct {
Weekly []*OldCodeIntelUsagePeriod
}
type OldCodeIntelUsagePeriod struct {
StartTime time.Time
Hover *OldCodeIntelEventCategoryStatistics
Definitions *OldCodeIntelEventCategoryStatistics
References *OldCodeIntelEventCategoryStatistics
}
type OldCodeIntelEventCategoryStatistics struct {
LSIF *OldCodeIntelEventStatistics
Search *OldCodeIntelEventStatistics
}
type OldCodeIntelEventStatistics struct {
UsersCount int32
EventsCount *int32
}
type RepoCommitPath struct {
Repo string `json:"repo"`
Commit string `json:"commit"`
Path string `json:"path"`
}
func (r RepoCommitPath) String() string {
return fmt.Sprintf("%s %s %s", r.Repo, r.Commit, r.Path)
}
type LocalCodeIntelPayload struct {
Symbols []Symbol `json:"symbols"`
}
type RepoCommitPathRange struct {
RepoCommitPath
Range
}
type RepoCommitPathMaybeRange struct {
RepoCommitPath
*Range
}
type RepoCommitPathPoint struct {
RepoCommitPath
Point
}
type Point struct {
Row int `json:"row"`
Column int `json:"column"`
}
type Symbol struct {
Name string `json:"name"`
Hover string `json:"hover,omitempty"`
Def Range `json:"def,omitempty"`
Refs []Range `json:"refs,omitempty"`
}
func (s Symbol) String() string {
return fmt.Sprintf("Symbol{Hover: %q, Def: %s, Refs: %+v", s.Hover, s.Def, s.Refs)
}
type Range struct {
Row int `json:"row"`
Column int `json:"column"`
Length int `json:"length"`
}
func (r Range) String() string {
return fmt.Sprintf("%d:%d:%d", r.Row, r.Column, r.Length)
}
type SymbolInfo struct {
Definition RepoCommitPathMaybeRange `json:"definition"`
Hover *string `json:"hover,omitempty"`
}
func (s SymbolInfo) String() string {
hover := "<nil>"
if s.Hover != nil {
hover = *s.Hover
}
rnge := "<nil>"
if s.Definition.Range != nil {
rnge = s.Definition.Range.String()
}
return fmt.Sprintf("SymbolInfo{Definition: %s %s, Hover: %q}", s.Definition.RepoCommitPath, rnge, hover)
}