ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / copilot / src / extension / prompts / node / panel / referencesAtPosition.tsx 169 строк · изменён 14 нояб., 04:52
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
import { PromptElement , PromptElementProps , PromptPiece , PromptReference , PromptSizing } from '@vscode/prompt-tsx' ;
import type * as vscode from 'vscode' ;
import { TextDocumentSnapshot } from '../../../../platform/editing/common/textDocumentSnapshot' ;
import { isScenarioAutomation } from '../../../../platform/env/common/envService' ;
import { IVSCodeExtensionContext } from '../../../../platform/extContext/common/extensionContext' ;
position vscode
timeoutMs
languageId
uri
code
excerptRange vscode
props
@ ignoreService
@ extensionContext
@ languageFeaturesService
@ workspaceService
@ logService
@ parserService
@ telemetryService
props
state sizing
timeout isScenarioAutomation
definitions usages timeout
definitions
definitions
usages
usages
definitions usages
title excerts
excerts
title excerts excerpt
lineCommentStart excerpt
filePath
code
timeoutMs
position
refs position
refs
refs
e
foundRefs timeoutMs findReference
nonIgnoredDefs
nonIgnoredRefs
ref foundRefs
ref
docContainingRef ref
treeSitterAST docContainingRef
treeSitterAST
range ref docContainingRef
calls treeSitterAST range
functions treeSitterAST
calls
nonIgnoredRefs
languageId docContainingRef
uri docContainingRef
code calls
excerptRange docContainingRef calls
functions f f range
nodeToDocument
docContainingRef
language
wholeRange ref
selection ref ref
fileIndentInfo
excerptRange nodeToDocument
nonIgnoredDefs
languageId docContainingRef
uri docContainingRef
code docContainingRef excerptRange
excerptRange
satisfies
nonIgnoredDefs nonIgnoredRefs
import
{ IIgnoreService }
from
'../../../../platform/ignore/common/ignoreService'
;
import
{ ILanguageFeaturesService }
from
'../../../../platform/languages/common/languageFeaturesService'
;
import
{ ILogService }
from
'../../../../platform/log/common/logService'
;
import
{ TreeSitterOffsetRange }
from
'../../../../platform/parser/node/nodes'
;
import
{ IParserService , treeSitterOffsetRangeToVSCodeRange, vscodeToTreeSitterOffsetRange }
from
'../../../../platform/parser/node/parserService'
;
import
{ ITelemetryService }
from
'../../../../platform/telemetry/common/telemetry'
;
import
{ IWorkspaceService }
from
'../../../../platform/workspace/common/workspaceService'
;
import
{ getLanguage }
from
'../../../../util/common/languages'
;
import
{ ExtensionMode , Location , Selection , Uri }
from
'../../../../vscodeTypes'
;
import
{ asyncComputeWithTimeBudget }
from
'../../../context/node/resolvers/selectionContextHelpers'
;
import
{ determineNodeToDocument }
from
'../../../prompt/node/definitionAroundCursor'
;
import
{ CodeBlock }
from
'./safeElements'
;
type
Props
=
PromptElementProps
<
{
document
:
TextDocumentSnapshot
;
:
.
Position
;
?
:
number
;
}
>
;
type
CodeExcerpt
=
{
:
string
;
:
Uri
;
:
string
;
:
.
Range
;
}
;
export
class
ReferencesAtPosition
extends
PromptElement< Props>
{
private
static
DEFAULT_TIMEOUT_MS
=
200
;
constructor
(
:
Props
,
IIgnoreService
private
readonly
:
IIgnoreService
,
IVSCodeExtensionContext
private
readonly
:
IVSCodeExtensionContext
,
ILanguageFeaturesService
private
readonly
:
ILanguageFeaturesService
,
IWorkspaceService
private
readonly
:
IWorkspaceService
,
ILogService
private
readonly
:
ILogService
,
IParserService
private
readonly
:
IParserService
,
ITelemetryService
private
readonly
:
ITelemetryService
,
)
{
super
(
)
;
}
async
render
(
:
void
,
:
PromptSizing
)
{
if
(
await
this
.
ignoreService
.
isCopilotIgnored
(
this
.
props
.
document
.
uri
)
)
{
return
< ignoredFiles value = { [ this . props . document . uri ] } />
;
}
const
=
this
.
extensionContext
.
extensionMode
===
ExtensionMode
.
Test
&&
!
?
0
:
(
this
.
props
.
timeoutMs
===
undefined
?
ReferencesAtPosition
.
DEFAULT_TIMEOUT_MS
:
this
.
props
.
timeoutMs
)
;
const
[
,
]
=
await
this
.
findReferences
(
)
;
this
.
logService
.
debug
(
` Found ${ definitions. length} implementation(s)/definition(s), ${ usages. length} usages `
)
;
if
(
.
length
>
0
)
{
this
.
logService
.
debug
(
` Implementation(s)/definition(s) found: `
+
JSON
.
stringify
(
,
null
,
'\t'
)
)
;
}
if
(
.
length
>
0
)
{
this
.
logService
.
debug
(
` Usages found: `
+
JSON
.
stringify
(
,
null
,
'\t'
)
)
;
}
return
(
< >
{
this
.
renderCodeExcerpts
(
` Relevant definition ${ definitions. length > 1 ? 's' : '' } : `
,
)
}
{
this
.
renderCodeExcerpts
(
` Other usages: `
,
)
}
</ >
)
;
}
private
renderCodeExcerpts
(
:
string
,
:
CodeExcerpt
[
]
)
:
PromptPiece
<
any
,
any
>
|
undefined
{
if
(
.
length
>
0
)
{
return
(
< >
{
}
< br />
<br />
{
.
map
(
=>
{
const
=
getLanguage
(
.
languageId
)
.
lineComment
.
start
;
const
=
` ${ lineCommentStart} FILEPATH: ${ excerpt. uri. path} `
;
const
=
` ${ filePath} \n ${ excerpt. code} `
;
return
(
< CodeBlock uri = { excerpt. uri } languageId = { excerpt. languageId } code = { code} references = { [ new PromptReference ( new Location ( excerpt. uri , excerpt. excerptRange ) ) ] } />
)
;
}
)
}
< br />
<br />
</ >
)
;
}
return
undefined
;
}
private
async
findReferences
(
:
number
)
:
Promise
<
[
CodeExcerpt
[
]
,
CodeExcerpt
[
]
]
>
{
const
{
document
,
}
=
this
.
props
;
const
findReference
=
async
(
)
=>
{
try
{
const
=
await
this
.
languageFeaturesService
.
getReferences
(
document
.
uri
,
)
;
this
.
logService
.
debug
(
` Found ${ refs. length} references: `
+
JSON
.
stringify
(
,
null
,
'\t'
)
)
;
return
;
}
catch
(
)
{
return
[
]
;
}
}
;
const
=
await
asyncComputeWithTimeBudget
(
this
.
logService
,
this
.
telemetryService
,
document
,
*
3
,
,
[
]
)
;
const
=
[
]
;
const
=
[
]
;
for
(
const
of
)
{
if
(
await
this
.
ignoreService
.
isCopilotIgnored
(
.
uri
)
)
{
continue
;
}
const
=
await
this
.
workspaceService
.
openTextDocumentAndSnapshot
(
.
uri
)
;
const
=
this
.
parserService
.
getTreeSitterAST
(
)
;
if
(
!
)
{
continue
;
}
const
=
vscodeToTreeSitterOffsetRange
(
.
range
,
)
;
const
=
await
.
getCallExpressions
(
)
;
const
=
await
.
getFunctionDefinitions
(
)
;
if
(
.
length
>
0
)
{
.
push
(
{
:
.
languageId
,
:
.
uri
,
:
[
0
]
.
text
,
:
treeSitterOffsetRangeToVSCodeRange
(
,
[
0
]
)
,
}
as
CodeExcerpt
)
;
}
else
if
(
.
some
(
=>
TreeSitterOffsetRange
.
doIntersect
(
,
)
)
)
{
const
=
await
determineNodeToDocument
(
this
.
parserService
,
this
.
telemetryService
,
{
document
:
,
:
getLanguage
(
document
.
languageId
)
,
:
.
range
,
:
new
Selection
(
.
range
.
start
,
.
range
.
end
)
,
:
undefined
,
}
)
;
const
=
.
range
;
.
push
(
{
:
.
languageId
,
:
.
uri
,
:
.
getText
(
)
,
,
}
CodeExcerpt
)
;
}
}
return
[
,
]
;
}
}