ttsc 0.31.4 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/cmd/ttsc/compiler_argument_cwd_test.go +38 -38
  2. package/cmd/ttscserver/main.go +2 -12
  3. package/cmd/ttscserver/resolve_launch_uses_native_flag_authority_test.go +7 -7
  4. package/driver/lsp.go +4 -43
  5. package/driver/rewrite.go +1 -1
  6. package/internal/e2etrace/completion_hints.go +3 -3
  7. package/internal/e2etrace/completion_hints_test.go +26 -12
  8. package/internal/graph/build.go +5 -6
  9. package/internal/graph/graph.go +3 -3
  10. package/internal/graph/line_model.go +2 -35
  11. package/internal/lspserver/lsp_clean_didopen_refreshes_compiler_state_test.go +13 -36
  12. package/internal/lspserver/lsp_hints_refresh_ignores_a_superseded_generation_test.go +9 -3
  13. package/internal/lspserver/lsp_plugin.go +19 -0
  14. package/internal/lspserver/lsp_proxy.go +9 -129
  15. package/internal/lspserver/lsp_server.go +0 -8
  16. package/internal/lspserver/lsp_watched_file_changes_reach_compiler_caches_test.go +6 -36
  17. package/internal/sourceprocess/windows_target_owns_suspended_admission_test.go +5 -5
  18. package/lib/compiler/internal/build/BuildExecution.js +11 -3
  19. package/lib/compiler/internal/build/BuildExecution.js.map +1 -1
  20. package/lib/compiler/internal/build/TsgoArguments.js.map +1 -1
  21. package/lib/compiler/internal/project/CompilerProjectSelection.d.ts +9 -8
  22. package/lib/compiler/internal/project/CompilerProjectSelection.js +11 -9
  23. package/lib/compiler/internal/project/CompilerProjectSelection.js.map +1 -1
  24. package/lib/compiler/internal/project/resolveOwningProjectConfig.d.ts +20 -8
  25. package/lib/compiler/internal/project/resolveOwningProjectConfig.js +21 -12
  26. package/lib/compiler/internal/project/resolveOwningProjectConfig.js.map +1 -1
  27. package/lib/compiler/internal/runSingleFileEmit.d.ts +5 -4
  28. package/lib/compiler/internal/runSingleFileEmit.js +5 -4
  29. package/lib/compiler/internal/runSingleFileEmit.js.map +1 -1
  30. package/lib/flags/ParseOptions.d.ts +2 -2
  31. package/lib/internal/E2ETrace.d.ts +1 -0
  32. package/lib/internal/E2ETrace.js.map +1 -1
  33. package/lib/internal/OwnedNativeProcess.d.ts +2 -2
  34. package/lib/internal/OwnedNativeProcess.js +2 -2
  35. package/lib/internal/SourceNativeRetirement.d.ts +8 -7
  36. package/lib/internal/SourceNativeRetirement.js +19 -10
  37. package/lib/internal/SourceNativeRetirement.js.map +1 -1
  38. package/lib/internal/TtsxNodeOptions.d.ts +79 -0
  39. package/lib/internal/TtsxNodeOptions.js +121 -0
  40. package/lib/internal/TtsxNodeOptions.js.map +1 -0
  41. package/lib/internal/javascriptRuntimeCapabilities.js +4 -1
  42. package/lib/internal/javascriptRuntimeCapabilities.js.map +1 -1
  43. package/lib/internal/parseWindowsDirectoryCaseSensitivity.d.ts +5 -5
  44. package/lib/internal/parseWindowsDirectoryCaseSensitivity.js +5 -5
  45. package/lib/internal/pathIdentity/createCaseSensitivityObservations.d.ts +35 -0
  46. package/lib/internal/pathIdentity/createCaseSensitivityObservations.js +209 -0
  47. package/lib/internal/pathIdentity/createCaseSensitivityObservations.js.map +1 -0
  48. package/lib/internal/pathIdentity/createFilesystemPathIdentityContext.js +2 -143
  49. package/lib/internal/pathIdentity/createFilesystemPathIdentityContext.js.map +1 -1
  50. package/lib/internal/probeLocalProcess.d.ts +5 -1
  51. package/lib/internal/probeLocalProcess.js +9 -7
  52. package/lib/internal/probeLocalProcess.js.map +1 -1
  53. package/lib/internal/projectInputPathIdentity.d.ts +1 -0
  54. package/lib/internal/projectInputPathIdentity.js +1 -0
  55. package/lib/internal/projectInputPathIdentity.js.map +1 -1
  56. package/lib/launcher/internal/parseTtsxCLI.d.ts +5 -4
  57. package/lib/launcher/internal/parseTtsxCLI.js +5 -4
  58. package/lib/launcher/internal/parseTtsxCLI.js.map +1 -1
  59. package/lib/launcher/internal/prepareExecution.js.map +1 -1
  60. package/lib/launcher/internal/resolveSingleFileOutput.d.ts +8 -9
  61. package/lib/launcher/internal/resolveSingleFileOutput.js +8 -9
  62. package/lib/launcher/internal/resolveSingleFileOutput.js.map +1 -1
  63. package/lib/launcher/internal/runTtsc.js +5 -5
  64. package/lib/launcher/internal/runTtsx.js +5 -2
  65. package/lib/launcher/internal/runTtsx.js.map +1 -1
  66. package/lib/launcher/internal/runtime/ProcessOwnedDirectory.d.ts +2 -0
  67. package/lib/launcher/internal/runtime/ProcessOwnedDirectory.js +2 -1
  68. package/lib/launcher/internal/runtime/ProcessOwnedDirectory.js.map +1 -1
  69. package/lib/launcher/internal/runtime/RuntimeEntrySources.d.ts +40 -0
  70. package/lib/launcher/internal/runtime/RuntimeEntrySources.js +57 -0
  71. package/lib/launcher/internal/runtime/RuntimeEntrySources.js.map +1 -0
  72. package/lib/launcher/internal/runtime/RuntimeProjectOwnership.d.ts +5 -4
  73. package/lib/launcher/internal/runtime/RuntimeProjectOwnership.js +8 -6
  74. package/lib/launcher/internal/runtime/RuntimeProjectOwnership.js.map +1 -1
  75. package/lib/launcher/internal/runtime/commonJsExportNames.d.ts +2 -1
  76. package/lib/launcher/internal/runtime/commonJsExportNames.js +2 -1
  77. package/lib/launcher/internal/runtime/commonJsExportNames.js.map +1 -1
  78. package/lib/launcher/internal/runtime/installRuntimeHooks.js +35 -9
  79. package/lib/launcher/internal/runtime/installRuntimeHooks.js.map +1 -1
  80. package/lib/launcher/internal/runtime/isLocalProcessGone.d.ts +1 -1
  81. package/lib/launcher/internal/runtime/isLocalProcessGone.js +4 -4
  82. package/lib/launcher/internal/runtime/isLocalProcessGone.js.map +1 -1
  83. package/lib/launcher/internal/runtime/resolveRuntimeCleanTargets.js +3 -1
  84. package/lib/launcher/internal/runtime/resolveRuntimeCleanTargets.js.map +1 -1
  85. package/lib/launcher/internal/watch/FseventsStreams.d.ts +2 -0
  86. package/lib/launcher/internal/watch/FseventsStreams.js +19 -0
  87. package/lib/launcher/internal/watch/FseventsStreams.js.map +1 -1
  88. package/lib/launcher/internal/watch/WatchTopology.d.ts +74 -12
  89. package/lib/launcher/internal/watch/WatchTopology.js +301 -92
  90. package/lib/launcher/internal/watch/WatchTopology.js.map +1 -1
  91. package/lib/launcher/internal/watch/projectInputReloadEventShouldNotify.d.ts +4 -1
  92. package/lib/launcher/internal/watch/projectInputReloadEventShouldNotify.js +3 -2
  93. package/lib/launcher/internal/watch/projectInputReloadEventShouldNotify.js.map +1 -1
  94. package/lib/plugin/internal/load/loadProjectPlugins.js +17 -9
  95. package/lib/plugin/internal/load/loadProjectPlugins.js.map +1 -1
  96. package/lib/plugin/internal/load/resolveNativeSource.js +2 -3
  97. package/lib/plugin/internal/load/resolveNativeSource.js.map +1 -1
  98. package/lib/plugin/internal/source/pluginModuleReplaceDirectories.d.ts +4 -1
  99. package/lib/plugin/internal/source/pluginModuleReplaceDirectories.js +9 -2
  100. package/lib/plugin/internal/source/pluginModuleReplaceDirectories.js.map +1 -1
  101. package/lib/structures/internal/TtscCommonOptions.d.ts +2 -2
  102. package/package.json +9 -9
  103. package/src/compiler/internal/build/BuildExecution.ts +15 -6
  104. package/src/compiler/internal/build/TsgoArguments.ts +4 -1
  105. package/src/compiler/internal/project/CompilerProjectSelection.ts +14 -14
  106. package/src/compiler/internal/project/resolveOwningProjectConfig.ts +29 -14
  107. package/src/compiler/internal/runSingleFileEmit.ts +11 -7
  108. package/src/flags/ParseOptions.ts +2 -2
  109. package/src/internal/E2ETrace.ts +5 -1
  110. package/src/internal/OwnedNativeProcess.ts +2 -2
  111. package/src/internal/SourceNativeRetirement.ts +42 -19
  112. package/src/internal/TtsxNodeOptions.ts +124 -0
  113. package/src/internal/javascriptRuntimeCapabilities.ts +6 -1
  114. package/src/internal/parseWindowsDirectoryCaseSensitivity.ts +5 -5
  115. package/src/internal/pathIdentity/createCaseSensitivityObservations.ts +242 -0
  116. package/src/internal/pathIdentity/createFilesystemPathIdentityContext.ts +2 -169
  117. package/src/internal/probeLocalProcess.ts +13 -8
  118. package/src/internal/projectInputPathIdentity.ts +1 -0
  119. package/src/launcher/internal/parseTtsxCLI.ts +5 -4
  120. package/src/launcher/internal/prepareExecution.ts +4 -1
  121. package/src/launcher/internal/resolveSingleFileOutput.ts +8 -9
  122. package/src/launcher/internal/runTtsc.ts +5 -5
  123. package/src/launcher/internal/runTtsx.ts +17 -8
  124. package/src/launcher/internal/runtime/ProcessOwnedDirectory.ts +5 -1
  125. package/src/launcher/internal/runtime/RuntimeEntrySources.ts +57 -0
  126. package/src/launcher/internal/runtime/RuntimeProjectOwnership.ts +23 -10
  127. package/src/launcher/internal/runtime/commonJsExportNames.ts +11 -4
  128. package/src/launcher/internal/runtime/installRuntimeHooks.ts +55 -13
  129. package/src/launcher/internal/runtime/isLocalProcessGone.ts +5 -3
  130. package/src/launcher/internal/runtime/resolveRuntimeCleanTargets.ts +17 -5
  131. package/src/launcher/internal/watch/FseventsStreams.ts +22 -0
  132. package/src/launcher/internal/watch/WatchTopology.ts +387 -99
  133. package/src/launcher/internal/watch/projectInputReloadEventShouldNotify.ts +14 -9
  134. package/src/plugin/internal/load/loadProjectPlugins.ts +17 -3
  135. package/src/plugin/internal/load/resolveNativeSource.ts +10 -4
  136. package/src/plugin/internal/source/pluginModuleReplaceDirectories.ts +10 -1
  137. package/src/structures/internal/TtscCommonOptions.ts +2 -2
  138. package/internal/graphsymbols/position_helpers_follow_ecma_line_terminators_test.go +0 -78
  139. package/internal/graphsymbols/provider.go +0 -650
  140. package/internal/lspserver/lsp_symbols.go +0 -212
