@macroforge/svelte-language-server 0.1.3

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 (256) hide show
  1. package/README.md +331 -0
  2. package/bin/server.js +5 -0
  3. package/dist/src/importPackage.d.ts +16 -0
  4. package/dist/src/importPackage.js +76 -0
  5. package/dist/src/importPackage.js.map +1 -0
  6. package/dist/src/index.d.ts +3 -0
  7. package/dist/src/index.js +23 -0
  8. package/dist/src/index.js.map +1 -0
  9. package/dist/src/lib/DiagnosticsManager.d.ts +20 -0
  10. package/dist/src/lib/DiagnosticsManager.js +71 -0
  11. package/dist/src/lib/DiagnosticsManager.js.map +1 -0
  12. package/dist/src/lib/FallbackWatcher.d.ts +15 -0
  13. package/dist/src/lib/FallbackWatcher.js +66 -0
  14. package/dist/src/lib/FallbackWatcher.js.map +1 -0
  15. package/dist/src/lib/documentHighlight/wordHighlight.d.ts +3 -0
  16. package/dist/src/lib/documentHighlight/wordHighlight.js +62 -0
  17. package/dist/src/lib/documentHighlight/wordHighlight.js.map +1 -0
  18. package/dist/src/lib/documents/Document.d.ts +63 -0
  19. package/dist/src/lib/documents/Document.js +138 -0
  20. package/dist/src/lib/documents/Document.js.map +1 -0
  21. package/dist/src/lib/documents/DocumentBase.d.ts +65 -0
  22. package/dist/src/lib/documents/DocumentBase.js +69 -0
  23. package/dist/src/lib/documents/DocumentBase.js.map +1 -0
  24. package/dist/src/lib/documents/DocumentManager.d.ts +28 -0
  25. package/dist/src/lib/documents/DocumentManager.js +122 -0
  26. package/dist/src/lib/documents/DocumentManager.js.map +1 -0
  27. package/dist/src/lib/documents/DocumentMapper.d.ts +88 -0
  28. package/dist/src/lib/documents/DocumentMapper.js +258 -0
  29. package/dist/src/lib/documents/DocumentMapper.js.map +1 -0
  30. package/dist/src/lib/documents/configLoader.d.ts +80 -0
  31. package/dist/src/lib/documents/configLoader.js +265 -0
  32. package/dist/src/lib/documents/configLoader.js.map +1 -0
  33. package/dist/src/lib/documents/fileCollection.d.ts +41 -0
  34. package/dist/src/lib/documents/fileCollection.js +87 -0
  35. package/dist/src/lib/documents/fileCollection.js.map +1 -0
  36. package/dist/src/lib/documents/index.d.ts +5 -0
  37. package/dist/src/lib/documents/index.js +22 -0
  38. package/dist/src/lib/documents/index.js.map +1 -0
  39. package/dist/src/lib/documents/parseHtml.d.ts +13 -0
  40. package/dist/src/lib/documents/parseHtml.js +160 -0
  41. package/dist/src/lib/documents/parseHtml.js.map +1 -0
  42. package/dist/src/lib/documents/utils.d.ts +105 -0
  43. package/dist/src/lib/documents/utils.js +410 -0
  44. package/dist/src/lib/documents/utils.js.map +1 -0
  45. package/dist/src/lib/foldingRange/indentFolding.d.ts +26 -0
  46. package/dist/src/lib/foldingRange/indentFolding.js +142 -0
  47. package/dist/src/lib/foldingRange/indentFolding.js.map +1 -0
  48. package/dist/src/lib/semanticToken/semanticTokenLegend.d.ts +33 -0
  49. package/dist/src/lib/semanticToken/semanticTokenLegend.js +37 -0
  50. package/dist/src/lib/semanticToken/semanticTokenLegend.js.map +1 -0
  51. package/dist/src/logger.d.ts +9 -0
  52. package/dist/src/logger.js +28 -0
  53. package/dist/src/logger.js.map +1 -0
  54. package/dist/src/ls-config.d.ts +326 -0
  55. package/dist/src/ls-config.js +386 -0
  56. package/dist/src/ls-config.js.map +1 -0
  57. package/dist/src/plugins/PluginHost.d.ts +68 -0
  58. package/dist/src/plugins/PluginHost.js +447 -0
  59. package/dist/src/plugins/PluginHost.js.map +1 -0
  60. package/dist/src/plugins/css/CSSDocument.d.ts +46 -0
  61. package/dist/src/plugins/css/CSSDocument.js +78 -0
  62. package/dist/src/plugins/css/CSSDocument.js.map +1 -0
  63. package/dist/src/plugins/css/CSSPlugin.d.ts +35 -0
  64. package/dist/src/plugins/css/CSSPlugin.js +407 -0
  65. package/dist/src/plugins/css/CSSPlugin.js.map +1 -0
  66. package/dist/src/plugins/css/FileSystemProvider.d.ts +10 -0
  67. package/dist/src/plugins/css/FileSystemProvider.js +75 -0
  68. package/dist/src/plugins/css/FileSystemProvider.js.map +1 -0
  69. package/dist/src/plugins/css/StyleAttributeDocument.d.ts +41 -0
  70. package/dist/src/plugins/css/StyleAttributeDocument.js +65 -0
  71. package/dist/src/plugins/css/StyleAttributeDocument.js.map +1 -0
  72. package/dist/src/plugins/css/features/getIdClassCompletion.d.ts +19 -0
  73. package/dist/src/plugins/css/features/getIdClassCompletion.js +56 -0
  74. package/dist/src/plugins/css/features/getIdClassCompletion.js.map +1 -0
  75. package/dist/src/plugins/css/features/svelte-selectors.d.ts +2 -0
  76. package/dist/src/plugins/css/features/svelte-selectors.js +18 -0
  77. package/dist/src/plugins/css/features/svelte-selectors.js.map +1 -0
  78. package/dist/src/plugins/css/global-vars.d.ts +16 -0
  79. package/dist/src/plugins/css/global-vars.js +82 -0
  80. package/dist/src/plugins/css/global-vars.js.map +1 -0
  81. package/dist/src/plugins/css/service.d.ts +5 -0
  82. package/dist/src/plugins/css/service.js +66 -0
  83. package/dist/src/plugins/css/service.js.map +1 -0
  84. package/dist/src/plugins/documentContext.d.ts +3 -0
  85. package/dist/src/plugins/documentContext.js +36 -0
  86. package/dist/src/plugins/documentContext.js.map +1 -0
  87. package/dist/src/plugins/html/HTMLPlugin.d.ts +36 -0
  88. package/dist/src/plugins/html/HTMLPlugin.js +363 -0
  89. package/dist/src/plugins/html/HTMLPlugin.js.map +1 -0
  90. package/dist/src/plugins/html/dataProvider.d.ts +1 -0
  91. package/dist/src/plugins/html/dataProvider.js +481 -0
  92. package/dist/src/plugins/html/dataProvider.js.map +1 -0
  93. package/dist/src/plugins/index.d.ts +7 -0
  94. package/dist/src/plugins/index.js +24 -0
  95. package/dist/src/plugins/index.js.map +1 -0
  96. package/dist/src/plugins/interfaces.d.ts +132 -0
  97. package/dist/src/plugins/interfaces.js +3 -0
  98. package/dist/src/plugins/interfaces.js.map +1 -0
  99. package/dist/src/plugins/svelte/SvelteDocument.d.ts +98 -0
  100. package/dist/src/plugins/svelte/SvelteDocument.js +318 -0
  101. package/dist/src/plugins/svelte/SvelteDocument.js.map +1 -0
  102. package/dist/src/plugins/svelte/SveltePlugin.d.ts +24 -0
  103. package/dist/src/plugins/svelte/SveltePlugin.js +306 -0
  104. package/dist/src/plugins/svelte/SveltePlugin.js.map +1 -0
  105. package/dist/src/plugins/svelte/features/SvelteTags.d.ts +28 -0
  106. package/dist/src/plugins/svelte/features/SvelteTags.js +136 -0
  107. package/dist/src/plugins/svelte/features/SvelteTags.js.map +1 -0
  108. package/dist/src/plugins/svelte/features/getCodeActions/getQuickfixes.d.ts +11 -0
  109. package/dist/src/plugins/svelte/features/getCodeActions/getQuickfixes.js +140 -0
  110. package/dist/src/plugins/svelte/features/getCodeActions/getQuickfixes.js.map +1 -0
  111. package/dist/src/plugins/svelte/features/getCodeActions/getRefactorings.d.ts +9 -0
  112. package/dist/src/plugins/svelte/features/getCodeActions/getRefactorings.js +140 -0
  113. package/dist/src/plugins/svelte/features/getCodeActions/getRefactorings.js.map +1 -0
  114. package/dist/src/plugins/svelte/features/getCodeActions/index.d.ts +4 -0
  115. package/dist/src/plugins/svelte/features/getCodeActions/index.js +19 -0
  116. package/dist/src/plugins/svelte/features/getCodeActions/index.js.map +1 -0
  117. package/dist/src/plugins/svelte/features/getCompletions.d.ts +4 -0
  118. package/dist/src/plugins/svelte/features/getCompletions.js +184 -0
  119. package/dist/src/plugins/svelte/features/getCompletions.js.map +1 -0
  120. package/dist/src/plugins/svelte/features/getDiagnostics.d.ts +9 -0
  121. package/dist/src/plugins/svelte/features/getDiagnostics.js +284 -0
  122. package/dist/src/plugins/svelte/features/getDiagnostics.js.map +1 -0
  123. package/dist/src/plugins/svelte/features/getHoverInfo.d.ts +7 -0
  124. package/dist/src/plugins/svelte/features/getHoverInfo.js +93 -0
  125. package/dist/src/plugins/svelte/features/getHoverInfo.js.map +1 -0
  126. package/dist/src/plugins/svelte/features/getModifierData.d.ts +7 -0
  127. package/dist/src/plugins/svelte/features/getModifierData.js +56 -0
  128. package/dist/src/plugins/svelte/features/getModifierData.js.map +1 -0
  129. package/dist/src/plugins/svelte/features/getSelectionRanges.d.ts +3 -0
  130. package/dist/src/plugins/svelte/features/getSelectionRanges.js +46 -0
  131. package/dist/src/plugins/svelte/features/getSelectionRanges.js.map +1 -0
  132. package/dist/src/plugins/svelte/features/utils.d.ts +5 -0
  133. package/dist/src/plugins/svelte/features/utils.js +18 -0
  134. package/dist/src/plugins/svelte/features/utils.js.map +1 -0
  135. package/dist/src/plugins/typescript/ComponentInfoProvider.d.ts +27 -0
  136. package/dist/src/plugins/typescript/ComponentInfoProvider.js +116 -0
  137. package/dist/src/plugins/typescript/ComponentInfoProvider.js.map +1 -0
  138. package/dist/src/plugins/typescript/DocumentMapper.d.ts +10 -0
  139. package/dist/src/plugins/typescript/DocumentMapper.js +25 -0
  140. package/dist/src/plugins/typescript/DocumentMapper.js.map +1 -0
  141. package/dist/src/plugins/typescript/DocumentSnapshot.d.ts +173 -0
  142. package/dist/src/plugins/typescript/DocumentSnapshot.js +623 -0
  143. package/dist/src/plugins/typescript/DocumentSnapshot.js.map +1 -0
  144. package/dist/src/plugins/typescript/LSAndTSDocResolver.d.ts +100 -0
  145. package/dist/src/plugins/typescript/LSAndTSDocResolver.js +301 -0
  146. package/dist/src/plugins/typescript/LSAndTSDocResolver.js.map +1 -0
  147. package/dist/src/plugins/typescript/SnapshotManager.d.ts +59 -0
  148. package/dist/src/plugins/typescript/SnapshotManager.js +238 -0
  149. package/dist/src/plugins/typescript/SnapshotManager.js.map +1 -0
  150. package/dist/src/plugins/typescript/TypeScriptPlugin.d.ts +65 -0
  151. package/dist/src/plugins/typescript/TypeScriptPlugin.js +332 -0
  152. package/dist/src/plugins/typescript/TypeScriptPlugin.js.map +1 -0
  153. package/dist/src/plugins/typescript/features/CallHierarchyProvider.d.ts +24 -0
  154. package/dist/src/plugins/typescript/features/CallHierarchyProvider.js +325 -0
  155. package/dist/src/plugins/typescript/features/CallHierarchyProvider.js.map +1 -0
  156. package/dist/src/plugins/typescript/features/CodeActionsProvider.d.ts +72 -0
  157. package/dist/src/plugins/typescript/features/CodeActionsProvider.js +1030 -0
  158. package/dist/src/plugins/typescript/features/CodeActionsProvider.js.map +1 -0
  159. package/dist/src/plugins/typescript/features/CodeLensProvider.d.ts +28 -0
  160. package/dist/src/plugins/typescript/features/CodeLensProvider.js +205 -0
  161. package/dist/src/plugins/typescript/features/CodeLensProvider.js.map +1 -0
  162. package/dist/src/plugins/typescript/features/CompletionProvider.d.ts +57 -0
  163. package/dist/src/plugins/typescript/features/CompletionProvider.js +791 -0
  164. package/dist/src/plugins/typescript/features/CompletionProvider.js.map +1 -0
  165. package/dist/src/plugins/typescript/features/DiagnosticsProvider.d.ts +36 -0
  166. package/dist/src/plugins/typescript/features/DiagnosticsProvider.js +497 -0
  167. package/dist/src/plugins/typescript/features/DiagnosticsProvider.js.map +1 -0
  168. package/dist/src/plugins/typescript/features/DocumentHighlightProvider.d.ts +17 -0
  169. package/dist/src/plugins/typescript/features/DocumentHighlightProvider.js +211 -0
  170. package/dist/src/plugins/typescript/features/DocumentHighlightProvider.js.map +1 -0
  171. package/dist/src/plugins/typescript/features/FindComponentReferencesProvider.d.ts +9 -0
  172. package/dist/src/plugins/typescript/features/FindComponentReferencesProvider.js +66 -0
  173. package/dist/src/plugins/typescript/features/FindComponentReferencesProvider.js.map +1 -0
  174. package/dist/src/plugins/typescript/features/FindFileReferencesProvider.d.ts +9 -0
  175. package/dist/src/plugins/typescript/features/FindFileReferencesProvider.js +38 -0
  176. package/dist/src/plugins/typescript/features/FindFileReferencesProvider.js.map +1 -0
  177. package/dist/src/plugins/typescript/features/FindReferencesProvider.d.ts +20 -0
  178. package/dist/src/plugins/typescript/features/FindReferencesProvider.js +149 -0
  179. package/dist/src/plugins/typescript/features/FindReferencesProvider.js.map +1 -0
  180. package/dist/src/plugins/typescript/features/FoldingRangeProvider.d.ts +28 -0
  181. package/dist/src/plugins/typescript/features/FoldingRangeProvider.js +247 -0
  182. package/dist/src/plugins/typescript/features/FoldingRangeProvider.js.map +1 -0
  183. package/dist/src/plugins/typescript/features/HoverProvider.d.ts +11 -0
  184. package/dist/src/plugins/typescript/features/HoverProvider.js +75 -0
  185. package/dist/src/plugins/typescript/features/HoverProvider.js.map +1 -0
  186. package/dist/src/plugins/typescript/features/ImplementationProvider.d.ts +9 -0
  187. package/dist/src/plugins/typescript/features/ImplementationProvider.js +47 -0
  188. package/dist/src/plugins/typescript/features/ImplementationProvider.js.map +1 -0
  189. package/dist/src/plugins/typescript/features/InlayHintProvider.d.ts +22 -0
  190. package/dist/src/plugins/typescript/features/InlayHintProvider.js +225 -0
  191. package/dist/src/plugins/typescript/features/InlayHintProvider.js.map +1 -0
  192. package/dist/src/plugins/typescript/features/RenameProvider.d.ts +53 -0
  193. package/dist/src/plugins/typescript/features/RenameProvider.js +423 -0
  194. package/dist/src/plugins/typescript/features/RenameProvider.js.map +1 -0
  195. package/dist/src/plugins/typescript/features/SelectionRangeProvider.d.ts +18 -0
  196. package/dist/src/plugins/typescript/features/SelectionRangeProvider.js +62 -0
  197. package/dist/src/plugins/typescript/features/SelectionRangeProvider.js.map +1 -0
  198. package/dist/src/plugins/typescript/features/SemanticTokensProvider.d.ts +15 -0
  199. package/dist/src/plugins/typescript/features/SemanticTokensProvider.js +116 -0
  200. package/dist/src/plugins/typescript/features/SemanticTokensProvider.js.map +1 -0
  201. package/dist/src/plugins/typescript/features/SignatureHelpProvider.d.ts +22 -0
  202. package/dist/src/plugins/typescript/features/SignatureHelpProvider.js +110 -0
  203. package/dist/src/plugins/typescript/features/SignatureHelpProvider.js.map +1 -0
  204. package/dist/src/plugins/typescript/features/TypeDefinitionProvider.d.ts +9 -0
  205. package/dist/src/plugins/typescript/features/TypeDefinitionProvider.js +35 -0
  206. package/dist/src/plugins/typescript/features/TypeDefinitionProvider.js.map +1 -0
  207. package/dist/src/plugins/typescript/features/UpdateImportsProvider.d.ts +11 -0
  208. package/dist/src/plugins/typescript/features/UpdateImportsProvider.js +109 -0
  209. package/dist/src/plugins/typescript/features/UpdateImportsProvider.js.map +1 -0
  210. package/dist/src/plugins/typescript/features/WorkspaceSymbolProvider.d.ts +25 -0
  211. package/dist/src/plugins/typescript/features/WorkspaceSymbolProvider.js +176 -0
  212. package/dist/src/plugins/typescript/features/WorkspaceSymbolProvider.js.map +1 -0
  213. package/dist/src/plugins/typescript/features/getDirectiveCommentCompletions.d.ts +13 -0
  214. package/dist/src/plugins/typescript/features/getDirectiveCommentCompletions.js +58 -0
  215. package/dist/src/plugins/typescript/features/getDirectiveCommentCompletions.js.map +1 -0
  216. package/dist/src/plugins/typescript/features/getJsDocTemplateCompletion.d.ts +4 -0
  217. package/dist/src/plugins/typescript/features/getJsDocTemplateCompletion.js +57 -0
  218. package/dist/src/plugins/typescript/features/getJsDocTemplateCompletion.js.map +1 -0
  219. package/dist/src/plugins/typescript/features/utils.d.ts +81 -0
  220. package/dist/src/plugins/typescript/features/utils.js +331 -0
  221. package/dist/src/plugins/typescript/features/utils.js.map +1 -0
  222. package/dist/src/plugins/typescript/macroforgeAugmenter.d.ts +23 -0
  223. package/dist/src/plugins/typescript/macroforgeAugmenter.js +41 -0
  224. package/dist/src/plugins/typescript/macroforgeAugmenter.js.map +1 -0
  225. package/dist/src/plugins/typescript/module-loader.d.ts +28 -0
  226. package/dist/src/plugins/typescript/module-loader.js +254 -0
  227. package/dist/src/plugins/typescript/module-loader.js.map +1 -0
  228. package/dist/src/plugins/typescript/previewer.d.ts +7 -0
  229. package/dist/src/plugins/typescript/previewer.js +120 -0
  230. package/dist/src/plugins/typescript/previewer.js.map +1 -0
  231. package/dist/src/plugins/typescript/service.d.ts +105 -0
  232. package/dist/src/plugins/typescript/service.js +1073 -0
  233. package/dist/src/plugins/typescript/service.js.map +1 -0
  234. package/dist/src/plugins/typescript/serviceCache.d.ts +90 -0
  235. package/dist/src/plugins/typescript/serviceCache.js +50 -0
  236. package/dist/src/plugins/typescript/serviceCache.js.map +1 -0
  237. package/dist/src/plugins/typescript/svelte-ast-utils.d.ts +77 -0
  238. package/dist/src/plugins/typescript/svelte-ast-utils.js +100 -0
  239. package/dist/src/plugins/typescript/svelte-ast-utils.js.map +1 -0
  240. package/dist/src/plugins/typescript/svelte-sys.d.ts +9 -0
  241. package/dist/src/plugins/typescript/svelte-sys.js +79 -0
  242. package/dist/src/plugins/typescript/svelte-sys.js.map +1 -0
  243. package/dist/src/plugins/typescript/utils.d.ts +48 -0
  244. package/dist/src/plugins/typescript/utils.js +334 -0
  245. package/dist/src/plugins/typescript/utils.js.map +1 -0
  246. package/dist/src/server.d.ts +19 -0
  247. package/dist/src/server.js +434 -0
  248. package/dist/src/server.js.map +1 -0
  249. package/dist/src/svelte-check.d.ts +65 -0
  250. package/dist/src/svelte-check.js +288 -0
  251. package/dist/src/svelte-check.js.map +1 -0
  252. package/dist/src/utils.d.ts +111 -0
  253. package/dist/src/utils.js +337 -0
  254. package/dist/src/utils.js.map +1 -0
  255. package/dist/tsconfig.tsbuildinfo +1 -0
  256. package/package.json +79 -0
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ignoredBuildDirectories = exports.SnapshotManager = exports.GlobalSnapshotsManager = void 0;
7
+ const typescript_1 = __importDefault(require("typescript"));
8
+ const DocumentSnapshot_1 = require("./DocumentSnapshot");
9
+ const logger_1 = require("../../logger");
10
+ const utils_1 = require("../../utils");
11
+ const events_1 = require("events");
12
+ const fileCollection_1 = require("../../lib/documents/fileCollection");
13
+ /**
14
+ * Every snapshot corresponds to a unique file on disk.
15
+ * A snapshot can be part of multiple projects, but for a given file path
16
+ * there can be only one snapshot.
17
+ */
18
+ class GlobalSnapshotsManager {
19
+ constructor(tsSystem) {
20
+ this.tsSystem = tsSystem;
21
+ this.emitter = new events_1.EventEmitter();
22
+ this.documents = new fileCollection_1.FileMap(tsSystem.useCaseSensitiveFileNames);
23
+ this.getCanonicalFileName = (0, utils_1.createGetCanonicalFileName)(tsSystem.useCaseSensitiveFileNames);
24
+ }
25
+ get(fileName) {
26
+ fileName = (0, utils_1.normalizePath)(fileName);
27
+ return this.documents.get(fileName);
28
+ }
29
+ getByPrefix(path) {
30
+ path = this.getCanonicalFileName((0, utils_1.normalizePath)(path));
31
+ return Array.from(this.documents.entries())
32
+ .filter((doc) => doc[0].startsWith(path))
33
+ .map((doc) => doc[1]);
34
+ }
35
+ set(fileName, document) {
36
+ fileName = (0, utils_1.normalizePath)(fileName);
37
+ this.documents.set(fileName, document);
38
+ this.emitter.emit('change', fileName, document);
39
+ }
40
+ delete(fileName) {
41
+ fileName = (0, utils_1.normalizePath)(fileName);
42
+ this.documents.delete(fileName);
43
+ this.emitter.emit('change', fileName, undefined);
44
+ }
45
+ updateTsOrJsFile(fileName, changes) {
46
+ fileName = (0, utils_1.normalizePath)(fileName);
47
+ const previousSnapshot = this.get(fileName);
48
+ if (changes) {
49
+ if (!(previousSnapshot instanceof DocumentSnapshot_1.JSOrTSDocumentSnapshot)) {
50
+ return;
51
+ }
52
+ previousSnapshot.update(changes);
53
+ this.emitter.emit('change', fileName, previousSnapshot);
54
+ return previousSnapshot;
55
+ }
56
+ else {
57
+ const newSnapshot = DocumentSnapshot_1.DocumentSnapshot.fromNonSvelteFilePath(fileName, this.tsSystem);
58
+ if (previousSnapshot) {
59
+ newSnapshot.version = previousSnapshot.version + 1;
60
+ }
61
+ else {
62
+ // ensure it's greater than initial version
63
+ // so that ts server picks up the change
64
+ newSnapshot.version += 1;
65
+ }
66
+ this.set(fileName, newSnapshot);
67
+ return newSnapshot;
68
+ }
69
+ }
70
+ onChange(listener) {
71
+ this.emitter.on('change', listener);
72
+ }
73
+ removeChangeListener(listener) {
74
+ this.emitter.off('change', listener);
75
+ }
76
+ }
77
+ exports.GlobalSnapshotsManager = GlobalSnapshotsManager;
78
+ /**
79
+ * Should only be used by `service.ts`
80
+ */
81
+ class SnapshotManager {
82
+ constructor(globalSnapshotsManager, fileSpec, workspaceRoot, tsSystem, projectFiles, wildcardDirectories) {
83
+ this.globalSnapshotsManager = globalSnapshotsManager;
84
+ this.fileSpec = fileSpec;
85
+ this.workspaceRoot = workspaceRoot;
86
+ this.tsSystem = tsSystem;
87
+ this.lastLogged = new Date(new Date().getTime() - 60_001);
88
+ this.watchExtensions = [
89
+ typescript_1.default.Extension.Dts,
90
+ typescript_1.default.Extension.Dcts,
91
+ typescript_1.default.Extension.Dmts,
92
+ typescript_1.default.Extension.Js,
93
+ typescript_1.default.Extension.Cjs,
94
+ typescript_1.default.Extension.Mjs,
95
+ typescript_1.default.Extension.Jsx,
96
+ typescript_1.default.Extension.Ts,
97
+ typescript_1.default.Extension.Mts,
98
+ typescript_1.default.Extension.Cts,
99
+ typescript_1.default.Extension.Tsx,
100
+ typescript_1.default.Extension.Json,
101
+ '.svelte'
102
+ ];
103
+ this.onSnapshotChange = this.onSnapshotChange.bind(this);
104
+ this.globalSnapshotsManager.onChange(this.onSnapshotChange);
105
+ this.documents = new fileCollection_1.FileMap(tsSystem.useCaseSensitiveFileNames);
106
+ this.projectFileToOriginalCasing = new Map();
107
+ this.getCanonicalFileName = (0, utils_1.createGetCanonicalFileName)(tsSystem.useCaseSensitiveFileNames);
108
+ projectFiles.forEach((originalCasing) => this.projectFileToOriginalCasing.set(this.getCanonicalFileName(originalCasing), originalCasing));
109
+ this.watchingCanonicalDirectories = new Map(Object.entries(wildcardDirectories ?? {}).map(([dir, flags]) => [
110
+ this.getCanonicalFileName(dir),
111
+ flags
112
+ ]));
113
+ }
114
+ onSnapshotChange(fileName, document) {
115
+ // Only delete/update snapshots, don't add new ones,
116
+ // as they could be from another TS service and this
117
+ // snapshot manager can't reach this file.
118
+ // For these, instead wait on a `get` method invocation
119
+ // and set them "manually" in the set/update methods.
120
+ if (!document) {
121
+ this.documents.delete(fileName);
122
+ this.projectFileToOriginalCasing.delete(this.getCanonicalFileName(fileName));
123
+ }
124
+ else if (this.documents.has(fileName)) {
125
+ this.documents.set(fileName, document);
126
+ }
127
+ }
128
+ areIgnoredFromNewFileWatch(watcherNewFiles) {
129
+ const { include } = this.fileSpec;
130
+ // Since we default to not include anything,
131
+ // just don't waste time on this
132
+ if (include?.length === 0 || !this.watchingCanonicalDirectories) {
133
+ return true;
134
+ }
135
+ for (const newFile of watcherNewFiles) {
136
+ const path = this.getCanonicalFileName((0, utils_1.normalizePath)(newFile));
137
+ if (this.projectFileToOriginalCasing.has(path)) {
138
+ continue;
139
+ }
140
+ for (const [dir, flags] of this.watchingCanonicalDirectories) {
141
+ if (path.startsWith(dir)) {
142
+ if (!(flags & typescript_1.default.WatchDirectoryFlags.Recursive)) {
143
+ const relative = path.slice(dir.length);
144
+ if (relative.includes('/')) {
145
+ continue;
146
+ }
147
+ }
148
+ return false;
149
+ }
150
+ }
151
+ }
152
+ return true;
153
+ }
154
+ updateProjectFiles() {
155
+ const { include, exclude } = this.fileSpec;
156
+ if (include?.length === 0) {
157
+ return;
158
+ }
159
+ const projectFiles = this.tsSystem
160
+ .readDirectory(this.workspaceRoot, this.watchExtensions, exclude, include)
161
+ .map(utils_1.normalizePath);
162
+ projectFiles.forEach((projectFile) => this.projectFileToOriginalCasing.set(this.getCanonicalFileName(projectFile), projectFile));
163
+ }
164
+ updateTsOrJsFile(fileName, changes) {
165
+ const snapshot = this.globalSnapshotsManager.updateTsOrJsFile(fileName, changes);
166
+ // This isn't duplicated logic to the listener, because this could
167
+ // be a new snapshot which the listener wouldn't add.
168
+ if (snapshot) {
169
+ this.documents.set((0, utils_1.normalizePath)(fileName), snapshot);
170
+ }
171
+ }
172
+ has(fileName) {
173
+ fileName = (0, utils_1.normalizePath)(fileName);
174
+ return (this.projectFileToOriginalCasing.has(this.getCanonicalFileName(fileName)) ||
175
+ this.documents.has(fileName));
176
+ }
177
+ set(fileName, snapshot) {
178
+ this.globalSnapshotsManager.set(fileName, snapshot);
179
+ // This isn't duplicated logic to the listener, because this could
180
+ // be a new snapshot which the listener wouldn't add.
181
+ this.documents.set((0, utils_1.normalizePath)(fileName), snapshot);
182
+ this.logStatistics();
183
+ }
184
+ get(fileName) {
185
+ fileName = (0, utils_1.normalizePath)(fileName);
186
+ let snapshot = this.documents.get(fileName);
187
+ if (!snapshot) {
188
+ snapshot = this.globalSnapshotsManager.get(fileName);
189
+ if (snapshot) {
190
+ this.documents.set(fileName, snapshot);
191
+ }
192
+ }
193
+ return snapshot;
194
+ }
195
+ delete(fileName) {
196
+ fileName = (0, utils_1.normalizePath)(fileName);
197
+ this.globalSnapshotsManager.delete(fileName);
198
+ }
199
+ getClientFileNames() {
200
+ return Array.from(this.documents.values())
201
+ .filter((doc) => doc.isOpenedInClient())
202
+ .map((doc) => doc.filePath);
203
+ }
204
+ getProjectFileNames() {
205
+ return Array.from(this.projectFileToOriginalCasing.values());
206
+ }
207
+ isProjectFile(fileName) {
208
+ fileName = (0, utils_1.normalizePath)(fileName);
209
+ return this.projectFileToOriginalCasing.has(this.getCanonicalFileName(fileName));
210
+ }
211
+ logStatistics() {
212
+ const date = new Date();
213
+ // Don't use setInterval because that will keep tests running forever
214
+ if (date.getTime() - this.lastLogged.getTime() > 60_000) {
215
+ this.lastLogged = date;
216
+ const allFiles = Array.from(new Set([...this.projectFileToOriginalCasing.keys(), ...this.documents.keys()]));
217
+ logger_1.Logger.log('SnapshotManager File Statistics:\n' +
218
+ `Project files: ${this.projectFileToOriginalCasing.size}\n` +
219
+ `Svelte files: ${allFiles.filter((name) => name.endsWith('.svelte')).length}\n` +
220
+ `From node_modules: ${allFiles.filter((name) => name.includes('node_modules')).length}\n` +
221
+ `Total: ${allFiles.length}`);
222
+ }
223
+ }
224
+ allFilesAreJsOrDts() {
225
+ for (const doc of this.documents.values()) {
226
+ if (doc.scriptKind === typescript_1.default.ScriptKind.TS || doc.scriptKind === typescript_1.default.ScriptKind.TSX) {
227
+ return false;
228
+ }
229
+ }
230
+ return true;
231
+ }
232
+ dispose() {
233
+ this.globalSnapshotsManager.removeChangeListener(this.onSnapshotChange);
234
+ }
235
+ }
236
+ exports.SnapshotManager = SnapshotManager;
237
+ exports.ignoredBuildDirectories = ['__sapper__', '.svelte-kit'];
238
+ //# sourceMappingURL=SnapshotManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SnapshotManager.js","sourceRoot":"","sources":["../../../../src/plugins/typescript/SnapshotManager.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4B;AAC5B,yDAA8E;AAC9E,yCAAsC;AAEtC,uCAA8F;AAC9F,mCAAsC;AACtC,uEAA6D;AAI7D;;;;GAIG;AACH,MAAa,sBAAsB;IAK/B,YAA6B,QAAmB;QAAnB,aAAQ,GAAR,QAAQ,CAAW;QAJxC,YAAO,GAAG,IAAI,qBAAY,EAAE,CAAC;QAKjC,IAAI,CAAC,SAAS,GAAG,IAAI,wBAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;QACjE,IAAI,CAAC,oBAAoB,GAAG,IAAA,kCAA0B,EAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IAC/F,CAAC;IAED,GAAG,CAAC,QAAgB;QAChB,QAAQ,GAAG,IAAA,qBAAa,EAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED,WAAW,CAAC,IAAY;QACpB,IAAI,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAA,qBAAa,EAAC,IAAI,CAAC,CAAC,CAAC;QACtD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;aACtC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;aACxC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,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BAAgB,CAAC,CAAC;IAC5E,CAAC;CACJ;AAlND,0CAkNC;AAEY,QAAA,uBAAuB,GAAG,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { CallHierarchyIncomingCall, CallHierarchyItem, CallHierarchyOutgoingCall, CancellationToken, CodeAction, CodeActionContext, CodeLens, CompletionContext, DefinitionLink, Diagnostic, DocumentHighlight, FoldingRange, Hover, InlayHint, Location, Position, Range, ReferenceContext, SelectionRange, SemanticTokens, SignatureHelp, SignatureHelpContext, SymbolInformation, TextDocumentContentChangeEvent, WorkspaceEdit, WorkspaceSymbol } from 'vscode-languageserver';
2
+ import { Document, DocumentManager } from '../../lib/documents';
3
+ import { LSConfigManager } from '../../ls-config';
4
+ import { AppCompletionItem, AppCompletionList, CallHierarchyProvider, CodeActionsProvider, CodeLensProvider, CompletionsProvider, DefinitionsProvider, DiagnosticsProvider, DocumentHighlightProvider, DocumentSymbolsProvider, FileReferencesProvider, FileRename, FindComponentReferencesProvider, FindReferencesProvider, FoldingRangeProvider, HoverProvider, ImplementationProvider, InlayHintProvider, OnWatchFileChanges, OnWatchFileChangesPara, RenameProvider, SelectionRangeProvider, SemanticTokensProvider, SignatureHelpProvider, TypeDefinitionProvider, UpdateImportsProvider, UpdateTsOrJsFile, WorkspaceSymbolsProvider } from '../interfaces';
5
+ import { LSAndTSDocResolver } from './LSAndTSDocResolver';
6
+ import { CompletionResolveInfo } from './features/CompletionProvider';
7
+ export declare class TypeScriptPlugin implements DiagnosticsProvider, HoverProvider, DocumentSymbolsProvider, DefinitionsProvider, CodeActionsProvider, UpdateImportsProvider, RenameProvider, FindReferencesProvider, FileReferencesProvider, FindComponentReferencesProvider, SelectionRangeProvider, SignatureHelpProvider, SemanticTokensProvider, DocumentHighlightProvider, ImplementationProvider, TypeDefinitionProvider, InlayHintProvider, CallHierarchyProvider, FoldingRangeProvider, CodeLensProvider, WorkspaceSymbolsProvider, OnWatchFileChanges, CompletionsProvider<CompletionResolveInfo>, UpdateTsOrJsFile {
8
+ __name: string;
9
+ private readonly configManager;
10
+ private readonly documentManager;
11
+ private readonly lsAndTsDocResolver;
12
+ private readonly completionProvider;
13
+ private readonly codeActionsProvider;
14
+ private readonly updateImportsProvider;
15
+ private readonly diagnosticsProvider;
16
+ private readonly renameProvider;
17
+ private readonly hoverProvider;
18
+ private readonly findReferencesProvider;
19
+ private readonly findFileReferencesProvider;
20
+ private readonly findComponentReferencesProvider;
21
+ private readonly selectionRangeProvider;
22
+ private readonly signatureHelpProvider;
23
+ private readonly semanticTokensProvider;
24
+ private readonly implementationProvider;
25
+ private readonly typeDefinitionProvider;
26
+ private readonly inlayHintProvider;
27
+ private readonly foldingRangeProvider;
28
+ private readonly callHierarchyProvider;
29
+ private readonly codLensProvider;
30
+ private readonly documentHeightProvider;
31
+ private readonly workspaceSymbolsProvider;
32
+ constructor(configManager: LSConfigManager, lsAndTsDocResolver: LSAndTSDocResolver, workspaceUris: string[], documentManager: DocumentManager);
33
+ getDiagnostics(document: Document, cancellationToken?: CancellationToken): Promise<Diagnostic[]>;
34
+ doHover(document: Document, position: Position): Promise<Hover | null>;
35
+ getDocumentSymbols(document: Document, cancellationToken?: CancellationToken): Promise<SymbolInformation[]>;
36
+ getCompletions(document: Document, position: Position, completionContext?: CompletionContext, cancellationToken?: CancellationToken): Promise<AppCompletionList<CompletionResolveInfo> | null>;
37
+ resolveCompletion(document: Document, completionItem: AppCompletionItem<CompletionResolveInfo>, cancellationToken?: CancellationToken): Promise<AppCompletionItem<CompletionResolveInfo>>;
38
+ getDefinitions(document: Document, position: Position): Promise<DefinitionLink[]>;
39
+ prepareRename(document: Document, position: Position): Promise<Range | null>;
40
+ rename(document: Document, position: Position, newName: string): Promise<WorkspaceEdit | null>;
41
+ getCodeActions(document: Document, range: Range, context: CodeActionContext, cancellationToken?: CancellationToken): Promise<CodeAction[]>;
42
+ resolveCodeAction(document: Document, codeAction: CodeAction, cancellationToken?: CancellationToken | undefined): Promise<CodeAction>;
43
+ executeCommand(document: Document, command: string, args?: any[]): Promise<WorkspaceEdit | null>;
44
+ updateImports(fileRename: FileRename): Promise<WorkspaceEdit | null>;
45
+ findReferences(document: Document, position: Position, context: ReferenceContext): Promise<Location[] | null>;
46
+ fileReferences(uri: string): Promise<Location[] | null>;
47
+ findComponentReferences(uri: string): Promise<Location[] | null>;
48
+ onWatchFileChanges(onWatchFileChangesParas: OnWatchFileChangesPara[]): Promise<void>;
49
+ updateTsOrJsFile(fileName: string, changes: TextDocumentContentChangeEvent[]): Promise<void>;
50
+ getSelectionRange(document: Document, position: Position): Promise<SelectionRange | null>;
51
+ getSignatureHelp(document: Document, position: Position, context: SignatureHelpContext | undefined, cancellationToken?: CancellationToken): Promise<SignatureHelp | null>;
52
+ getSemanticTokens(textDocument: Document, range?: Range, cancellationToken?: CancellationToken): Promise<SemanticTokens | null>;
53
+ getImplementation(document: Document, position: Position, cancellationToken?: CancellationToken): Promise<Location[] | null>;
54
+ getTypeDefinition(document: Document, position: Position): Promise<Location[] | null>;
55
+ getInlayHints(document: Document, range: Range, cancellationToken?: CancellationToken): Promise<InlayHint[] | null>;
56
+ prepareCallHierarchy(document: Document, position: Position, cancellationToken?: CancellationToken): Promise<CallHierarchyItem[] | null>;
57
+ getIncomingCalls(item: CallHierarchyItem, cancellationToken?: CancellationToken | undefined): Promise<CallHierarchyIncomingCall[] | null>;
58
+ getOutgoingCalls(item: CallHierarchyItem, cancellationToken?: CancellationToken | undefined): Promise<CallHierarchyOutgoingCall[] | null>;
59
+ getFoldingRanges(document: Document): Promise<FoldingRange[]>;
60
+ getCodeLens(document: Document): Promise<CodeLens[] | null>;
61
+ resolveCodeLens(document: Document, codeLensToResolve: CodeLens, cancellationToken?: CancellationToken): Promise<CodeLens>;
62
+ findDocumentHighlight(document: Document, position: Position): Promise<DocumentHighlight[] | null>;
63
+ getWorkspaceSymbols(query: string, cancellationToken?: CancellationToken): Promise<WorkspaceSymbol[] | null>;
64
+ private featureEnabled;
65
+ }
@@ -0,0 +1,332 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TypeScriptPlugin = void 0;
7
+ const typescript_1 = __importDefault(require("typescript"));
8
+ const vscode_languageserver_1 = require("vscode-languageserver");
9
+ const documents_1 = require("../../lib/documents");
10
+ const utils_1 = require("../../utils");
11
+ const SnapshotManager_1 = require("./SnapshotManager");
12
+ const CodeActionsProvider_1 = require("./features/CodeActionsProvider");
13
+ const CompletionProvider_1 = require("./features/CompletionProvider");
14
+ const DiagnosticsProvider_1 = require("./features/DiagnosticsProvider");
15
+ const FindComponentReferencesProvider_1 = require("./features/FindComponentReferencesProvider");
16
+ const FindFileReferencesProvider_1 = require("./features/FindFileReferencesProvider");
17
+ const FindReferencesProvider_1 = require("./features/FindReferencesProvider");
18
+ const FoldingRangeProvider_1 = require("./features/FoldingRangeProvider");
19
+ const HoverProvider_1 = require("./features/HoverProvider");
20
+ const ImplementationProvider_1 = require("./features/ImplementationProvider");
21
+ const InlayHintProvider_1 = require("./features/InlayHintProvider");
22
+ const RenameProvider_1 = require("./features/RenameProvider");
23
+ const SelectionRangeProvider_1 = require("./features/SelectionRangeProvider");
24
+ const SemanticTokensProvider_1 = require("./features/SemanticTokensProvider");
25
+ const SignatureHelpProvider_1 = require("./features/SignatureHelpProvider");
26
+ const TypeDefinitionProvider_1 = require("./features/TypeDefinitionProvider");
27
+ const UpdateImportsProvider_1 = require("./features/UpdateImportsProvider");
28
+ const getDirectiveCommentCompletions_1 = require("./features/getDirectiveCommentCompletions");
29
+ const utils_2 = require("./features/utils");
30
+ const DocumentHighlightProvider_1 = require("./features/DocumentHighlightProvider");
31
+ const svelte_ast_utils_1 = require("./svelte-ast-utils");
32
+ const utils_3 = require("./utils");
33
+ const CallHierarchyProvider_1 = require("./features/CallHierarchyProvider");
34
+ const CodeLensProvider_1 = require("./features/CodeLensProvider");
35
+ const WorkspaceSymbolProvider_1 = require("./features/WorkspaceSymbolProvider");
36
+ class TypeScriptPlugin {
37
+ constructor(configManager, lsAndTsDocResolver, workspaceUris, documentManager) {
38
+ this.__name = 'ts';
39
+ this.configManager = configManager;
40
+ this.documentManager = documentManager;
41
+ this.lsAndTsDocResolver = lsAndTsDocResolver;
42
+ this.completionProvider = new CompletionProvider_1.CompletionsProviderImpl(this.lsAndTsDocResolver, this.configManager);
43
+ this.codeActionsProvider = new CodeActionsProvider_1.CodeActionsProviderImpl(this.lsAndTsDocResolver, this.completionProvider, configManager);
44
+ this.updateImportsProvider = new UpdateImportsProvider_1.UpdateImportsProviderImpl(this.lsAndTsDocResolver, typescript_1.default.sys.useCaseSensitiveFileNames);
45
+ this.diagnosticsProvider = new DiagnosticsProvider_1.DiagnosticsProviderImpl(this.lsAndTsDocResolver, configManager);
46
+ this.renameProvider = new RenameProvider_1.RenameProviderImpl(this.lsAndTsDocResolver, configManager);
47
+ this.hoverProvider = new HoverProvider_1.HoverProviderImpl(this.lsAndTsDocResolver);
48
+ this.findFileReferencesProvider = new FindFileReferencesProvider_1.FindFileReferencesProviderImpl(this.lsAndTsDocResolver);
49
+ this.findComponentReferencesProvider = new FindComponentReferencesProvider_1.FindComponentReferencesProviderImpl(this.lsAndTsDocResolver);
50
+ this.findReferencesProvider = new FindReferencesProvider_1.FindReferencesProviderImpl(this.lsAndTsDocResolver, this.findComponentReferencesProvider);
51
+ this.selectionRangeProvider = new SelectionRangeProvider_1.SelectionRangeProviderImpl(this.lsAndTsDocResolver);
52
+ this.signatureHelpProvider = new SignatureHelpProvider_1.SignatureHelpProviderImpl(this.lsAndTsDocResolver);
53
+ this.semanticTokensProvider = new SemanticTokensProvider_1.SemanticTokensProviderImpl(this.lsAndTsDocResolver);
54
+ this.implementationProvider = new ImplementationProvider_1.ImplementationProviderImpl(this.lsAndTsDocResolver);
55
+ this.typeDefinitionProvider = new TypeDefinitionProvider_1.TypeDefinitionProviderImpl(this.lsAndTsDocResolver);
56
+ this.inlayHintProvider = new InlayHintProvider_1.InlayHintProviderImpl(this.lsAndTsDocResolver);
57
+ this.callHierarchyProvider = new CallHierarchyProvider_1.CallHierarchyProviderImpl(this.lsAndTsDocResolver, workspaceUris);
58
+ this.foldingRangeProvider = new FoldingRangeProvider_1.FoldingRangeProviderImpl(this.lsAndTsDocResolver, configManager);
59
+ this.codLensProvider = new CodeLensProvider_1.CodeLensProviderImpl(this.lsAndTsDocResolver, this.findReferencesProvider, this.implementationProvider, this.configManager);
60
+ this.documentHeightProvider = new DocumentHighlightProvider_1.DocumentHighlightProviderImpl(this.lsAndTsDocResolver);
61
+ this.workspaceSymbolsProvider = new WorkspaceSymbolProvider_1.WorkspaceSymbolsProviderImpl(this.lsAndTsDocResolver, configManager);
62
+ }
63
+ async getDiagnostics(document, cancellationToken) {
64
+ if (!this.featureEnabled('diagnostics')) {
65
+ return [];
66
+ }
67
+ return this.diagnosticsProvider.getDiagnostics(document, cancellationToken);
68
+ }
69
+ async doHover(document, position) {
70
+ if (!this.featureEnabled('hover')) {
71
+ return null;
72
+ }
73
+ return this.hoverProvider.doHover(document, position);
74
+ }
75
+ async getDocumentSymbols(document, cancellationToken) {
76
+ if (!this.featureEnabled('documentSymbols')) {
77
+ return [];
78
+ }
79
+ const { lang, tsDoc } = await this.lsAndTsDocResolver.getLsForSyntheticOperations(document);
80
+ if (cancellationToken?.isCancellationRequested) {
81
+ return [];
82
+ }
83
+ const navTree = lang.getNavigationTree(tsDoc.filePath);
84
+ const symbols = [];
85
+ collectSymbols(navTree, undefined, (symbol) => symbols.push(symbol));
86
+ const topContainerName = symbols[0].name;
87
+ const result = [];
88
+ for (let symbol of symbols.slice(1)) {
89
+ if (symbol.containerName === topContainerName) {
90
+ symbol.containerName = 'script';
91
+ }
92
+ symbol = (0, documents_1.mapSymbolInformationToOriginal)(tsDoc, symbol);
93
+ if (symbol.location.range.start.line < 0 ||
94
+ symbol.location.range.end.line < 0 ||
95
+ (0, utils_1.isZeroLengthRange)(symbol.location.range) ||
96
+ symbol.name.startsWith('__sveltets_')) {
97
+ continue;
98
+ }
99
+ if ((symbol.kind === vscode_languageserver_1.SymbolKind.Property || symbol.kind === vscode_languageserver_1.SymbolKind.Method) &&
100
+ !(0, utils_3.isInScript)(symbol.location.range.start, document)) {
101
+ if (symbol.name === 'props' &&
102
+ document.getText().charAt(document.offsetAt(symbol.location.range.start)) !==
103
+ 'p') {
104
+ // This is the "props" of a generated component constructor
105
+ continue;
106
+ }
107
+ const node = tsDoc.svelteNodeAt(symbol.location.range.start);
108
+ if ((node && ((0, svelte_ast_utils_1.isAttributeName)(node) || (0, svelte_ast_utils_1.isAttributeShorthand)(node))) ||
109
+ (0, svelte_ast_utils_1.isEventHandler)(node)) {
110
+ // This is a html or component property, they are not treated as a new symbol
111
+ // in JSX and so we do the same for the new transformation.
112
+ continue;
113
+ }
114
+ }
115
+ if (symbol.name === '<function>') {
116
+ let name = (0, documents_1.getTextInRange)(symbol.location.range, document.getText()).trimLeft();
117
+ if (name.length > 50) {
118
+ name = name.substring(0, 50) + '...';
119
+ }
120
+ symbol.name = name;
121
+ }
122
+ if (symbol.name.startsWith('$$_')) {
123
+ if (!symbol.name.includes('$on')) {
124
+ continue;
125
+ }
126
+ // on:foo={() => ''} -> $on("foo") callback
127
+ symbol.name = symbol.name.substring(symbol.name.indexOf('$on'));
128
+ }
129
+ result.push(symbol);
130
+ }
131
+ return result;
132
+ function collectSymbols(tree, container, cb) {
133
+ const start = tree.spans[0];
134
+ const end = tree.spans[tree.spans.length - 1];
135
+ if (start && end) {
136
+ cb(vscode_languageserver_1.SymbolInformation.create(tree.text, (0, utils_3.symbolKindFromString)(tree.kind), vscode_languageserver_1.Range.create(tsDoc.positionAt(start.start), tsDoc.positionAt(end.start + end.length)), tsDoc.getURL(), container));
137
+ }
138
+ if (tree.childItems) {
139
+ for (const child of tree.childItems) {
140
+ collectSymbols(child, tree.text, cb);
141
+ }
142
+ }
143
+ }
144
+ }
145
+ async getCompletions(document, position, completionContext, cancellationToken) {
146
+ if (!this.featureEnabled('completions')) {
147
+ return null;
148
+ }
149
+ const tsDirectiveCommentCompletions = (0, getDirectiveCommentCompletions_1.getDirectiveCommentCompletions)(position, document, completionContext);
150
+ const completions = await this.completionProvider.getCompletions(document, position, completionContext, cancellationToken);
151
+ if (completions && tsDirectiveCommentCompletions) {
152
+ return vscode_languageserver_1.CompletionList.create(completions.items.concat(tsDirectiveCommentCompletions.items), completions.isIncomplete);
153
+ }
154
+ return completions ?? tsDirectiveCommentCompletions;
155
+ }
156
+ async resolveCompletion(document, completionItem, cancellationToken) {
157
+ return this.completionProvider.resolveCompletion(document, completionItem, cancellationToken);
158
+ }
159
+ async getDefinitions(document, position) {
160
+ const { lang, tsDoc, lsContainer } = await this.lsAndTsDocResolver.getLSAndTSDoc(document);
161
+ const defs = lang.getDefinitionAndBoundSpan(tsDoc.filePath, tsDoc.offsetAt(tsDoc.getGeneratedPosition(position)));
162
+ if (!defs || !defs.definitions) {
163
+ return [];
164
+ }
165
+ const snapshots = new utils_2.SnapshotMap(this.lsAndTsDocResolver, lsContainer);
166
+ snapshots.set(tsDoc.filePath, tsDoc);
167
+ const result = await Promise.all(defs.definitions.map(async (def) => {
168
+ if ((0, utils_3.isSvelte2tsxShimFile)(def.fileName)) {
169
+ return;
170
+ }
171
+ let snapshot = await snapshots.retrieve(def.fileName);
172
+ // Go from generated $store to store if user wants to find definition for $store
173
+ if ((0, utils_2.isTextSpanInGeneratedCode)(snapshot.getFullText(), def.textSpan)) {
174
+ if (!(0, utils_2.is$storeVariableIn$storeDeclaration)(snapshot.getFullText(), def.textSpan.start)) {
175
+ return;
176
+ }
177
+ // there will be exactly one definition, the store
178
+ def = lang.getDefinitionAndBoundSpan(tsDoc.filePath, tsDoc.getFullText().indexOf(');', def.textSpan.start) - 1).definitions[0];
179
+ snapshot = await snapshots.retrieve(def.fileName);
180
+ }
181
+ const defLocation = (0, utils_3.convertToLocationForReferenceOrDefinition)(snapshot, def.textSpan);
182
+ return vscode_languageserver_1.LocationLink.create(defLocation.uri, defLocation.range, defLocation.range, (0, utils_3.convertToLocationRange)(tsDoc, defs.textSpan));
183
+ }));
184
+ return result.filter(utils_1.isNotNullOrUndefined);
185
+ }
186
+ async prepareRename(document, position) {
187
+ return this.renameProvider.prepareRename(document, position);
188
+ }
189
+ async rename(document, position, newName) {
190
+ return this.renameProvider.rename(document, position, newName);
191
+ }
192
+ async getCodeActions(document, range, context, cancellationToken) {
193
+ if (!this.featureEnabled('codeActions')) {
194
+ return [];
195
+ }
196
+ return this.codeActionsProvider.getCodeActions(document, range, context, cancellationToken);
197
+ }
198
+ async resolveCodeAction(document, codeAction, cancellationToken) {
199
+ return this.codeActionsProvider.resolveCodeAction(document, codeAction, cancellationToken);
200
+ }
201
+ async executeCommand(document, command, args) {
202
+ if (!this.featureEnabled('codeActions')) {
203
+ return null;
204
+ }
205
+ return this.codeActionsProvider.executeCommand(document, command, args);
206
+ }
207
+ async updateImports(fileRename) {
208
+ if (!(this.configManager.enabled('svelte.enable') &&
209
+ this.configManager.enabled('svelte.rename.enable'))) {
210
+ return null;
211
+ }
212
+ return this.updateImportsProvider.updateImports(fileRename);
213
+ }
214
+ async findReferences(document, position, context) {
215
+ return this.findReferencesProvider.findReferences(document, position, context);
216
+ }
217
+ async fileReferences(uri) {
218
+ return this.findFileReferencesProvider.fileReferences(uri);
219
+ }
220
+ async findComponentReferences(uri) {
221
+ return this.findComponentReferencesProvider.findComponentReferences(uri);
222
+ }
223
+ async onWatchFileChanges(onWatchFileChangesParas) {
224
+ const newFiles = [];
225
+ for (const { fileName, changeType } of onWatchFileChangesParas) {
226
+ const pathParts = fileName.split(/\/|\\/);
227
+ const dirPathParts = pathParts.slice(0, pathParts.length - 1);
228
+ const declarationExtensions = [typescript_1.default.Extension.Dcts, typescript_1.default.Extension.Dts, typescript_1.default.Extension.Dmts];
229
+ const canSafelyIgnore = declarationExtensions.every((ext) => !fileName.endsWith(ext)) &&
230
+ SnapshotManager_1.ignoredBuildDirectories.some((dir) => {
231
+ const index = dirPathParts.indexOf(dir);
232
+ return (
233
+ // Files in .svelte-kit/types should always come through
234
+ index > 0 && (dir !== '.svelte-kit' || dirPathParts[index + 1] !== 'types'));
235
+ });
236
+ if (canSafelyIgnore) {
237
+ continue;
238
+ }
239
+ const isSvelteFile = (0, utils_3.isSvelteFilePath)(fileName);
240
+ const isClientSvelteFile = isSvelteFile && this.documentManager.get((0, utils_1.pathToUrl)(fileName))?.openedByClient;
241
+ if (changeType === vscode_languageserver_1.FileChangeType.Deleted) {
242
+ if (!isClientSvelteFile) {
243
+ await this.lsAndTsDocResolver.deleteSnapshot(fileName);
244
+ }
245
+ continue;
246
+ }
247
+ if (changeType === vscode_languageserver_1.FileChangeType.Created) {
248
+ newFiles.push(fileName);
249
+ continue;
250
+ }
251
+ if (isSvelteFile) {
252
+ if (!isClientSvelteFile) {
253
+ await this.lsAndTsDocResolver.updateExistingSvelteFile(fileName);
254
+ }
255
+ continue;
256
+ }
257
+ await this.lsAndTsDocResolver.updateExistingTsOrJsFile(fileName);
258
+ }
259
+ if (newFiles.length) {
260
+ await this.lsAndTsDocResolver.updateProjectFiles(newFiles);
261
+ await this.lsAndTsDocResolver.invalidateModuleCache(newFiles);
262
+ }
263
+ }
264
+ async updateTsOrJsFile(fileName, changes) {
265
+ await this.lsAndTsDocResolver.updateExistingTsOrJsFile(fileName, changes);
266
+ }
267
+ async getSelectionRange(document, position) {
268
+ if (!this.featureEnabled('selectionRange')) {
269
+ return null;
270
+ }
271
+ return this.selectionRangeProvider.getSelectionRange(document, position);
272
+ }
273
+ async getSignatureHelp(document, position, context, cancellationToken) {
274
+ if (!this.featureEnabled('signatureHelp')) {
275
+ return null;
276
+ }
277
+ return this.signatureHelpProvider.getSignatureHelp(document, position, context, cancellationToken);
278
+ }
279
+ async getSemanticTokens(textDocument, range, cancellationToken) {
280
+ if (!this.featureEnabled('semanticTokens')) {
281
+ return {
282
+ data: []
283
+ };
284
+ }
285
+ return this.semanticTokensProvider.getSemanticTokens(textDocument, range, cancellationToken);
286
+ }
287
+ async getImplementation(document, position, cancellationToken) {
288
+ return this.implementationProvider.getImplementation(document, position, cancellationToken);
289
+ }
290
+ async getTypeDefinition(document, position) {
291
+ return this.typeDefinitionProvider.getTypeDefinition(document, position);
292
+ }
293
+ async getInlayHints(document, range, cancellationToken) {
294
+ if (!this.configManager.enabled('typescript.enable')) {
295
+ return null;
296
+ }
297
+ return this.inlayHintProvider.getInlayHints(document, range, cancellationToken);
298
+ }
299
+ prepareCallHierarchy(document, position, cancellationToken) {
300
+ return this.callHierarchyProvider.prepareCallHierarchy(document, position, cancellationToken);
301
+ }
302
+ getIncomingCalls(item, cancellationToken) {
303
+ return this.callHierarchyProvider.getIncomingCalls(item, cancellationToken);
304
+ }
305
+ async getOutgoingCalls(item, cancellationToken) {
306
+ return this.callHierarchyProvider.getOutgoingCalls(item, cancellationToken);
307
+ }
308
+ async getFoldingRanges(document) {
309
+ return this.foldingRangeProvider.getFoldingRanges(document);
310
+ }
311
+ getCodeLens(document) {
312
+ return this.codLensProvider.getCodeLens(document);
313
+ }
314
+ resolveCodeLens(document, codeLensToResolve, cancellationToken) {
315
+ return this.codLensProvider.resolveCodeLens(document, codeLensToResolve, cancellationToken);
316
+ }
317
+ async findDocumentHighlight(document, position) {
318
+ return this.documentHeightProvider.findDocumentHighlight(document, position);
319
+ }
320
+ async getWorkspaceSymbols(query, cancellationToken) {
321
+ if (!this.featureEnabled('workspaceSymbols')) {
322
+ return null;
323
+ }
324
+ return this.workspaceSymbolsProvider.getWorkspaceSymbols(query, cancellationToken);
325
+ }
326
+ featureEnabled(feature) {
327
+ return (this.configManager.enabled('typescript.enable') &&
328
+ this.configManager.enabled(`typescript.${feature}.enable`));
329
+ }
330
+ }
331
+ exports.TypeScriptPlugin = TypeScriptPlugin;
332
+ //# sourceMappingURL=TypeScriptPlugin.js.map