@ripple-ts/language-server 0.2.191 → 0.2.192

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.191",
3
+ "version": "0.2.192",
4
4
  "description": "Language Server Protocol implementation for Ripple",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -19,10 +19,10 @@
19
19
  "volar-service-typescript": "0.0.65",
20
20
  "vscode-languageserver-textdocument": "^1.0.12",
21
21
  "vscode-uri": "^3.1.0",
22
- "@ripple-ts/typescript-plugin": "0.2.191"
22
+ "@ripple-ts/typescript-plugin": "0.2.192"
23
23
  },
24
24
  "devDependencies": {
25
- "ripple": "0.2.191"
25
+ "ripple": "0.2.192"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "typescript": "^5.9.2"
@@ -10,7 +10,7 @@ const {
10
10
  createLogging,
11
11
  getWordFromPosition,
12
12
  concatMarkdownContents,
13
- deobfuscateImportDefinitions,
13
+ deobfuscateIdentifiers,
14
14
  } = require('./utils.js');
15
15
 
16
16
  const { log, logError } = createLogging('[Ripple Hover Plugin]');
@@ -55,7 +55,7 @@ function createHoverPlugin() {
55
55
  }
56
56
 
57
57
  if (tsHover && tsHover.contents) {
58
- /** @type {MarkupContent} **/ (tsHover.contents).value = deobfuscateImportDefinitions(
58
+ /** @type {MarkupContent} **/ (tsHover.contents).value = deobfuscateIdentifiers(
59
59
  /** @type {MarkupContent} **/ (tsHover.contents).value,
60
60
  );
61
61
  }
@@ -8,10 +8,19 @@
8
8
  @import {TextDocument} from 'vscode-languageserver-textdocument';
9
9
  */
10
10
 
11
- const { getVirtualCode, createLogging } = require('./utils.js');
11
+ const { getVirtualCode, createLogging, deobfuscateIdentifiers } = require('./utils.js');
12
12
 
13
13
  const { log, logError } = createLogging('[Ripple TypeScript Diagnostic Plugin]');
14
14
 
15
+ /**
16
+ * @param {Diagnostic} diagnostic
17
+ * @param {Diagnostic[]} items
18
+ */
19
+ function process(diagnostic, items) {
20
+ diagnostic.message = deobfuscateIdentifiers(diagnostic.message);
21
+ items.push(diagnostic);
22
+ }
23
+
15
24
  /**
16
25
  * Filter diagnostics based on suppressed diagnostic codes in mappings.
17
26
  * @param {TextDocument} document
@@ -19,7 +28,7 @@ const { log, logError } = createLogging('[Ripple TypeScript Diagnostic Plugin]')
19
28
  * @param {Diagnostic[]} diagnostics
20
29
  * @returns {Diagnostic[]}
21
30
  */
22
- function filterDiagnostics(document, context, diagnostics) {
31
+ function processDiagnostics(document, context, diagnostics) {
23
32
  if (!diagnostics || diagnostics.length === 0) {
24
33
  return diagnostics;
25
34
  }
@@ -32,20 +41,25 @@ function filterDiagnostics(document, context, diagnostics) {
32
41
  return diagnostics;
33
42
  }
34
43
 
35
- const filtered = diagnostics.filter((diagnostic) => {
44
+ /** @type {Diagnostic[]} */
45
+ const result = [];
46
+
47
+ for (const diagnostic of diagnostics) {
36
48
  const range = diagnostic.range;
37
49
  const rangeStart = document.offsetAt(range.start);
38
50
  const rangeEnd = document.offsetAt(range.end);
39
51
  const mapping = virtualCode.findMappingByGeneratedRange(rangeStart, rangeEnd);
40
52
 
41
53
  if (!mapping) {
42
- return true;
54
+ process(diagnostic, result);
55
+ continue;
43
56
  }
44
57
 
45
58
  const suppressedCodes = mapping.data.customData?.suppressedDiagnostics;
46
59
 
47
60
  if (!suppressedCodes || suppressedCodes.length === 0) {
48
- return true;
61
+ process(diagnostic, result);
62
+ continue;
49
63
  }
50
64
 
51
65
  const diagnosticCode =
@@ -57,14 +71,14 @@ function filterDiagnostics(document, context, diagnostics) {
57
71
 
58
72
  if (diagnosticCode && suppressedCodes.includes(diagnosticCode)) {
59
73
  log(`Suppressing diagnostic ${diagnosticCode}: ${diagnostic.message}`);
60
- return false;
74
+ continue;
61
75
  }
62
76
 
63
- return true;
64
- });
77
+ process(diagnostic, result);
78
+ }
65
79
 
66
- log(`Filtered from ${diagnostics.length} to ${filtered.length} diagnostics`);
67
- return filtered;
80
+ log(`Filtered from ${diagnostics.length} to ${result.length} diagnostics`);
81
+ return result;
68
82
  }
69
83
 
70
84
  /**
@@ -96,7 +110,7 @@ function createTypeScriptDiagnosticFilterPlugin() {
96
110
  // This maintains the plugin association for code actions
97
111
  instance.provideDiagnostics = async function (document, token) {
98
112
  const diagnostics = await originalProvider?.call(originalInstance, document, token);
99
- return filterDiagnostics(document, context, diagnostics ?? []);
113
+ return processDiagnostics(document, context, diagnostics ?? []);
100
114
  };
101
115
 
102
116
  log('Successfully wrapped typescript-semantic provideDiagnostics');
package/src/utils.js CHANGED
@@ -27,13 +27,13 @@ let deobfuscate_identifier;
27
27
  /** @type {IDENTIFIER_OBFUSCATION_PREFIX} */
28
28
  let IDENTIFIER_OBFUSCATION_PREFIX;
29
29
  /** @type {RegExp} */
30
- let obfuscatedImportRegex;
30
+ let obfuscated_identifier_regex;
31
31
 
32
32
  import('ripple/compiler/internal/identifier/utils').then((imports) => {
33
33
  is_identifier_obfuscated = imports.is_identifier_obfuscated;
34
34
  deobfuscate_identifier = imports.deobfuscate_identifier;
35
35
  IDENTIFIER_OBFUSCATION_PREFIX = imports.IDENTIFIER_OBFUSCATION_PREFIX;
36
- obfuscatedImportRegex = new RegExp(
36
+ obfuscated_identifier_regex = new RegExp(
37
37
  escapeRegExp(IDENTIFIER_OBFUSCATION_PREFIX) + charAllowedWordRegex.source + '+',
38
38
  'gm',
39
39
  );
@@ -52,8 +52,8 @@ function escapeRegExp(source) {
52
52
  * @param {string} text
53
53
  * @returns {string}
54
54
  */
55
- function deobfuscateImportDefinitions(text) {
56
- return text.replace(obfuscatedImportRegex, (match) => deobfuscate_identifier(match));
55
+ function deobfuscateIdentifiers(text) {
56
+ return text.replace(obfuscated_identifier_regex, (match) => deobfuscate_identifier(match));
57
57
  }
58
58
 
59
59
  /**
@@ -169,6 +169,6 @@ module.exports = {
169
169
  isInsideExport,
170
170
  createLogging,
171
171
  concatMarkdownContents,
172
- deobfuscateImportDefinitions,
172
+ deobfuscateIdentifiers,
173
173
  DEBUG,
174
174
  };