@ripple-ts/language-server 0.2.199 → 0.2.201

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ripple-ts/language-server",
3
- "version": "0.2.199",
3
+ "version": "0.2.201",
4
4
  "description": "Language Server Protocol implementation for Ripple",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -14,15 +14,15 @@
14
14
  "directory": "packages/language-server"
15
15
  },
16
16
  "dependencies": {
17
- "@volar/language-server": "~2.4.23",
18
- "volar-service-css": "0.0.65",
19
- "volar-service-typescript": "0.0.65",
17
+ "@volar/language-server": "~2.4.28",
18
+ "volar-service-css": "0.0.68",
19
+ "volar-service-typescript": "0.0.68",
20
20
  "vscode-languageserver-textdocument": "^1.0.12",
21
21
  "vscode-uri": "^3.1.0",
22
- "@ripple-ts/typescript-plugin": "0.2.199"
22
+ "@ripple-ts/typescript-plugin": "0.2.201"
23
23
  },
24
24
  "devDependencies": {
25
- "ripple": "0.2.199"
25
+ "ripple": "0.2.201"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "typescript": "^5.9.2"
@@ -203,66 +203,6 @@ function createDefinitionPlugin() {
203
203
  }
204
204
  }
205
205
 
206
- // Below here we handle adjusting TS definition for transformed tokens
207
- // `originSelectionRange` returned by TS needs its end character adjusted
208
- // to account for the source length differing from generated length
209
- // e.g. when "component" in Ripple maps to "function" in TS
210
- // Or when "#Map" maps to "TrackedMap", etc.
211
-
212
- // If no TypeScript definitions, nothing to modify
213
- // Volar will let the next ts plugin handle it
214
- if (tsDefinitions.length === 0) {
215
- return;
216
- }
217
-
218
- // Get the range from TypeScript's definition to find the exact token
219
- // This gives us the precise start and end of the token (e.g., "function")
220
- const firstDefinition = tsDefinitions[0];
221
- if (!firstDefinition?.originSelectionRange) {
222
- return tsDefinitions;
223
- }
224
-
225
- const range = firstDefinition.originSelectionRange;
226
- const rangeStart = document.offsetAt(range.start);
227
- const rangeEnd = document.offsetAt(range.end);
228
-
229
- // Find the mapping using the exact token range for O(1) lookup
230
- const mapping = virtualCode.findMappingByGeneratedRange(rangeStart, rangeEnd);
231
-
232
- if (!mapping) {
233
- return tsDefinitions;
234
- }
235
-
236
- log('Found mapping for definition at range', 'start: ', rangeStart, 'end: ', rangeEnd);
237
-
238
- // Check if source length differs from generated length
239
- // e.g., "component" -> "function" (source > generated)
240
- // e.g., "#Map" -> "TrackedMap" (source < generated)
241
- const customData = mapping.data.customData;
242
- const sourceLength = mapping.lengths[0];
243
- const generatedLength = customData.generatedLengths[0];
244
-
245
- // If source and generated are same length, no transformation needed
246
- if (sourceLength === generatedLength) {
247
- return tsDefinitions;
248
- }
249
-
250
- const diffLength = sourceLength - generatedLength;
251
-
252
- for (const definition of tsDefinitions) {
253
- const tsRange = definition.originSelectionRange;
254
- if (!tsRange) {
255
- continue;
256
- }
257
-
258
- definition.originSelectionRange = {
259
- start: tsRange.start,
260
- end: {
261
- line: tsRange.end.line,
262
- character: tsRange.end.character + diffLength,
263
- },
264
- };
265
- }
266
206
  return tsDefinitions;
267
207
  },
268
208
  };
@@ -98,13 +98,26 @@ function createHoverPlugin() {
98
98
  }
99
99
 
100
100
  const customHover = mapping?.data?.customData?.hover;
101
- if (customHover) {
101
+
102
+ if (customHover === undefined) {
103
+ return tsHover;
104
+ }
105
+
106
+ if (typeof customHover === 'function') {
107
+ if (tsHover) {
108
+ /** @type {MarkupContent} **/ (tsHover.contents).value = customHover(
109
+ /** @type {MarkupContent} **/ (tsHover.contents).value,
110
+ );
111
+ log('Modified hover contents using custom hover function');
112
+ }
113
+ return tsHover;
114
+ } else if (typeof customHover === 'string') {
102
115
  const contents = tsHover
103
116
  ? concatMarkdownContents(
104
117
  /** @type {MarkupContent} **/ (tsHover.contents).value,
105
- customHover.contents,
118
+ customHover,
106
119
  )
107
- : customHover.contents;
120
+ : customHover;
108
121
  log('Found custom hover data in mapping');
109
122
  return {
110
123
  contents: {
@@ -125,29 +138,6 @@ function createHoverPlugin() {
125
138
 
126
139
  log('Found mapping for hover at range', 'start: ', starOffset, 'end: ', endOffset);
127
140
 
128
- if (tsHover && tsHover.range) {
129
- // Check if source length is greater than generated length (component -> function)
130
- const customData = mapping.data.customData;
131
- const sourceLength = mapping.lengths[0];
132
- const generatedLength = customData.generatedLengths[0];
133
-
134
- // If no generatedLengths, or source and generated are same length, no transformation
135
- if (sourceLength <= generatedLength) {
136
- return tsHover;
137
- }
138
-
139
- const diffLength = sourceLength - generatedLength;
140
-
141
- // Adjust the hover range to highlight the full "component" keyword
142
- tsHover.range = {
143
- start: tsHover.range.start,
144
- end: {
145
- line: tsHover.range.end.line,
146
- character: tsHover.range.end.character + diffLength,
147
- },
148
- };
149
- }
150
-
151
141
  return tsHover;
152
142
  },
153
143
  };