@platformos/platformos-language-server-common 0.0.7 → 0.0.9
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/CHANGELOG.md +20 -0
- package/dist/PropertyShapeInference.d.ts +18 -0
- package/dist/PropertyShapeInference.js +62 -0
- package/dist/PropertyShapeInference.js.map +1 -1
- package/dist/TypeSystem.d.ts +4 -9
- package/dist/TypeSystem.js +246 -390
- package/dist/TypeSystem.js.map +1 -1
- package/dist/codeActions/providers/GenerateDocBlockProvider.d.ts +10 -0
- package/dist/codeActions/providers/GenerateDocBlockProvider.js +39 -0
- package/dist/codeActions/providers/GenerateDocBlockProvider.js.map +1 -0
- package/dist/commands/providers/GenerateDocBlockCommandProvider.d.ts +19 -0
- package/dist/commands/providers/GenerateDocBlockCommandProvider.js +64 -0
- package/dist/commands/providers/GenerateDocBlockCommandProvider.js.map +1 -0
- package/dist/completions/CompletionsProvider.d.ts +6 -10
- package/dist/completions/CompletionsProvider.js +6 -9
- package/dist/completions/CompletionsProvider.js.map +1 -1
- package/dist/completions/params/LiquidCompletionParams.js +6 -17
- package/dist/completions/params/LiquidCompletionParams.js.map +1 -1
- package/dist/completions/providers/ContentForCompletionProvider.js +2 -4
- package/dist/completions/providers/ContentForCompletionProvider.js.map +1 -1
- package/dist/completions/providers/FilterNamedParameterCompletionProvider.d.ts +3 -3
- package/dist/completions/providers/FilterNamedParameterCompletionProvider.js +6 -6
- package/dist/completions/providers/FilterNamedParameterCompletionProvider.js.map +1 -1
- package/dist/completions/providers/LiquidDocParamTypeCompletionProvider.d.ts +3 -3
- package/dist/completions/providers/LiquidDocParamTypeCompletionProvider.js +3 -3
- package/dist/completions/providers/LiquidDocParamTypeCompletionProvider.js.map +1 -1
- package/dist/completions/providers/LiquidTagsCompletionProvider.d.ts +3 -3
- package/dist/completions/providers/LiquidTagsCompletionProvider.js +3 -3
- package/dist/completions/providers/LiquidTagsCompletionProvider.js.map +1 -1
- package/dist/completions/providers/RenderPartialParameterCompletionProvider.js +1 -1
- package/dist/completions/providers/RenderPartialParameterCompletionProvider.js.map +1 -1
- package/dist/completions/providers/index.d.ts +0 -3
- package/dist/completions/providers/index.js +1 -7
- package/dist/completions/providers/index.js.map +1 -1
- package/dist/css/CSSLanguageService.d.ts +19 -5
- package/dist/css/CSSLanguageService.js +77 -63
- package/dist/css/CSSLanguageService.js.map +1 -1
- package/dist/definitions/DefinitionProvider.d.ts +1 -1
- package/dist/definitions/DefinitionProvider.js +1 -3
- package/dist/definitions/DefinitionProvider.js.map +1 -1
- package/dist/diagnostics/offenseToDiagnostic.js +1 -1
- package/dist/diagnostics/offenseToDiagnostic.js.map +1 -1
- package/dist/diagnostics/runChecks.d.ts +3 -5
- package/dist/diagnostics/runChecks.js +12 -64
- package/dist/diagnostics/runChecks.js.map +1 -1
- package/dist/docset/MarkdownRenderer.js +1 -1
- package/dist/docset/MarkdownRenderer.js.map +1 -1
- package/dist/documentLinks/DocumentLinksProvider.d.ts +3 -3
- package/dist/documentLinks/DocumentLinksProvider.js +3 -3
- package/dist/documentLinks/DocumentLinksProvider.js.map +1 -1
- package/dist/documents/DocumentManager.d.ts +4 -5
- package/dist/documents/DocumentManager.js +17 -12
- package/dist/documents/DocumentManager.js.map +1 -1
- package/dist/documents/types.d.ts +16 -3
- package/dist/documents/types.js +3 -3
- package/dist/documents/types.js.map +1 -1
- package/dist/hover/HoverProvider.d.ts +5 -8
- package/dist/hover/HoverProvider.js +8 -14
- package/dist/hover/HoverProvider.js.map +1 -1
- package/dist/hover/providers/LiquidFilterArgumentHoverProvider.d.ts +3 -3
- package/dist/hover/providers/LiquidFilterArgumentHoverProvider.js +3 -3
- package/dist/hover/providers/LiquidFilterArgumentHoverProvider.js.map +1 -1
- package/dist/hover/providers/LiquidFilterHoverProvider.d.ts +3 -3
- package/dist/hover/providers/LiquidFilterHoverProvider.js +3 -3
- package/dist/hover/providers/LiquidFilterHoverProvider.js.map +1 -1
- package/dist/hover/providers/LiquidTagHoverProvider.d.ts +3 -3
- package/dist/hover/providers/LiquidTagHoverProvider.js +3 -3
- package/dist/hover/providers/LiquidTagHoverProvider.js.map +1 -1
- package/dist/hover/providers/RenderPartialHoverProvider.js +1 -1
- package/dist/hover/providers/RenderPartialHoverProvider.js.map +1 -1
- package/dist/hover/providers/RenderPartialParameterHoverProvider.js +1 -1
- package/dist/hover/providers/RenderPartialParameterHoverProvider.js.map +1 -1
- package/dist/hover/providers/TranslationHoverProvider.d.ts +3 -3
- package/dist/hover/providers/TranslationHoverProvider.js +3 -3
- package/dist/hover/providers/TranslationHoverProvider.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal-types.d.ts +1 -1
- package/dist/json/JSONContributions.d.ts +1 -5
- package/dist/json/JSONContributions.js +4 -36
- package/dist/json/JSONContributions.js.map +1 -1
- package/dist/json/JSONLanguageService.d.ts +4 -12
- package/dist/json/JSONLanguageService.js +17 -80
- package/dist/json/JSONLanguageService.js.map +1 -1
- package/dist/json/test/test-helpers.d.ts +1 -3
- package/dist/json/test/test-helpers.js +3 -19
- package/dist/json/test/test-helpers.js.map +1 -1
- package/dist/json/utils.d.ts +0 -5
- package/dist/json/utils.js +0 -24
- package/dist/json/utils.js.map +1 -1
- package/dist/rename/RenameProvider.d.ts +2 -2
- package/dist/rename/RenameProvider.js +2 -2
- package/dist/rename/RenameProvider.js.map +1 -1
- package/dist/rename/providers/LiquidVariableRenameProvider.d.ts +3 -3
- package/dist/rename/providers/LiquidVariableRenameProvider.js +4 -4
- package/dist/rename/providers/LiquidVariableRenameProvider.js.map +1 -1
- package/dist/renamed/RenameHandler.d.ts +2 -3
- package/dist/renamed/RenameHandler.js +3 -8
- package/dist/renamed/RenameHandler.js.map +1 -1
- package/dist/renamed/handlers/AssetRenameHandler.d.ts +3 -3
- package/dist/renamed/handlers/AssetRenameHandler.js +5 -5
- package/dist/renamed/handlers/AssetRenameHandler.js.map +1 -1
- package/dist/renamed/handlers/PartialRenameHandler.d.ts +3 -3
- package/dist/renamed/handlers/PartialRenameHandler.js +5 -5
- package/dist/renamed/handlers/PartialRenameHandler.js.map +1 -1
- package/dist/renamed/handlers/utils.d.ts +1 -1
- package/dist/server/AppGraphManager.d.ts +32 -0
- package/dist/server/AppGraphManager.js +155 -0
- package/dist/server/AppGraphManager.js.map +1 -0
- package/dist/server/startServer.d.ts +2 -2
- package/dist/server/startServer.js +62 -164
- package/dist/server/startServer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +33 -54
- package/dist/types.js +21 -26
- package/dist/types.js.map +1 -1
- package/dist/utils/liquidDoc.js +1 -1
- package/dist/utils/liquidDoc.js.map +1 -1
- package/dist/utils/uri.d.ts +2 -9
- package/dist/utils/uri.js +5 -21
- package/dist/utils/uri.js.map +1 -1
- package/package.json +4 -4
- package/src/ClientCapabilities.ts +1 -1
- package/src/PropertyShapeInference.ts +81 -1
- package/src/TypeSystem.spec.ts +206 -449
- package/src/TypeSystem.ts +267 -460
- package/src/codeActions/providers/FixAllProvider.spec.ts +1 -1
- package/src/codeActions/providers/FixProvider.spec.ts +11 -11
- package/src/codeActions/providers/SuggestionProvider.spec.ts +2 -2
- package/src/commands/providers/ApplyFixesProvider.ts +2 -2
- package/src/commands/providers/ApplySuggestionProvider.ts +2 -2
- package/src/commands/providers/RunChecksProvider.ts +2 -2
- package/src/completions/CompletionsProvider.ts +14 -35
- package/src/completions/params/LiquidCompletionParams.spec.ts +0 -9
- package/src/completions/params/LiquidCompletionParams.ts +8 -17
- package/src/completions/params/fix.spec.ts +0 -3
- package/src/completions/providers/FilterCompletionProvider.spec.ts +2 -8
- package/src/completions/providers/FilterNamedParameterCompletionProvider.spec.ts +1 -5
- package/src/completions/providers/FilterNamedParameterCompletionProvider.ts +6 -6
- package/src/completions/providers/HtmlAttributeCompletionProvider.spec.ts +1 -4
- package/src/completions/providers/HtmlAttributeValueCompletionProvider.spec.ts +1 -4
- package/src/completions/providers/HtmlTagCompletionProvider.spec.ts +1 -4
- package/src/completions/providers/LiquidDocParamTypeCompletionProvider.spec.ts +1 -28
- package/src/completions/providers/LiquidDocParamTypeCompletionProvider.ts +3 -3
- package/src/completions/providers/LiquidDocTagCompletionProvider.spec.ts +1 -26
- package/src/completions/providers/LiquidTagsCompletionProvider.spec.ts +4 -18
- package/src/completions/providers/LiquidTagsCompletionProvider.ts +3 -3
- package/src/completions/providers/ObjectAttributeCompletionProvider.spec.ts +2 -31
- package/src/completions/providers/ObjectCompletionProvider.spec.ts +34 -123
- package/src/completions/providers/PartialCompletionProvider.spec.ts +6 -15
- package/src/completions/providers/RenderPartialParameterCompletionProvider.spec.ts +13 -15
- package/src/completions/providers/RenderPartialParameterCompletionProvider.ts +2 -3
- package/src/completions/providers/TranslationCompletionProvider.spec.ts +1 -4
- package/src/completions/providers/TranslationCompletionProvider.ts +3 -3
- package/src/completions/providers/index.ts +0 -3
- package/src/css/CSSLanguageService.ts +97 -81
- package/src/definitions/DefinitionProvider.ts +0 -6
- package/src/definitions/providers/TranslationStringDefinitionProvider.spec.ts +1 -5
- package/src/diagnostics/offenseToDiagnostic.ts +1 -1
- package/src/diagnostics/runChecks.spec.ts +22 -30
- package/src/diagnostics/runChecks.ts +17 -91
- package/src/docset/MarkdownRenderer.ts +1 -1
- package/src/documentLinks/DocumentLinksProvider.ts +10 -10
- package/src/documents/DocumentManager.spec.ts +46 -119
- package/src/documents/DocumentManager.ts +19 -15
- package/src/documents/types.ts +18 -9
- package/src/hover/HoverProvider.ts +9 -21
- package/src/hover/providers/HtmlAttributeHoverProvider.spec.ts +1 -3
- package/src/hover/providers/HtmlAttributeValueHoverProvider.spec.ts +1 -3
- package/src/hover/providers/HtmlTagHoverProvider.spec.ts +1 -3
- package/src/hover/providers/LiquidDocTagHoverProvider.spec.ts +1 -4
- package/src/hover/providers/LiquidFilterArgumentHoverProvider.spec.ts +0 -3
- package/src/hover/providers/LiquidFilterArgumentHoverProvider.ts +3 -3
- package/src/hover/providers/LiquidFilterHoverProvider.spec.ts +0 -3
- package/src/hover/providers/LiquidFilterHoverProvider.ts +3 -3
- package/src/hover/providers/LiquidObjectAttributeHoverProvider.spec.ts +1 -3
- package/src/hover/providers/LiquidObjectHoverProvider.spec.ts +46 -129
- package/src/hover/providers/LiquidTagHoverProvider.spec.ts +0 -3
- package/src/hover/providers/LiquidTagHoverProvider.ts +3 -3
- package/src/hover/providers/RenderPartialHoverProvider.spec.ts +11 -14
- package/src/hover/providers/RenderPartialHoverProvider.ts +1 -5
- package/src/hover/providers/RenderPartialParameterHoverProvider.spec.ts +10 -13
- package/src/hover/providers/RenderPartialParameterHoverProvider.ts +2 -3
- package/src/hover/providers/TranslationHoverProvider.spec.ts +1 -4
- package/src/hover/providers/TranslationHoverProvider.ts +3 -3
- package/src/index.ts +4 -7
- package/src/internal-types.ts +1 -1
- package/src/json/JSONContributions.ts +4 -61
- package/src/json/JSONLanguageService.ts +19 -117
- package/src/json/test/test-helpers.ts +4 -35
- package/src/json/utils.ts +0 -27
- package/src/rename/RenameProvider.ts +4 -4
- package/src/rename/providers/LiquidVariableRenameProvider.spec.ts +5 -5
- package/src/rename/providers/LiquidVariableRenameProvider.ts +6 -6
- package/src/renamed/RenameHandler.ts +4 -9
- package/src/renamed/handlers/AssetRenameHandler.spec.ts +28 -28
- package/src/renamed/handlers/AssetRenameHandler.ts +6 -6
- package/src/renamed/handlers/PartialRenameHandler.spec.ts +9 -9
- package/src/renamed/handlers/PartialRenameHandler.ts +10 -10
- package/src/server/{ThemeGraphManager.ts → AppGraphManager.ts} +21 -90
- package/src/server/safe.ts +1 -1
- package/src/server/startServer.spec.ts +10 -12
- package/src/server/startServer.ts +69 -222
- package/src/test/CompletionItemsAssertion.spec.ts +1 -4
- package/src/types.ts +33 -63
- package/src/utils/debounce.ts +1 -1
- package/src/utils/liquidDoc.ts +6 -6
- package/src/utils/uri.ts +5 -17
- package/src/completions/providers/ContentForBlockTypeCompletionProvider.spec.ts +0 -41
- package/src/completions/providers/ContentForBlockTypeCompletionProvider.ts +0 -42
- package/src/completions/providers/ContentForCompletionProvider.spec.ts +0 -96
- package/src/completions/providers/ContentForCompletionProvider.ts +0 -113
- package/src/completions/providers/ContentForParameterCompletionProvider.spec.ts +0 -362
- package/src/completions/providers/ContentForParameterCompletionProvider.ts +0 -187
- package/src/completions/providers/data/contentForParameterCompletionOptions.ts +0 -9
- package/src/css/CSSLanguageService.spec.ts +0 -159
- package/src/css/test/test-helpers.ts +0 -30
- package/src/definitions/providers/SchemaTranslationStringDefinitionProvider.spec.ts +0 -96
- package/src/definitions/providers/SchemaTranslationStringDefinitionProvider.ts +0 -82
- package/src/hover/providers/ContentForArgumentHoverProvider.spec.ts +0 -76
- package/src/hover/providers/ContentForArgumentHoverProvider.ts +0 -56
- package/src/hover/providers/ContentForTypeHoverProvider.spec.ts +0 -91
- package/src/hover/providers/ContentForTypeHoverProvider.ts +0 -42
- package/src/json/JSONLanguageService.spec.ts +0 -424
- package/src/json/completions/providers/BlockSettingsPropertyCompletionProvider.spec.ts +0 -163
- package/src/json/completions/providers/BlockSettingsPropertyCompletionProvider.ts +0 -121
- package/src/json/completions/providers/BlockTypeCompletionProvider.spec.ts +0 -137
- package/src/json/completions/providers/BlockTypeCompletionProvider.ts +0 -108
- package/src/json/completions/providers/ReferencedBlockTypeCompletionProvider.spec.ts +0 -132
- package/src/json/completions/providers/ReferencedBlockTypeCompletionProvider.ts +0 -120
- package/src/json/completions/providers/SchemaTranslationCompletionProvider.ts +0 -51
- package/src/json/completions/providers/SettingsPropertyCompletionProvider.spec.ts +0 -211
- package/src/json/completions/providers/SettingsPropertyCompletionProvider.ts +0 -75
- package/src/json/documentLinks/DocumentLinksProvider.spec.ts +0 -223
- package/src/json/documentLinks/DocumentLinksProvider.ts +0 -61
- package/src/json/hover/providers/BlockSettingsHoverProvider.spec.ts +0 -292
- package/src/json/hover/providers/BlockSettingsHoverProvider.ts +0 -99
- package/src/json/hover/providers/SchemaTranslationHoverProvider.ts +0 -35
- package/src/json/hover/providers/SettingsHoverProvider.spec.ts +0 -139
- package/src/json/hover/providers/SettingsHoverProvider.ts +0 -79
- package/src/json/schemaSettings.spec.ts +0 -103
- package/src/json/schemaSettings.ts +0 -53
- package/src/plugins/css.ts +0 -12
- package/src/renamed/handlers/BlockRenameHandler.spec.ts +0 -399
- package/src/renamed/handlers/BlockRenameHandler.ts +0 -402
- package/src/renamed/handlers/SectionRenameHandler.spec.ts +0 -321
- package/src/renamed/handlers/SectionRenameHandler.ts +0 -224
- package/src/renamed/handlers/utils.ts +0 -22
- package/src/settings/index.ts +0 -50
|
@@ -10,7 +10,7 @@ import { RenameHandler } from '../RenameHandler';
|
|
|
10
10
|
|
|
11
11
|
describe('Module: AssetRenameHandler', () => {
|
|
12
12
|
const mockRoot = 'mock-fs:';
|
|
13
|
-
const
|
|
13
|
+
const findAppRootURI = async () => mockRoot;
|
|
14
14
|
let capabilities: ClientCapabilities;
|
|
15
15
|
let documentManager: DocumentManager;
|
|
16
16
|
let handler: RenameHandler;
|
|
@@ -22,14 +22,14 @@ describe('Module: AssetRenameHandler', () => {
|
|
|
22
22
|
capabilities = new ClientCapabilities();
|
|
23
23
|
fs = new MockFileSystem(
|
|
24
24
|
{
|
|
25
|
-
'assets/oldName.js': 'console.log("Hello, world!")',
|
|
26
|
-
'
|
|
27
|
-
'
|
|
25
|
+
'app/assets/oldName.js': 'console.log("Hello, world!")',
|
|
26
|
+
'app/views/partials/section.liquid': `<script src="{{ 'oldName.js' | asset_url }}" defer></script>`,
|
|
27
|
+
'app/views/partials/block.liquid': `{{ 'oldName.js' | asset_url | script_tag }} oldName.js`,
|
|
28
28
|
},
|
|
29
29
|
mockRoot,
|
|
30
30
|
);
|
|
31
31
|
documentManager = new DocumentManager(fs);
|
|
32
|
-
handler = new RenameHandler(connection, capabilities, documentManager,
|
|
32
|
+
handler = new RenameHandler(connection, capabilities, documentManager, findAppRootURI);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
describe('when the client does not support workspace/applyEdit', () => {
|
|
@@ -45,8 +45,8 @@ describe('Module: AssetRenameHandler', () => {
|
|
|
45
45
|
await handler.onDidRenameFiles({
|
|
46
46
|
files: [
|
|
47
47
|
{
|
|
48
|
-
oldUri: 'mock-fs:/assets/oldName.js',
|
|
49
|
-
newUri: 'mock-fs:/assets/newName.js',
|
|
48
|
+
oldUri: 'mock-fs:/app/assets/oldName.js',
|
|
49
|
+
newUri: 'mock-fs:/app/assets/newName.js',
|
|
50
50
|
},
|
|
51
51
|
],
|
|
52
52
|
});
|
|
@@ -67,8 +67,8 @@ describe('Module: AssetRenameHandler', () => {
|
|
|
67
67
|
await handler.onDidRenameFiles({
|
|
68
68
|
files: [
|
|
69
69
|
{
|
|
70
|
-
oldUri: 'mock-fs:/assets/oldName.js',
|
|
71
|
-
newUri: 'mock-fs:/assets/newName.js',
|
|
70
|
+
oldUri: 'mock-fs:/app/assets/oldName.js',
|
|
71
|
+
newUri: 'mock-fs:/app/assets/newName.js',
|
|
72
72
|
},
|
|
73
73
|
],
|
|
74
74
|
});
|
|
@@ -90,7 +90,7 @@ describe('Module: AssetRenameHandler', () => {
|
|
|
90
90
|
documentChanges: [
|
|
91
91
|
{
|
|
92
92
|
textDocument: {
|
|
93
|
-
uri: 'mock-fs:/
|
|
93
|
+
uri: 'mock-fs:/app/views/partials/section.liquid',
|
|
94
94
|
version: null,
|
|
95
95
|
},
|
|
96
96
|
edits: [expectedTextEdit],
|
|
@@ -98,7 +98,7 @@ describe('Module: AssetRenameHandler', () => {
|
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
textDocument: {
|
|
101
|
-
uri: 'mock-fs:/
|
|
101
|
+
uri: 'mock-fs:/app/views/partials/block.liquid',
|
|
102
102
|
version: null,
|
|
103
103
|
},
|
|
104
104
|
edits: [expectedTextEdit],
|
|
@@ -113,8 +113,8 @@ describe('Module: AssetRenameHandler', () => {
|
|
|
113
113
|
await handler.onDidRenameFiles({
|
|
114
114
|
files: [
|
|
115
115
|
{
|
|
116
|
-
oldUri: 'mock-fs:/assets/oldName.js',
|
|
117
|
-
newUri: 'mock-fs:/assets/newName.js',
|
|
116
|
+
oldUri: 'mock-fs:/app/assets/oldName.js',
|
|
117
|
+
newUri: 'mock-fs:/app/assets/newName.js',
|
|
118
118
|
},
|
|
119
119
|
],
|
|
120
120
|
});
|
|
@@ -122,9 +122,9 @@ describe('Module: AssetRenameHandler', () => {
|
|
|
122
122
|
const params: ApplyWorkspaceEditParams = connection.spies.sendRequest.mock.calls[0][1];
|
|
123
123
|
const expectedFs = new MockFileSystem(
|
|
124
124
|
{
|
|
125
|
-
'assets/oldName.js': 'console.log("Hello, world!")',
|
|
126
|
-
'
|
|
127
|
-
'
|
|
125
|
+
'app/assets/oldName.js': 'console.log("Hello, world!")',
|
|
126
|
+
'app/views/partials/section.liquid': `<script src="{{ 'newName.js' | asset_url }}" defer></script>`,
|
|
127
|
+
'app/views/partials/block.liquid': `{{ 'newName.js' | asset_url | script_tag }} oldName.js`,
|
|
128
128
|
},
|
|
129
129
|
'mock-fs:',
|
|
130
130
|
);
|
|
@@ -145,8 +145,8 @@ describe('Module: AssetRenameHandler', () => {
|
|
|
145
145
|
await handler.onDidRenameFiles({
|
|
146
146
|
files: [
|
|
147
147
|
{
|
|
148
|
-
oldUri: 'mock-fs:/assets/oldName.js',
|
|
149
|
-
newUri: `mock-fs:/assets/newName.js.liquid`,
|
|
148
|
+
oldUri: 'mock-fs:/app/assets/oldName.js',
|
|
149
|
+
newUri: `mock-fs:/app/assets/newName.js.liquid`,
|
|
150
150
|
},
|
|
151
151
|
],
|
|
152
152
|
});
|
|
@@ -154,9 +154,9 @@ describe('Module: AssetRenameHandler', () => {
|
|
|
154
154
|
const params: ApplyWorkspaceEditParams = connection.spies.sendRequest.mock.calls[0][1];
|
|
155
155
|
const expectedFs = new MockFileSystem(
|
|
156
156
|
{
|
|
157
|
-
'assets/oldName.js': 'console.log("Hello, world!")',
|
|
158
|
-
'
|
|
159
|
-
'
|
|
157
|
+
'app/assets/oldName.js': 'console.log("Hello, world!")',
|
|
158
|
+
'app/views/partials/section.liquid': `<script src="{{ 'newName.js' | asset_url }}" defer></script>`,
|
|
159
|
+
'app/views/partials/block.liquid': `{{ 'newName.js' | asset_url | script_tag }} oldName.js`,
|
|
160
160
|
},
|
|
161
161
|
'mock-fs:',
|
|
162
162
|
);
|
|
@@ -176,19 +176,19 @@ describe('Module: AssetRenameHandler', () => {
|
|
|
176
176
|
it('handles .css.liquid files', async () => {
|
|
177
177
|
fs = new MockFileSystem(
|
|
178
178
|
{
|
|
179
|
-
'assets/oldName.css.liquid': 'body { color: red; }',
|
|
180
|
-
'
|
|
179
|
+
'app/assets/oldName.css.liquid': 'body { color: red; }',
|
|
180
|
+
'app/views/partials/section.liquid': `{% echo 'oldName.css' | asset_url | stylesheet_tag %}`,
|
|
181
181
|
},
|
|
182
182
|
'mock-fs:',
|
|
183
183
|
);
|
|
184
184
|
documentManager = new DocumentManager(fs);
|
|
185
|
-
handler = new RenameHandler(connection, capabilities, documentManager,
|
|
185
|
+
handler = new RenameHandler(connection, capabilities, documentManager, findAppRootURI);
|
|
186
186
|
|
|
187
187
|
await handler.onDidRenameFiles({
|
|
188
188
|
files: [
|
|
189
189
|
{
|
|
190
|
-
oldUri: 'mock-fs:/assets/oldName.css.liquid',
|
|
191
|
-
newUri: `mock-fs:/assets/newName.css.liquid`,
|
|
190
|
+
oldUri: 'mock-fs:/app/assets/oldName.css.liquid',
|
|
191
|
+
newUri: `mock-fs:/app/assets/newName.css.liquid`,
|
|
192
192
|
},
|
|
193
193
|
],
|
|
194
194
|
});
|
|
@@ -196,8 +196,8 @@ describe('Module: AssetRenameHandler', () => {
|
|
|
196
196
|
const params: ApplyWorkspaceEditParams = connection.spies.sendRequest.mock.calls[0][1];
|
|
197
197
|
const expectedFs = new MockFileSystem(
|
|
198
198
|
{
|
|
199
|
-
'assets/newName.css.liquid': 'body { color: red; }',
|
|
200
|
-
'
|
|
199
|
+
'app/assets/newName.css.liquid': 'body { color: red; }',
|
|
200
|
+
'app/views/partials/section.liquid': `{% echo 'newName.css' | asset_url | stylesheet_tag %}`,
|
|
201
201
|
},
|
|
202
202
|
'mock-fs:',
|
|
203
203
|
);
|
|
@@ -12,7 +12,7 @@ import { ClientCapabilities } from '../../ClientCapabilities';
|
|
|
12
12
|
import { DocumentManager, isLiquidSourceCode } from '../../documents';
|
|
13
13
|
import { assetName, isAsset } from '../../utils/uri';
|
|
14
14
|
import { BaseRenameHandler } from '../BaseRenameHandler';
|
|
15
|
-
import {
|
|
15
|
+
import { FindAppRootURI } from '../../internal-types';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The AssetRenameHandler will handle asset renames.
|
|
@@ -22,7 +22,7 @@ import { FindThemeRootURI } from '../../internal-types';
|
|
|
22
22
|
*
|
|
23
23
|
* We'll do that for `.(css|js).liquid` files as well
|
|
24
24
|
*
|
|
25
|
-
* We'll do this by visiting all the liquid files in the
|
|
25
|
+
* We'll do this by visiting all the liquid files in the app and looking for
|
|
26
26
|
* string | asset_url Variable nodes that reference the old asset. We'll then create a
|
|
27
27
|
* WorkspaceEdit that changes the references to the new asset.
|
|
28
28
|
*/
|
|
@@ -31,7 +31,7 @@ export class AssetRenameHandler implements BaseRenameHandler {
|
|
|
31
31
|
private documentManager: DocumentManager,
|
|
32
32
|
private connection: Connection,
|
|
33
33
|
private capabilities: ClientCapabilities,
|
|
34
|
-
private
|
|
34
|
+
private findAppRootURI: FindAppRootURI,
|
|
35
35
|
) {}
|
|
36
36
|
|
|
37
37
|
async onDidRenameFiles(params: RenameFilesParams): Promise<void> {
|
|
@@ -44,11 +44,11 @@ export class AssetRenameHandler implements BaseRenameHandler {
|
|
|
44
44
|
// Only preload if you have something to do (folder renames are not supported)
|
|
45
45
|
if (relevantRenames.length !== 1) return;
|
|
46
46
|
const rename = relevantRenames[0];
|
|
47
|
-
const rootUri = await this.
|
|
47
|
+
const rootUri = await this.findAppRootURI(path.dirname(params.files[0].oldUri));
|
|
48
48
|
if (!rootUri) return;
|
|
49
49
|
await this.documentManager.preload(rootUri);
|
|
50
|
-
const
|
|
51
|
-
const liquidSourceCodes =
|
|
50
|
+
const app = this.documentManager.app(rootUri, true);
|
|
51
|
+
const liquidSourceCodes = app.filter(isLiquidSourceCode);
|
|
52
52
|
|
|
53
53
|
const oldAssetName = assetName(rename.oldUri);
|
|
54
54
|
const newAssetName = assetName(rename.newUri);
|
|
@@ -9,7 +9,7 @@ import { RenameHandler } from '../RenameHandler';
|
|
|
9
9
|
|
|
10
10
|
describe('Module: PartialRenameHandler', () => {
|
|
11
11
|
const mockRoot = 'mock-fs:';
|
|
12
|
-
const
|
|
12
|
+
const findAppRootURI = async () => mockRoot;
|
|
13
13
|
let capabilities: ClientCapabilities;
|
|
14
14
|
let documentManager: DocumentManager;
|
|
15
15
|
let handler: RenameHandler;
|
|
@@ -21,15 +21,15 @@ describe('Module: PartialRenameHandler', () => {
|
|
|
21
21
|
capabilities = new ClientCapabilities();
|
|
22
22
|
fs = new MockFileSystem(
|
|
23
23
|
{
|
|
24
|
-
'
|
|
25
|
-
'
|
|
24
|
+
'app/views/partials/page.liquid': `<div>{% render 'oldName', foo: 'bar' %}oldName</div>`,
|
|
25
|
+
'app/lib/component.liquid': `<div>{% render 'oldName', foo: 'baz' %}</div>`,
|
|
26
26
|
'app/views/partials/oldName.liquid': `<div>oldName{%</div>`,
|
|
27
27
|
'app/views/partials/other.liquid': `<div>{% render 'oldName' %}{% render 'other' %}</div>`,
|
|
28
28
|
},
|
|
29
29
|
mockRoot,
|
|
30
30
|
);
|
|
31
31
|
documentManager = new DocumentManager(fs);
|
|
32
|
-
handler = new RenameHandler(connection, capabilities, documentManager,
|
|
32
|
+
handler = new RenameHandler(connection, capabilities, documentManager, findAppRootURI);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
describe('when the client does not support workspace/applyEdit', () => {
|
|
@@ -90,7 +90,7 @@ describe('Module: PartialRenameHandler', () => {
|
|
|
90
90
|
documentChanges: [
|
|
91
91
|
{
|
|
92
92
|
textDocument: {
|
|
93
|
-
uri: 'mock-fs:/
|
|
93
|
+
uri: 'mock-fs:/app/views/partials/page.liquid',
|
|
94
94
|
version: null,
|
|
95
95
|
},
|
|
96
96
|
edits: [expectedTextEdit],
|
|
@@ -98,7 +98,7 @@ describe('Module: PartialRenameHandler', () => {
|
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
textDocument: {
|
|
101
|
-
uri: 'mock-fs:/
|
|
101
|
+
uri: 'mock-fs:/app/views/partials/other.liquid',
|
|
102
102
|
version: null,
|
|
103
103
|
},
|
|
104
104
|
edits: [expectedTextEdit],
|
|
@@ -106,7 +106,7 @@ describe('Module: PartialRenameHandler', () => {
|
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
textDocument: {
|
|
109
|
-
uri: 'mock-fs:/app/
|
|
109
|
+
uri: 'mock-fs:/app/lib/component.liquid',
|
|
110
110
|
version: null,
|
|
111
111
|
},
|
|
112
112
|
edits: [expectedTextEdit],
|
|
@@ -130,8 +130,8 @@ describe('Module: PartialRenameHandler', () => {
|
|
|
130
130
|
const params: ApplyWorkspaceEditParams = connection.spies.sendRequest.mock.calls[0][1];
|
|
131
131
|
const expectedFs = new MockFileSystem(
|
|
132
132
|
{
|
|
133
|
-
'
|
|
134
|
-
'
|
|
133
|
+
'app/views/partials/page.liquid': `<div>{% render 'newName', foo: 'bar' %}oldName</div>`,
|
|
134
|
+
'app/lib/component.liquid': `<div>{% render 'newName', foo: 'baz' %}</div>`,
|
|
135
135
|
'app/views/partials/newName.liquid': `<div>oldName{%</div>`,
|
|
136
136
|
'app/views/partials/other.liquid': `<div>{% render 'newName' %}{% render 'other' %}</div>`,
|
|
137
137
|
},
|
|
@@ -12,7 +12,7 @@ import { ClientCapabilities } from '../../ClientCapabilities';
|
|
|
12
12
|
import { DocumentManager, isLiquidSourceCode } from '../../documents';
|
|
13
13
|
import { isPartial, partialName } from '../../utils/uri';
|
|
14
14
|
import { BaseRenameHandler } from '../BaseRenameHandler';
|
|
15
|
-
import {
|
|
15
|
+
import { FindAppRootURI } from '../../internal-types';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* The PartialRenameHandler will handle partial renames.
|
|
@@ -22,7 +22,7 @@ import { FindThemeRootURI } from '../../internal-types';
|
|
|
22
22
|
*
|
|
23
23
|
* {% render 'oldName' %} -> {% render 'newName' %}
|
|
24
24
|
*
|
|
25
|
-
* We'll do this by visiting all the liquid files in the
|
|
25
|
+
* We'll do this by visiting all the liquid files in the app and looking for
|
|
26
26
|
* render and include tags that reference the old partial. We'll then create a
|
|
27
27
|
* WorkspaceEdit that changes the references to the new partial.
|
|
28
28
|
*/
|
|
@@ -31,7 +31,7 @@ export class PartialRenameHandler implements BaseRenameHandler {
|
|
|
31
31
|
private documentManager: DocumentManager,
|
|
32
32
|
private connection: Connection,
|
|
33
33
|
private capabilities: ClientCapabilities,
|
|
34
|
-
private
|
|
34
|
+
private findAppRootURI: FindAppRootURI,
|
|
35
35
|
) {}
|
|
36
36
|
|
|
37
37
|
async onDidRenameFiles(params: RenameFilesParams): Promise<void> {
|
|
@@ -43,11 +43,11 @@ export class PartialRenameHandler implements BaseRenameHandler {
|
|
|
43
43
|
// Only preload if you have something to do (folder renames are not supported)
|
|
44
44
|
if (relevantRenames.length !== 1) return;
|
|
45
45
|
const rename = relevantRenames[0];
|
|
46
|
-
const rootUri = await this.
|
|
46
|
+
const rootUri = await this.findAppRootURI(path.dirname(params.files[0].oldUri));
|
|
47
47
|
if (!rootUri) return;
|
|
48
48
|
await this.documentManager.preload(rootUri);
|
|
49
|
-
const
|
|
50
|
-
const liquidSourceCodes =
|
|
49
|
+
const app = this.documentManager.app(rootUri, true);
|
|
50
|
+
const liquidSourceCodes = app.filter(isLiquidSourceCode);
|
|
51
51
|
const oldPartialName = partialName(rename.oldUri);
|
|
52
52
|
const newPartialName = partialName(rename.newUri);
|
|
53
53
|
const editLabel = `Rename partial '${oldPartialName}' to '${newPartialName}'`;
|
|
@@ -73,13 +73,13 @@ export class PartialRenameHandler implements BaseRenameHandler {
|
|
|
73
73
|
if (typeof node.markup === 'string') {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
76
|
+
const partial = node.markup.partial;
|
|
77
|
+
if (partial.type === NodeTypes.String && partial.value === oldPartialName) {
|
|
78
78
|
return {
|
|
79
79
|
newText: `${newPartialName}`,
|
|
80
80
|
range: Range.create(
|
|
81
|
-
textDocument.positionAt(
|
|
82
|
-
textDocument.positionAt(
|
|
81
|
+
textDocument.positionAt(partial.position.start + 1), // +1 to skip the opening quote
|
|
82
|
+
textDocument.positionAt(partial.position.end - 1), // -1 to skip the closing quote
|
|
83
83
|
),
|
|
84
84
|
};
|
|
85
85
|
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
path,
|
|
3
|
-
recursiveReadDirectory,
|
|
4
|
-
SectionSchema,
|
|
5
|
-
SourceCodeType,
|
|
6
|
-
ThemeBlockSchema,
|
|
7
|
-
} from '@platformos/platformos-check-common';
|
|
1
|
+
import { path, SourceCodeType } from '@platformos/platformos-check-common';
|
|
8
2
|
import { AbstractFileSystem } from '@platformos/platformos-common';
|
|
9
3
|
import {
|
|
10
|
-
|
|
4
|
+
buildAppGraph,
|
|
11
5
|
getWebComponentMap,
|
|
12
6
|
IDependencies as GraphDependencies,
|
|
13
7
|
Location,
|
|
@@ -22,40 +16,36 @@ import {
|
|
|
22
16
|
AugmentedLocation,
|
|
23
17
|
AugmentedLocationWithExistence,
|
|
24
18
|
AugmentedReference,
|
|
25
|
-
|
|
19
|
+
AppGraphDidUpdateNotification,
|
|
26
20
|
} from '../types';
|
|
27
21
|
import { debounce } from '../utils';
|
|
28
|
-
import {
|
|
22
|
+
import { FindAppRootURI } from '../internal-types';
|
|
29
23
|
|
|
30
|
-
export class
|
|
31
|
-
graphs: Map<string, ReturnType<typeof
|
|
24
|
+
export class AppGraphManager {
|
|
25
|
+
graphs: Map<string, ReturnType<typeof buildAppGraph>> = new Map();
|
|
32
26
|
|
|
33
27
|
constructor(
|
|
34
28
|
private connection: Connection,
|
|
35
29
|
private documentManager: DocumentManager,
|
|
36
30
|
private fs: AbstractFileSystem,
|
|
37
|
-
private
|
|
31
|
+
private findAppRootURI: FindAppRootURI,
|
|
38
32
|
) {}
|
|
39
33
|
|
|
40
|
-
async
|
|
41
|
-
const rootUri = await this.
|
|
34
|
+
async getAppGraphForURI(uri: string) {
|
|
35
|
+
const rootUri = await this.findAppRootURI(uri);
|
|
42
36
|
if (!rootUri) {
|
|
43
37
|
return undefined;
|
|
44
38
|
}
|
|
45
39
|
|
|
46
40
|
if (!this.graphs.has(rootUri)) {
|
|
47
|
-
this.graphs.set(rootUri, this.
|
|
41
|
+
this.graphs.set(rootUri, this.buildAppGraph(rootUri));
|
|
48
42
|
}
|
|
49
43
|
|
|
50
44
|
return this.graphs.get(rootUri);
|
|
51
45
|
}
|
|
52
46
|
|
|
53
|
-
async getReferences(
|
|
54
|
-
uri
|
|
55
|
-
offset?: number,
|
|
56
|
-
{ includeIndirect = true, includePreset = true } = {},
|
|
57
|
-
) {
|
|
58
|
-
const graph = await this.getThemeGraphForURI(uri);
|
|
47
|
+
async getReferences(uri: string, offset?: number, { includeIndirect = true } = {}) {
|
|
48
|
+
const graph = await this.getAppGraphForURI(uri);
|
|
59
49
|
if (!graph) return [];
|
|
60
50
|
|
|
61
51
|
const module = graph.modules[uri];
|
|
@@ -64,7 +54,6 @@ export class ThemeGraphManager {
|
|
|
64
54
|
const includedTypes: (AugmentedReference['type'] | undefined)[] = [
|
|
65
55
|
'direct',
|
|
66
56
|
includeIndirect ? 'indirect' : undefined,
|
|
67
|
-
includePreset ? 'preset' : undefined,
|
|
68
57
|
];
|
|
69
58
|
|
|
70
59
|
const refs = module.references.filter((dep) => includedTypes.includes(dep.type));
|
|
@@ -84,31 +73,16 @@ export class ThemeGraphManager {
|
|
|
84
73
|
);
|
|
85
74
|
}
|
|
86
75
|
|
|
87
|
-
async getDependencies(
|
|
88
|
-
uri
|
|
89
|
-
offset?: number,
|
|
90
|
-
{ includeIndirect = true, includePreset = true } = {},
|
|
91
|
-
) {
|
|
92
|
-
const graph = await this.getThemeGraphForURI(uri);
|
|
76
|
+
async getDependencies(uri: string, offset?: number, { includeIndirect = true } = {}) {
|
|
77
|
+
const graph = await this.getAppGraphForURI(uri);
|
|
93
78
|
if (!graph) return [];
|
|
94
79
|
|
|
95
|
-
|
|
96
|
-
if (!module) {
|
|
97
|
-
// If the module is not found, we might be dealing with dead code.
|
|
98
|
-
// dead code doesn't show up in the graph, but it might still have dependencies.
|
|
99
|
-
// So we're building a smaller graph with that file as entry point to figure
|
|
100
|
-
// out what it depends on.
|
|
101
|
-
const deadCodeGraph = await this.buildThemeGraph(graph.rootUri, [uri]);
|
|
102
|
-
module = deadCodeGraph.modules[uri];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// If the module is still not found, we return an empty array.
|
|
80
|
+
const module = graph.modules[uri];
|
|
106
81
|
if (!module) return [];
|
|
107
82
|
|
|
108
83
|
const includedTypes: (AugmentedReference['type'] | undefined)[] = [
|
|
109
84
|
'direct',
|
|
110
85
|
includeIndirect ? 'indirect' : undefined,
|
|
111
|
-
includePreset ? 'preset' : undefined,
|
|
112
86
|
];
|
|
113
87
|
|
|
114
88
|
const deps = module.dependencies.filter((dep) => includedTypes.includes(dep.type)) ?? [];
|
|
@@ -148,33 +122,6 @@ export class ThemeGraphManager {
|
|
|
148
122
|
};
|
|
149
123
|
}
|
|
150
124
|
|
|
151
|
-
async deadCode(rootUri: string): Promise<string[]> {
|
|
152
|
-
const graph = await this.getThemeGraphForURI(rootUri);
|
|
153
|
-
if (!graph) return [];
|
|
154
|
-
|
|
155
|
-
const files = await recursiveReadDirectory(
|
|
156
|
-
this.fs,
|
|
157
|
-
rootUri,
|
|
158
|
-
([uri]) =>
|
|
159
|
-
['assets', 'blocks', 'layout', 'sections', 'snippets', 'templates'].some((dir) =>
|
|
160
|
-
uri.startsWith(path.join(rootUri, dir)),
|
|
161
|
-
) &&
|
|
162
|
-
(uri.endsWith('.liquid') ||
|
|
163
|
-
uri.endsWith('.json') ||
|
|
164
|
-
uri.endsWith('.js') ||
|
|
165
|
-
uri.endsWith('.css')),
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
const unusedFiles = new Set<string>();
|
|
169
|
-
for (const file of files) {
|
|
170
|
-
if (!graph.modules[file]) {
|
|
171
|
-
unusedFiles.add(file);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return Array.from(unusedFiles).sort();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
125
|
public operationQueue: string[] = [];
|
|
179
126
|
|
|
180
127
|
async rename(oldUri: string, newUri: string) {
|
|
@@ -203,23 +150,23 @@ export class ThemeGraphManager {
|
|
|
203
150
|
if (operations.length === 0) return;
|
|
204
151
|
|
|
205
152
|
const anyUri = operations[0];
|
|
206
|
-
const rootUri = await this.
|
|
153
|
+
const rootUri = await this.findAppRootURI(anyUri);
|
|
207
154
|
if (!rootUri) return;
|
|
208
155
|
|
|
209
156
|
const graph = await this.graphs.get(rootUri);
|
|
210
157
|
if (!graph) return;
|
|
211
158
|
|
|
212
159
|
this.graphs.delete(rootUri);
|
|
213
|
-
await this.
|
|
214
|
-
this.connection.sendNotification(
|
|
160
|
+
await this.getAppGraphForURI(rootUri);
|
|
161
|
+
this.connection.sendNotification(AppGraphDidUpdateNotification.type, { uri: rootUri });
|
|
215
162
|
}, 500);
|
|
216
163
|
|
|
217
|
-
private
|
|
164
|
+
private buildAppGraph = async (rootUri: string, entryPoints?: string[]) => {
|
|
218
165
|
const { documentManager } = this;
|
|
219
166
|
await documentManager.preload(rootUri);
|
|
220
167
|
|
|
221
168
|
const dependencies = await this.graphDependencies(rootUri);
|
|
222
|
-
return
|
|
169
|
+
return buildAppGraph(rootUri, dependencies, entryPoints);
|
|
223
170
|
};
|
|
224
171
|
|
|
225
172
|
private getSourceCode = async (uri: string) => {
|
|
@@ -236,27 +183,11 @@ export class ThemeGraphManager {
|
|
|
236
183
|
}
|
|
237
184
|
|
|
238
185
|
private async graphDependencies(rootUri: string): Promise<GraphDependencies> {
|
|
239
|
-
const {
|
|
186
|
+
const { fs, getSourceCode } = this;
|
|
240
187
|
const webComponentDefs = await this.getWebComponentMap(rootUri);
|
|
241
188
|
return {
|
|
242
189
|
fs: fs,
|
|
243
190
|
getSourceCode: getSourceCode,
|
|
244
|
-
async getBlockSchema(name: string) {
|
|
245
|
-
const blockUri = path.join(rootUri, 'blocks', `${name}.liquid`);
|
|
246
|
-
const doc = documentManager.get(blockUri);
|
|
247
|
-
if (!doc || doc.type !== SourceCodeType.LiquidHtml) {
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
return (await doc.getSchema()) as ThemeBlockSchema;
|
|
251
|
-
},
|
|
252
|
-
async getSectionSchema(name) {
|
|
253
|
-
const sectionUri = path.join(rootUri, 'sections', `${name}.liquid`);
|
|
254
|
-
const doc = documentManager.get(sectionUri);
|
|
255
|
-
if (!doc || doc.type !== SourceCodeType.LiquidHtml) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
return (await doc.getSchema()) as SectionSchema;
|
|
259
|
-
},
|
|
260
191
|
getWebComponentDefinitionReference(customElementName: string) {
|
|
261
192
|
return webComponentDefs.get(customElementName);
|
|
262
193
|
},
|
package/src/server/safe.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* @param defaultReturnValue
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
|
-
* const
|
|
17
|
+
* const getPartialNames = safe(async function () { ... }, []);
|
|
18
18
|
*/
|
|
19
19
|
export const safe = <T extends (...args: any[]) => Promise<any>>(
|
|
20
20
|
fn: T,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { allChecks, path } from '@platformos/platformos-check-common';
|
|
2
|
-
import { MockFileSystem,
|
|
2
|
+
import { MockFileSystem, MockApp } from '@platformos/platformos-check-common/dist/test';
|
|
3
3
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
4
|
import {
|
|
5
5
|
DidChangeConfigurationNotification,
|
|
@@ -16,8 +16,8 @@ import { startServer } from './startServer';
|
|
|
16
16
|
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
17
17
|
|
|
18
18
|
describe('Module: server', () => {
|
|
19
|
-
const mockRoot = path.normalize('browser:/
|
|
20
|
-
const filePath = 'app/code.liquid';
|
|
19
|
+
const mockRoot = path.normalize('browser:/app');
|
|
20
|
+
const filePath = 'app/views/partials/code.liquid';
|
|
21
21
|
const fileURI = path.join(mockRoot, filePath);
|
|
22
22
|
const fileContents = `{% render 'foo' %}`;
|
|
23
23
|
let checkOnChange: boolean | null = null;
|
|
@@ -25,7 +25,7 @@ describe('Module: server', () => {
|
|
|
25
25
|
let checkOnOpen: boolean | null = null;
|
|
26
26
|
let connection: MockConnection;
|
|
27
27
|
let dependencies: ReturnType<typeof getDependencies>;
|
|
28
|
-
let fileTree:
|
|
28
|
+
let fileTree: MockApp;
|
|
29
29
|
let logger: any;
|
|
30
30
|
|
|
31
31
|
beforeEach(() => {
|
|
@@ -60,7 +60,7 @@ describe('Module: server', () => {
|
|
|
60
60
|
|
|
61
61
|
fileTree = {
|
|
62
62
|
'.pos': '',
|
|
63
|
-
'app/code.liquid': fileContents,
|
|
63
|
+
'app/views/partials/code.liquid': fileContents,
|
|
64
64
|
'.git/test': 'test',
|
|
65
65
|
'modules/test': 'test',
|
|
66
66
|
};
|
|
@@ -375,25 +375,23 @@ describe('Module: server', () => {
|
|
|
375
375
|
return flushAsync();
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
-
function getDependencies(logger: any, fileTree:
|
|
379
|
-
const MissingTemplate = allChecks.filter((c) => c.meta.code === '
|
|
378
|
+
function getDependencies(logger: any, fileTree: MockApp): Dependencies {
|
|
379
|
+
const MissingTemplate = allChecks.filter((c) => c.meta.code === 'MissingPartial');
|
|
380
380
|
|
|
381
381
|
return {
|
|
382
382
|
fs: new MockFileSystem(fileTree, mockRoot),
|
|
383
383
|
log: logger,
|
|
384
384
|
loadConfig: async () => ({
|
|
385
|
-
context: 'theme',
|
|
386
385
|
settings: {},
|
|
387
386
|
checks: MissingTemplate,
|
|
388
387
|
rootUri: mockRoot,
|
|
389
388
|
}),
|
|
390
|
-
|
|
389
|
+
platformosDocset: {
|
|
391
390
|
graphQL: async () => null,
|
|
392
391
|
filters: async () => [],
|
|
393
392
|
objects: async () => [],
|
|
394
393
|
liquidDrops: async () => [],
|
|
395
394
|
tags: async () => [],
|
|
396
|
-
systemTranslations: async () => ({}),
|
|
397
395
|
},
|
|
398
396
|
jsonValidationSet: {
|
|
399
397
|
schemas: async () => [],
|
|
@@ -403,11 +401,11 @@ describe('Module: server', () => {
|
|
|
403
401
|
|
|
404
402
|
function missingTemplateDiagnostic() {
|
|
405
403
|
return {
|
|
406
|
-
code: '
|
|
404
|
+
code: 'MissingPartial',
|
|
407
405
|
codeDescription: { href: expect.any(String) },
|
|
408
406
|
message: "'foo' does not exist",
|
|
409
407
|
severity: 1,
|
|
410
|
-
source: '
|
|
408
|
+
source: 'platformos-check',
|
|
411
409
|
range: {
|
|
412
410
|
start: {
|
|
413
411
|
character: 10,
|