typescript-svelte-plugin 0.3.33 → 0.3.35
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/README.md +4 -1
- package/dist/src/config-manager.d.ts +2 -0
- package/dist/src/config-manager.js +2 -1
- package/dist/src/index.js +2 -1
- package/dist/src/language-service/file-references.d.ts +3 -0
- package/dist/src/language-service/file-references.js +27 -0
- package/dist/src/language-service/index.js +4 -0
- package/dist/src/language-service/navigate-to-items.d.ts +3 -0
- package/dist/src/language-service/navigate-to-items.js +38 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,10 @@ Then add it to your `tsconfig.json` or `jsconfig.json`:
|
|
|
24
24
|
"compilerOptions": {
|
|
25
25
|
...
|
|
26
26
|
"plugins": [{
|
|
27
|
-
"name": "typescript-svelte-plugin"
|
|
27
|
+
"name": "typescript-svelte-plugin",
|
|
28
|
+
// the following options can be set additionally; they are optional; their default values are listed here
|
|
29
|
+
"enabled": true, // enables this plugin
|
|
30
|
+
"assumeIsSvelteProject": false // if true, skip detection and always assume it's a Svelte project
|
|
28
31
|
}]
|
|
29
32
|
}
|
|
30
33
|
}
|
package/dist/src/index.js
CHANGED
|
@@ -12,7 +12,8 @@ function init(modules) {
|
|
|
12
12
|
let resolvedSvelteTsxFiles;
|
|
13
13
|
function create(info) {
|
|
14
14
|
const logger = new logger_1.Logger(info.project.projectService.logger);
|
|
15
|
-
if (!
|
|
15
|
+
if (!info.config?.assumeIsSvelteProject &&
|
|
16
|
+
!isSvelteProject(info.project.getCompilerOptions())) {
|
|
16
17
|
logger.log('Detected that this is not a Svelte project, abort patching TypeScript');
|
|
17
18
|
return info.languageService;
|
|
18
19
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decorateFileReferences = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
function decorateFileReferences(ls, snapshotManager) {
|
|
6
|
+
const getFileReferences = ls.getFileReferences;
|
|
7
|
+
ls.getFileReferences = (fileName) => {
|
|
8
|
+
const references = getFileReferences(fileName);
|
|
9
|
+
return references
|
|
10
|
+
.map((ref) => {
|
|
11
|
+
if (!(0, utils_1.isSvelteFilePath)(ref.fileName)) {
|
|
12
|
+
return ref;
|
|
13
|
+
}
|
|
14
|
+
let textSpan = snapshotManager.get(ref.fileName)?.getOriginalTextSpan(ref.textSpan);
|
|
15
|
+
if (!textSpan) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
...ref,
|
|
20
|
+
textSpan
|
|
21
|
+
};
|
|
22
|
+
})
|
|
23
|
+
.filter(utils_1.isNotNullOrUndefined);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.decorateFileReferences = decorateFileReferences;
|
|
27
|
+
//# sourceMappingURL=file-references.js.map
|
|
@@ -13,6 +13,8 @@ const inlay_hints_1 = require("./inlay-hints");
|
|
|
13
13
|
const rename_1 = require("./rename");
|
|
14
14
|
const update_imports_1 = require("./update-imports");
|
|
15
15
|
const host_1 = require("./host");
|
|
16
|
+
const navigate_to_items_1 = require("./navigate-to-items");
|
|
17
|
+
const file_references_1 = require("./file-references");
|
|
16
18
|
const patchedProject = new Set();
|
|
17
19
|
function isPatched(project) {
|
|
18
20
|
return patchedProject.has(project.getProjectName());
|
|
@@ -40,6 +42,8 @@ function decorateLanguageServiceInner(ls, snapshotManager, logger, info, typescr
|
|
|
40
42
|
(0, call_hierarchy_1.decorateCallHierarchy)(ls, snapshotManager, typescript);
|
|
41
43
|
(0, hover_1.decorateHover)(ls, info, typescript, logger);
|
|
42
44
|
(0, inlay_hints_1.decorateInlayHints)(ls, info, typescript, logger);
|
|
45
|
+
(0, navigate_to_items_1.decorateNavigateToItems)(ls, snapshotManager);
|
|
46
|
+
(0, file_references_1.decorateFileReferences)(ls, snapshotManager);
|
|
43
47
|
decorateDispose(ls, info.project, onDispose);
|
|
44
48
|
return ls;
|
|
45
49
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decorateNavigateToItems = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
function decorateNavigateToItems(ls, snapshotManager) {
|
|
6
|
+
const getNavigateToItems = ls.getNavigateToItems;
|
|
7
|
+
ls.getNavigateToItems = (searchValue, maxResultCount, fileName, excludeDtsFiles) => {
|
|
8
|
+
const navigationToItems = getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles);
|
|
9
|
+
return navigationToItems
|
|
10
|
+
.map((item) => {
|
|
11
|
+
if (!(0, utils_1.isSvelteFilePath)(item.fileName)) {
|
|
12
|
+
return item;
|
|
13
|
+
}
|
|
14
|
+
if (item.name.startsWith('__sveltets_') ||
|
|
15
|
+
(item.name === 'render' && !item.containerName)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
let textSpan = snapshotManager
|
|
19
|
+
.get(item.fileName)
|
|
20
|
+
?.getOriginalTextSpan(item.textSpan);
|
|
21
|
+
if (!textSpan) {
|
|
22
|
+
if ((0, utils_1.isGeneratedSvelteComponentName)(item.name)) {
|
|
23
|
+
textSpan = { start: 0, length: 1 };
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
...item,
|
|
31
|
+
textSpan
|
|
32
|
+
};
|
|
33
|
+
})
|
|
34
|
+
.filter(utils_1.isNotNullOrUndefined);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.decorateNavigateToItems = decorateNavigateToItems;
|
|
38
|
+
//# sourceMappingURL=navigate-to-items.js.map
|