@@ -1,212 +0,0 @@
1
- package lspserver
2
-
3
- // lsp_symbols.go lets the proxy answer two language methods from a local
4
- // SymbolProvider computed off ttsc's compiler-backed code graph (see
5
- // internal/graphsymbols): textDocument/documentSymbol and
6
- // textDocument/references. The wrapped tsgo LSP implements both itself, so the
7
- // proxy forwards to tsgo whenever it advertises the capability and only answers
8
- // locally as a fallback or when a consumer opts into the graph answers (see
9
- // shouldAnswerDocumentSymbolLocally / shouldAnswerReferencesLocally).
10
-
11
- import "encoding/json"
12
-
13
- // LSPSymbolKind mirrors the LSP SymbolKind enum. Only the members the graph's
14
- // node kinds map onto are named here; the numeric values are the wire contract.
15
- //
16
- // @evidence contracts/common.md#principled-implementation Integer discriminants retain LSP SymbolKind values while naming the graph-supported subset.
17
- // @evidence contracts/common.md#clear-and-simple-design One enum serves hierarchy and usage results without compiler node dependencies.
18
- // @evidence contracts/common.md#prohibited-implementation-shortcuts Named values are protocol constants rather than guessed graph outputs.
19
- // @evidence contracts/common.md#meaningful-documentation Native prose explains the supported subset and numeric wire meaning, following the documentation skill.
20
- // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
21
- // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
22
- // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
23
- // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
24
- type LSPSymbolKind int
25
-
26
- const (
27
- LSPSymbolKindClass LSPSymbolKind = 5
28
- LSPSymbolKindMethod LSPSymbolKind = 6
29
- LSPSymbolKindEnum LSPSymbolKind = 10
30
- LSPSymbolKindInterface LSPSymbolKind = 11
31
- LSPSymbolKindFunction LSPSymbolKind = 12
32
- LSPSymbolKindVariable LSPSymbolKind = 13
33
- LSPSymbolKindStruct LSPSymbolKind = 23
34
- )
35
-
36
- // LSPDocumentSymbol is the hierarchical shape returned by
37
- // textDocument/documentSymbol. Range spans the whole declaration and
38
- // SelectionRange identifies the contained navigation span. The graph provider
39
- // uses the whole declaration span for both because it lacks a separate name
40
- // span. Children nest members (a class's methods) under their owner.
41
- //
42
- // @evidence contracts/common.md#principled-implementation Whole and selection ranges remain distinct while recursive Children represent declaration ownership.
43
- // @evidence contracts/common.md#clear-and-simple-design The hierarchical result reuses ranges and kinds without mixing query state into nodes.
44
- // @evidence contracts/common.md#prohibited-implementation-shortcuts The graph supplies actual names and ranges; the shape does not encode expected declarations.
45
- // @evidence contracts/common.md#meaningful-documentation Native prose documents selection containment and child ownership, following the documentation skill.
46
- // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
47
- // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
48
- // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
49
- // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
50
- type LSPDocumentSymbol struct {
51
- // Name is the declaration's display name.
52
- Name string `json:"name"`
53
-
54
- // Kind classifies the declaration using LSP SymbolKind discriminants.
55
- Kind LSPSymbolKind `json:"kind"`
56
-
57
- // Range covers the declaration in session UTF-16 coordinates.
58
- Range LSPRange `json:"range"`
59
-
60
- // SelectionRange is contained in Range and need not isolate the name.
61
- SelectionRange LSPRange `json:"selectionRange"`
62
-
63
- // Children nest owned declarations; an empty list is omitted.
64
- Children []LSPDocumentSymbol `json:"children,omitempty"`
65
- }
66
-
67
- // LSPLocation is the wire shape of an LSP Location: a range inside a document,
68
- // returned by textDocument/references for each usage site.
69
- //
70
- // @evidence contracts/common.md#principled-implementation URI plus range identifies a usage independently of the document currently open in the editor.
71
- // @evidence contracts/common.md#clear-and-simple-design Reference results and related diagnostics share this location value.
72
- // @evidence contracts/common.md#prohibited-implementation-shortcuts Locations are producer values rather than guessed local filenames.
73
- // @evidence contracts/common.md#meaningful-documentation Native prose describes document usage sites, following the documentation skill.
74
- // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
75
- // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
76
- // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
77
- // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
78
- type LSPLocation struct {
79
- // URI identifies the target document using protocol spelling.
80
- URI string `json:"uri"`
81
-
82
- // Range locates the site in that document's session UTF-16 coordinates.
83
- Range LSPRange `json:"range"`
84
- }
85
-
86
- // SymbolProvider computes documentSymbol and references locally from ttsc's
87
- // compiler-backed code graph. tsgo implements both methods too, so the proxy
88
- // consults a provider only as a fallback or when a consumer opts into the graph
89
- // answers; see shouldAnswerDocumentSymbolLocally / shouldAnswerReferencesLocally.
90
- //
91
- // Implementations may load a compiler Program lazily and must be safe to call
92
- // from multiple goroutines. DocumentSymbols and References run in separate
93
- // query goroutines rather than on the editor pump. Their replies still share
94
- // frame serialization, and this does not bound custom provider work or the
95
- // synchronous invalidation call.
96
- //
97
- // @evidence contracts/common.md#principled-implementation Hierarchy, usage lookup and invalidation are separate operations over the provider's compiler-backed state.
98
- // @evidence contracts/common.md#clear-and-simple-design The proxy depends on semantic queries without exposing graph construction or program storage.
99
- // @evidence contracts/common.md#prohibited-implementation-shortcuts Supported injection supplies local answers without replacing upstream symbol methods.
100
- // @evidence contracts/common.md#meaningful-documentation Native paragraphs document fallback selection and concurrent invocation, following the documentation skill.
101
- // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources A type declaration acquires and holds no runtime resource.
102
- // @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
103
- // @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
104
- // @evidenceExclude contracts/portability.md#os-neutral-implementation This type declaration describes a data shape only; it opens no file, builds no path and branches on no platform.
105
- type SymbolProvider interface {
106
- // DocumentSymbols returns the declarations in the document identified by uri
107
- // as a hierarchy of LSPDocumentSymbol. A document with no declarations
108
- // yields an empty (non-nil) slice.
109
- //
110
- // @evidence contracts/common.md#principled-implementation URI selects one document whose declarations form an ownership hierarchy.
111
- // @evidence contracts/common.md#clear-and-simple-design This query returns wire nodes while the implementation owns compiler loading.
112
- // @evidence contracts/common.md#prohibited-implementation-shortcuts Results come through the provider boundary instead of patched upstream methods.
113
- // @evidence contracts/common.md#meaningful-documentation Native prose states hierarchy and empty-result meaning, following the documentation skill.
114
- // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources DocumentSymbols declares a signature only; the implementation owns acquisition and release of resources.
115
- // @evidenceExclude contracts/performance.md#efficient-algorithms DocumentSymbols declares a signature only; the implementation owns the processing strategy.
116
- // @evidenceExclude contracts/performance.md#reuse-equivalent-work DocumentSymbols declares a signature only; the implementation owns any shared work.
117
- // @evidenceExclude contracts/portability.md#os-neutral-implementation DocumentSymbols is a signature without a body here; path and platform behavior belongs to the implementation that supplies it.
118
- DocumentSymbols(uri string) ([]LSPDocumentSymbol, error)
119
-
120
- // References returns the usage locations of the symbol at pos in the document
121
- // identified by uri. includeDeclaration adds the symbol's own declaration to
122
- // the result. A position that resolves to no symbol yields an empty slice.
123
- //
124
- // @evidence contracts/common.md#principled-implementation URI and UTF-16 position select a symbol; includeDeclaration distinguishes declaration sites from usages.
125
- // @evidence contracts/common.md#clear-and-simple-design The query returns shared location values without exposing symbol identity internals.
126
- // @evidence contracts/common.md#prohibited-implementation-shortcuts A missing symbol yields no usages instead of guessed same-name matches.
127
- // @evidence contracts/common.md#meaningful-documentation Native prose explains declaration inclusion and empty results, following the documentation skill.
128
- // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources References declares a signature only; the implementation owns acquisition and release of resources.
129
- // @evidenceExclude contracts/performance.md#efficient-algorithms References declares a signature only; the implementation owns the processing strategy.
130
- // @evidenceExclude contracts/performance.md#reuse-equivalent-work References declares a signature only; the implementation owns any shared work.
131
- // @evidenceExclude contracts/portability.md#os-neutral-implementation References is a signature without a body here; path and platform behavior belongs to the implementation that supplies it.
132
- References(uri string, pos LSPPosition, includeDeclaration bool) ([]LSPLocation, error)
133
-
134
- // Invalidate withdraws published cached compiler state from later queries.
135
- // The proxy calls it on didChange/didSave; an uncached provider may no-op.
136
- // In-flight queries may still hold an earlier snapshot, and invalidation alone
137
- // does not certify a new native capture or cancel that work.
138
- //
139
- // @evidence contracts/common.md#principled-implementation Invalidation withdraws compiler-backed state before later queries use it.
140
- // @evidence contracts/common.md#clear-and-simple-design Cache policy stays with the provider that owns the state.
141
- // @evidence contracts/common.md#prohibited-implementation-shortcuts An uncached provider may legitimately do nothing; a cached provider cannot fake freshness by retaining disproven state.
142
- // @evidence contracts/common.md#meaningful-documentation Native prose documents triggers and the uncached exception, following the documentation skill.
143
- // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources Invalidate declares a signature only; the implementation owns acquisition and release of resources.
144
- // @evidenceExclude contracts/performance.md#efficient-algorithms Invalidate declares a signature only; the implementation owns the processing strategy.
145
- // @evidenceExclude contracts/performance.md#reuse-equivalent-work Invalidate declares a signature only; the implementation owns any shared work.
146
- // @evidenceExclude contracts/portability.md#os-neutral-implementation Invalidate is a signature without a body here; path and platform behavior belongs to the implementation that supplies it.
147
- Invalidate()
148
- }
149
-
150
- // handleDocumentSymbolRequest answers textDocument/documentSymbol from the local
151
- // SymbolProvider only when shouldAnswerDocumentSymbolLocally says to (no
152
- // provider wired, upstream tsgo did not advertise the capability, or a consumer
153
- // forced the local provider). Otherwise it returns false so the request flows to
154
- // upstream tsgo's compiler-exact handler. The computation runs on its own
155
- // goroutine (a program load can be slow) so the editor->upstream pump keeps
156
- // servicing other traffic.
157
- func (p *Proxy) handleDocumentSymbolRequest(env Envelope) (bool, error) {
158
- if !p.shouldAnswerDocumentSymbolLocally() {
159
- return false, nil
160
- }
161
- var params struct {
162
- TextDocument struct {
163
- URI string `json:"uri"`
164
- } `json:"textDocument"`
165
- }
166
- if err := json.Unmarshal(env.Params, &params); err != nil || params.TextDocument.URI == "" {
167
- return false, nil
168
- }
169
- go p.completeDocumentSymbolRequest(env, params.TextDocument.URI)
170
- return true, nil
171
- }
172
-
173
- func (p *Proxy) completeDocumentSymbolRequest(env Envelope, uri string) {
174
- symbols, err := p.symbolProvider.DocumentSymbols(uri)
175
- if err != nil || symbols == nil {
176
- // A provider failure must not surface as an LSP error to a graph
177
- // consumer mid-index; reply with an empty result so the client moves on.
178
- symbols = []LSPDocumentSymbol{}
179
- }
180
- p.reportAsyncError(p.writeResult(env.ID, symbols))
181
- }
182
-
183
- // handleReferencesRequest answers textDocument/references from the local
184
- // SymbolProvider, mirroring handleDocumentSymbolRequest's gating (via
185
- // shouldAnswerReferencesLocally) and off-pump-goroutine behavior.
186
- func (p *Proxy) handleReferencesRequest(env Envelope) (bool, error) {
187
- if !p.shouldAnswerReferencesLocally() {
188
- return false, nil
189
- }
190
- var params struct {
191
- TextDocument struct {
192
- URI string `json:"uri"`
193
- } `json:"textDocument"`
194
- Position LSPPosition `json:"position"`
195
- Context struct {
196
- IncludeDeclaration bool `json:"includeDeclaration"`
197
- } `json:"context"`
198
- }
199
- if err := json.Unmarshal(env.Params, &params); err != nil || params.TextDocument.URI == "" {
200
- return false, nil
201
- }
202
- go p.completeReferencesRequest(env, params.TextDocument.URI, params.Position, params.Context.IncludeDeclaration)
203
- return true, nil
204
- }
205
-
206
- func (p *Proxy) completeReferencesRequest(env Envelope, uri string, pos LSPPosition, includeDeclaration bool) {
207
- locations, err := p.symbolProvider.References(uri, pos, includeDeclaration)
208
- if err != nil || locations == nil {
209
- locations = []LSPLocation{}
210
- }
211
- p.reportAsyncError(p.writeResult(env.ID, locations))
212
- }