@platformos/platformos-language-server-common 0.0.18 → 0.0.20

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 (54) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/codeActions/CodeActionsProvider.d.ts +1 -1
  3. package/dist/completions/providers/PartialCompletionProvider.js +6 -1
  4. package/dist/completions/providers/PartialCompletionProvider.js.map +1 -1
  5. package/dist/definitions/providers/RenderPartialDefinitionProvider.js +1 -0
  6. package/dist/definitions/providers/RenderPartialDefinitionProvider.js.map +1 -1
  7. package/dist/documentLinks/DocumentLinksProvider.js +1 -1
  8. package/dist/documentLinks/DocumentLinksProvider.js.map +1 -1
  9. package/dist/documents/DocumentManager.js +2 -3
  10. package/dist/documents/DocumentManager.js.map +1 -1
  11. package/dist/server/AppGraphManager.d.ts +0 -1
  12. package/dist/server/AppGraphManager.js +3 -14
  13. package/dist/server/AppGraphManager.js.map +1 -1
  14. package/dist/server/DocumentBackedFileSystem.d.ts +25 -0
  15. package/dist/server/DocumentBackedFileSystem.js +39 -0
  16. package/dist/server/DocumentBackedFileSystem.js.map +1 -0
  17. package/dist/server/startServer.js +7 -1
  18. package/dist/server/startServer.js.map +1 -1
  19. package/dist/test/CompletionItemsAssertion.js +3 -2
  20. package/dist/test/CompletionItemsAssertion.js.map +1 -1
  21. package/dist/test/HoverAssertion.js +3 -2
  22. package/dist/test/HoverAssertion.js.map +1 -1
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +4 -4
  25. package/src/codeActions/providers/FixAllProvider.spec.ts +2 -2
  26. package/src/codeActions/providers/FixProvider.spec.ts +2 -2
  27. package/src/codeActions/providers/SuggestionProvider.spec.ts +2 -2
  28. package/src/commands/providers/ApplyFixesProvider.spec.ts +2 -2
  29. package/src/commands/providers/ApplySuggestionProvider.spec.ts +2 -2
  30. package/src/commands/providers/RunChecksProvider.spec.ts +2 -2
  31. package/src/completions/params/LiquidCompletionParams.spec.ts +2 -2
  32. package/src/completions/providers/ObjectCompletionProvider.spec.ts +4 -1
  33. package/src/completions/providers/PartialCompletionProvider.ts +6 -3
  34. package/src/definitions/providers/RenderPartialDefinitionProvider.spec.ts +20 -0
  35. package/src/definitions/providers/RenderPartialDefinitionProvider.ts +1 -0
  36. package/src/definitions/providers/TranslationStringDefinitionProvider.spec.ts +2 -2
  37. package/src/diagnostics/runChecks.spec.ts +86 -0
  38. package/src/documentHighlights/providers/HtmlTagNameDocumentHighlightsProvider.spec.ts +5 -5
  39. package/src/documentHighlights/providers/LiquidBlockTagDocumentHighlightsProvider.spec.ts +6 -6
  40. package/src/documentLinks/DocumentLinksProvider.spec.ts +1 -1
  41. package/src/documentLinks/DocumentLinksProvider.ts +1 -1
  42. package/src/documents/DocumentManager.ts +3 -3
  43. package/src/formatting/providers/BracketsAutoclosingOnTypeFormattingProvider.spec.ts +4 -4
  44. package/src/formatting/providers/HtmlElementAutoclosingOnTypeFormattingProvider.spec.ts +1 -1
  45. package/src/hover/providers/LiquidObjectHoverProvider.spec.ts +4 -1
  46. package/src/linkedEditingRanges/providers/EmptyHtmlTagLinkedRangesProvider.spec.ts +4 -4
  47. package/src/linkedEditingRanges/providers/HtmlTagNameLinkedRangesProvider.spec.ts +1 -1
  48. package/src/rename/providers/HtmlTagNameRenameProvider.spec.ts +3 -3
  49. package/src/server/AppGraphManager.ts +3 -17
  50. package/src/server/DocumentBackedFileSystem.spec.ts +54 -0
  51. package/src/server/DocumentBackedFileSystem.ts +40 -0
  52. package/src/server/startServer.ts +7 -1
  53. package/src/test/CompletionItemsAssertion.ts +3 -1
  54. package/src/test/HoverAssertion.ts +3 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformos/platformos-language-server-common",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "platformOS",
@@ -27,9 +27,9 @@
27
27
  "type-check": "tsc --noEmit -p ./tsconfig.json"
28
28
  },
29
29
  "dependencies": {
30
- "@platformos/liquid-html-parser": "^0.0.16",
31
- "@platformos/platformos-check-common": "0.0.18",
32
- "@platformos/platformos-graph": "0.0.18",
30
+ "@platformos/liquid-html-parser": "^0.0.18",
31
+ "@platformos/platformos-check-common": "0.0.20",
32
+ "@platformos/platformos-graph": "0.0.20",
33
33
  "@vscode/web-custom-data": "^0.4.6",
34
34
  "graphql": "^16.12.0",
35
35
  "graphql-language-service": "^5.2.2",
@@ -7,7 +7,7 @@ import { FixAllProvider } from './FixAllProvider';
7
7
  import { TextDocument } from 'vscode-languageserver-textdocument';
8
8
 
9
9
  describe('Unit: FixAllProvider', () => {
10
- const uri = path.normalize(URI.file('/path/to/file.liquid'));
10
+ const uri = path.normalize(URI.file('/path/to/app/views/partials/file.liquid'));
11
11
  const contents = `
12
12
  {% assign x = 1 %}
13
13
  <script src="2.js"></script>
@@ -31,7 +31,7 @@ describe('Unit: FixAllProvider', () => {
31
31
  type: SourceCodeType.LiquidHtml,
32
32
  check: checkName,
33
33
  message: 'Parser blocking script detected',
34
- uri: 'file:///path/to/file.liquid',
34
+ uri,
35
35
  severity: Severity.ERROR,
36
36
  start: { ...document.positionAt(start), index: start },
37
37
  end: { ...document.positionAt(end), index: end },
@@ -7,7 +7,7 @@ import { FixProvider } from './FixProvider';
7
7
  import { TextDocument } from 'vscode-languageserver-textdocument';
8
8
 
9
9
  describe('Unit: FixProvider', () => {
10
- const uri = path.normalize(URI.file('/path/to/file.liquid'));
10
+ const uri = path.normalize(URI.file('/path/to/app/views/partials/file.liquid'));
11
11
  const contents = `
12
12
  {% assign x = 1 %}
13
13
  <script src="2.js"></script>
@@ -30,7 +30,7 @@ describe('Unit: FixProvider', () => {
30
30
  type: SourceCodeType.LiquidHtml,
31
31
  check: checkName,
32
32
  message: 'Parser blocking script detected',
33
- uri: 'file:///path/to/file.liquid',
33
+ uri,
34
34
  severity: Severity.ERROR,
35
35
  start: { ...document.positionAt(start), index: start },
36
36
  end: { ...document.positionAt(end), index: end },
@@ -13,7 +13,7 @@ import { DocumentManager } from '../../documents';
13
13
  import { SuggestionProvider } from './SuggestionProvider';
14
14
 
15
15
  describe('Unit: SuggestionProvider', () => {
16
- const uri = path.normalize(URI.file('/path/to/file.liquid'));
16
+ const uri = path.normalize(URI.file('/path/to/app/views/partials/file.liquid'));
17
17
  const contents = `
18
18
  {% assign x = 1 %}
19
19
  <script src="2.js"></script>
@@ -41,7 +41,7 @@ describe('Unit: SuggestionProvider', () => {
41
41
  type: SourceCodeType.LiquidHtml,
42
42
  check: checkName,
43
43
  message: 'Parser blocking script detected',
44
- uri: 'file:///path/to/file.liquid',
44
+ uri,
45
45
  severity: Severity.ERROR,
46
46
  start: { ...document.positionAt(start), index: start },
47
47
  end: { ...document.positionAt(end), index: end },
@@ -14,7 +14,7 @@ import { DocumentManager } from '../../documents';
14
14
  import { ApplyFixesProvider } from './ApplyFixesProvider';
15
15
 
16
16
  describe('Unit: ApplyFixesProvider', () => {
17
- const uri = path.normalize(URI.file('/path/to/file.liquid'));
17
+ const uri = path.normalize(URI.file('/path/to/app/views/partials/file.liquid'));
18
18
  const contents = `
19
19
  {% assign x = 1 %}
20
20
  <script src="2.js"></script>
@@ -38,7 +38,7 @@ describe('Unit: ApplyFixesProvider', () => {
38
38
  type: SourceCodeType.LiquidHtml,
39
39
  check: checkName,
40
40
  message: 'Offense detected',
41
- uri: 'file:///path/to/file.liquid',
41
+ uri,
42
42
  severity: Severity.ERROR,
43
43
  start: { ...document.positionAt(start), index: start },
44
44
  end: { ...document.positionAt(end), index: end },
@@ -15,7 +15,7 @@ import { TextDocument } from 'vscode-languageserver-textdocument';
15
15
  import { offenseToDiagnostic } from '../../diagnostics/offenseToDiagnostic';
16
16
 
17
17
  describe('Unit: ApplySuggestionProvider', () => {
18
- const uri = path.normalize(URI.file('/path/to/file.liquid'));
18
+ const uri = path.normalize(URI.file('/path/to/app/views/partials/file.liquid'));
19
19
  const contents = `
20
20
  {% assign x = 1 %}
21
21
  <script src="2.js"></script>
@@ -44,7 +44,7 @@ describe('Unit: ApplySuggestionProvider', () => {
44
44
  type: SourceCodeType.LiquidHtml,
45
45
  check: checkName,
46
46
  message: 'Parser blocking script detected',
47
- uri: 'file:///path/to/file.liquid',
47
+ uri,
48
48
  severity: Severity.ERROR,
49
49
  start: { ...document.positionAt(start), index: start },
50
50
  end: { ...document.positionAt(end), index: end },
@@ -9,8 +9,8 @@ import { DebouncedFunction } from '../../utils';
9
9
  import { RunChecksProvider } from './RunChecksProvider';
10
10
 
11
11
  describe('Unit: RunChecksProvider', () => {
12
- const uri1 = path.normalize(URI.file('/path/to/file1.liquid'));
13
- const uri2 = path.normalize(URI.file('/path/to/file2.liquid'));
12
+ const uri1 = path.normalize(URI.file('/path/to/app/views/partials/file1.liquid'));
13
+ const uri2 = path.normalize(URI.file('/path/to/app/views/partials/file2.liquid'));
14
14
  const contents1 = `
15
15
  {% assign x = 1 %}
16
16
  <script src="2.js"></script>
@@ -278,7 +278,7 @@ function createLiquidParamsFromContext(
278
278
  ) {
279
279
  const regex = new RegExp('█', 'g');
280
280
  const documentManager = new DocumentManager();
281
- const uri = 'file:///path/to/file.liquid';
281
+ const uri = 'file:///app/views/partials/file.liquid';
282
282
  documentManager.open(uri, context.replace(regex, ''), 1);
283
283
  const params = mockCompletionParams({ position: cursorPosition });
284
284
  return createLiquidCompletionParams(
@@ -303,7 +303,7 @@ function mockCompletionParams(params: Partial<CompletionParams> = {}): Completio
303
303
  line: 0,
304
304
  },
305
305
  textDocument: {
306
- uri: 'file:///path/to/file.liquid',
306
+ uri: 'file:///app/views/partials/file.liquid',
307
307
  },
308
308
  ...params,
309
309
  };
@@ -133,7 +133,10 @@ describe('Module: ObjectCompletionProvider', async () => {
133
133
  for (const [object, relativePath] of contexts) {
134
134
  const source = `{{ ${object}█ }}`;
135
135
  await expect(provider, source).to.complete({ source, relativePath }, [object]);
136
- await expect(provider, source).to.complete({ source, relativePath: 'file.liquid' }, []);
136
+ await expect(provider, source).to.complete(
137
+ { source, relativePath: 'app/views/layouts/main.liquid' },
138
+ [],
139
+ );
137
140
  }
138
141
  });
139
142
 
@@ -22,9 +22,12 @@ export class PartialCompletionProvider implements Provider {
22
22
  !node ||
23
23
  !parentNode ||
24
24
  node.type !== NodeTypes.String ||
25
- ![NodeTypes.RenderMarkup, NodeTypes.GraphQLMarkup, NodeTypes.FunctionMarkup].includes(
26
- parentNode.type,
27
- )
25
+ ![
26
+ NodeTypes.RenderMarkup,
27
+ NodeTypes.GraphQLMarkup,
28
+ NodeTypes.FunctionMarkup,
29
+ NodeTypes.BackgroundMarkup,
30
+ ].includes(parentNode.type)
28
31
  ) {
29
32
  return [];
30
33
  }
@@ -123,6 +123,17 @@ describe('RenderPartialDefinitionProvider', () => {
123
123
  });
124
124
  });
125
125
 
126
+ describe('background tag', () => {
127
+ it('should resolve background partials', async () => {
128
+ const result = await getDefinitions("{% background x = 'mytest/inner' %}", 22, {
129
+ 'project/app/views/partials/mytest/inner.liquid': 'inner content',
130
+ });
131
+
132
+ expect(result).toHaveLength(1);
133
+ expect(result[0].targetUri).toBe('file:///project/app/views/partials/mytest/inner.liquid');
134
+ });
135
+ });
136
+
126
137
  describe('graphql tag', () => {
127
138
  it('should resolve graphql references', async () => {
128
139
  const result = await getDefinitions("{% graphql g = 'users/search' %}", 18, {
@@ -151,6 +162,15 @@ describe('RenderPartialDefinitionProvider', () => {
151
162
  expect(result[0].targetUri).toBe('file:///project/app/lib/commands/missing.liquid');
152
163
  });
153
164
 
165
+ it('background: missing partial resolves to app/views/partials', async () => {
166
+ const result = await getDefinitions("{% background x = 'my/missing/partial' %}", 22, {});
167
+
168
+ expect(result).toHaveLength(1);
169
+ expect(result[0].targetUri).toBe(
170
+ 'file:///project/app/views/partials/my/missing/partial.liquid',
171
+ );
172
+ });
173
+
154
174
  it('graphql: missing file resolves to app/graphql', async () => {
155
175
  const result = await getDefinitions("{% graphql g = 'users/missing' %}", 18, {});
156
176
 
@@ -16,6 +16,7 @@ const TAG_MARKUP_TYPE: Record<string, NodeTypes> = {
16
16
  include: NodeTypes.RenderMarkup,
17
17
  theme_render_rc: NodeTypes.RenderMarkup,
18
18
  function: NodeTypes.FunctionMarkup,
19
+ background: NodeTypes.BackgroundMarkup,
19
20
  graphql: NodeTypes.GraphQLMarkup,
20
21
  };
21
22
 
@@ -37,9 +37,9 @@ describe('Module: TranslationStringDefinitionProvider', () => {
37
37
  });
38
38
 
39
39
  it('finds the definition of existing translation keys', async () => {
40
- documentManager.open('file:///test.liquid', '{{ "hello.world" | t }}', 1);
40
+ documentManager.open('file:///app/views/partials/test.liquid', '{{ "hello.world" | t }}', 1);
41
41
  const params: DefinitionParams = {
42
- textDocument: { uri: 'file:///test.liquid' },
42
+ textDocument: { uri: 'file:///app/views/partials/test.liquid' },
43
43
  position: { line: 0, character: 5 }, // Position within "hello.world"
44
44
  };
45
45
 
@@ -9,6 +9,7 @@ import { MockFileSystem } from '@platformos/platformos-check-common/src/test';
9
9
  import { beforeEach, describe, expect, it, vi } from 'vitest';
10
10
  import { Connection } from 'vscode-languageserver';
11
11
  import { DocumentManager } from '../documents';
12
+ import { DocumentBackedFileSystem } from '../server/DocumentBackedFileSystem';
12
13
  import { DiagnosticsManager } from './DiagnosticsManager';
13
14
  import { makeRunChecks } from './runChecks';
14
15
 
@@ -274,4 +275,89 @@ describe('Module: runChecks', () => {
274
275
  diagnostics: [],
275
276
  });
276
277
  });
278
+
279
+ describe('when a referenced partial is edited in the editor', () => {
280
+ const callerURI = path.join(rootUri, 'app', 'views', 'pages', 'index.liquid');
281
+ const partialURI = path.join(rootUri, 'app', 'lib', 'my_partial.liquid');
282
+ // The caller passes `arg`, which is only a known parameter once the partial
283
+ // references it.
284
+ const caller = `{% function res = 'my_partial', arg: 'value' %}`;
285
+ // On disk the partial only knows `followships`, so `arg` looks unknown.
286
+ const partialOnDisk = `{% liquid\n assign followships = followships | default: null\n%}`;
287
+ // In the editor the partial now uses `arg`, making it a known parameter.
288
+ const partialInBuffer = `{% liquid\n log arg, type: 'arg'\n assign followships = followships | default: null\n%}`;
289
+
290
+ const partialCallArguments = allChecks.filter((c) => c.meta.code === 'PartialCallArguments');
291
+
292
+ const unknownArgDiagnostic = {
293
+ source: 'platformos-check',
294
+ code: 'PartialCallArguments',
295
+ codeDescription: { href: expect.any(String) },
296
+ message: 'Unknown parameter arg passed to function call',
297
+ severity: 1,
298
+ range: {
299
+ start: { line: 0, character: 32 },
300
+ end: { line: 0, character: 44 },
301
+ },
302
+ };
303
+
304
+ function makeRunChecksWithFs(fs: MockFileSystem | DocumentBackedFileSystem) {
305
+ return makeRunChecks(documentManager, diagnosticsManager, {
306
+ fs: fs as MockFileSystem,
307
+ loadConfig: async () => ({
308
+ settings: {},
309
+ checks: partialCallArguments,
310
+ rootUri,
311
+ }),
312
+ platformosDocset: {
313
+ graphQL: async () => null,
314
+ filters: async () => [],
315
+ objects: async () => [],
316
+ liquidDrops: async () => [],
317
+ tags: async () => [],
318
+ },
319
+ jsonValidationSet: {
320
+ schemas: async () => [],
321
+ },
322
+ });
323
+ }
324
+
325
+ beforeEach(() => {
326
+ expect(partialCallArguments).to.have.lengthOf(1);
327
+ fs = new MockFileSystem(
328
+ {
329
+ '.pos': '',
330
+ 'app/views/pages/index.liquid': caller,
331
+ 'app/lib/my_partial.liquid': partialOnDisk,
332
+ },
333
+ rootUri,
334
+ );
335
+ documentManager.open(callerURI, caller, 0);
336
+ documentManager.open(partialURI, partialInBuffer, 0);
337
+ });
338
+
339
+ it('reports a stale offense when the check reads the partial straight from disk', async () => {
340
+ runChecks = makeRunChecksWithFs(fs);
341
+
342
+ await runChecks([callerURI]);
343
+
344
+ expect(connection.sendDiagnostics).toHaveBeenCalledWith({
345
+ uri: callerURI,
346
+ version: 0,
347
+ diagnostics: [unknownArgDiagnostic],
348
+ });
349
+ });
350
+
351
+ it('reads the in-editor buffer of the partial through DocumentBackedFileSystem', async () => {
352
+ runChecks = makeRunChecksWithFs(new DocumentBackedFileSystem(fs, documentManager));
353
+
354
+ await runChecks([callerURI]);
355
+
356
+ expect(connection.sendDiagnostics).toHaveBeenCalledWith({
357
+ uri: callerURI,
358
+ version: 0,
359
+ diagnostics: [],
360
+ });
361
+ });
362
+ });
277
363
  });
@@ -15,7 +15,7 @@ describe('Module: HtmlTagNameDocumentHighlightsProvider', () => {
15
15
 
16
16
  it('should return [] for non-existent documents', async () => {
17
17
  const params: DocumentHighlightParams = {
18
- textDocument: { uri: 'file:///path/to/non-existent-document.liquid' },
18
+ textDocument: { uri: 'file:///app/views/partials/non-existent-document.liquid' },
19
19
  position: Position.create(0, 0),
20
20
  };
21
21
 
@@ -25,7 +25,7 @@ describe('Module: HtmlTagNameDocumentHighlightsProvider', () => {
25
25
 
26
26
  it('should return [] for non-HTML documents', async () => {
27
27
  const params: DocumentHighlightParams = {
28
- textDocument: { uri: 'file:///path/to/document.liquid' },
28
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
29
29
  position: Position.create(0, 0),
30
30
  };
31
31
 
@@ -37,7 +37,7 @@ describe('Module: HtmlTagNameDocumentHighlightsProvider', () => {
37
37
 
38
38
  it('should return document highlight ranges for HTML tag names', async () => {
39
39
  const params: DocumentHighlightParams = {
40
- textDocument: { uri: 'file:///path/to/document.liquid' },
40
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
41
41
  position: Position.create(0, 3), // position within the tag name
42
42
  };
43
43
 
@@ -60,7 +60,7 @@ describe('Module: HtmlTagNameDocumentHighlightsProvider', () => {
60
60
 
61
61
  it('should return document highlight ranges for closing HTML tag names', async () => {
62
62
  const params: DocumentHighlightParams = {
63
- textDocument: { uri: 'file:///path/to/document.liquid' },
63
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
64
64
  position: Position.create(0, 16), // position within the closing div tag name
65
65
  };
66
66
 
@@ -82,7 +82,7 @@ describe('Module: HtmlTagNameDocumentHighlightsProvider', () => {
82
82
 
83
83
  it('return [] for positions not within HTML tag names', async () => {
84
84
  const params: DocumentHighlightParams = {
85
- textDocument: { uri: 'file:///path/to/document.liquid' },
85
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
86
86
  position: Position.create(0, 0), // position outside the tag name
87
87
  };
88
88
 
@@ -15,7 +15,7 @@ describe('Module: LiquidBlockTagDocumentHighlightsProvider', () => {
15
15
 
16
16
  it('should return document highlight ranges for liquid blocks', async () => {
17
17
  const params: DocumentHighlightParams = {
18
- textDocument: { uri: 'file:///path/to/document.liquid' },
18
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
19
19
  position: Position.create(0, 4), // position within the tag name
20
20
  };
21
21
 
@@ -38,7 +38,7 @@ describe('Module: LiquidBlockTagDocumentHighlightsProvider', () => {
38
38
 
39
39
  it('should return document highlight ranges for liquid conditionals', async () => {
40
40
  const params: DocumentHighlightParams = {
41
- textDocument: { uri: 'file:///path/to/document.liquid' },
41
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
42
42
  position: Position.create(0, 4),
43
43
  };
44
44
 
@@ -70,7 +70,7 @@ describe('Module: LiquidBlockTagDocumentHighlightsProvider', () => {
70
70
 
71
71
  it('should return document highlight ranges for liquid case statements', async () => {
72
72
  const params: DocumentHighlightParams = {
73
- textDocument: { uri: 'file:///path/to/document.liquid' },
73
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
74
74
  position: Position.create(0, 4),
75
75
  };
76
76
 
@@ -109,7 +109,7 @@ describe('Module: LiquidBlockTagDocumentHighlightsProvider', () => {
109
109
 
110
110
  it('should return document highlight ranges for LiquidRawTags tags', async () => {
111
111
  const params: DocumentHighlightParams = {
112
- textDocument: { uri: 'file:///path/to/document.liquid' },
112
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
113
113
  position: Position.create(0, 4),
114
114
  };
115
115
 
@@ -131,7 +131,7 @@ describe('Module: LiquidBlockTagDocumentHighlightsProvider', () => {
131
131
 
132
132
  it('should return document highlight ranges for liquid comment tags', async () => {
133
133
  const params: DocumentHighlightParams = {
134
- textDocument: { uri: 'file:///path/to/document.liquid' },
134
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
135
135
  position: Position.create(0, 4),
136
136
  };
137
137
 
@@ -153,7 +153,7 @@ describe('Module: LiquidBlockTagDocumentHighlightsProvider', () => {
153
153
 
154
154
  it('should return the correct highlights inside liquid liquid tags', async () => {
155
155
  const params: DocumentHighlightParams = {
156
- textDocument: { uri: 'file:///path/to/document.liquid' },
156
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
157
157
  position: Position.create(1, 10),
158
158
  };
159
159
 
@@ -53,7 +53,7 @@ describe('DocumentLinksProvider', () => {
53
53
  });
54
54
 
55
55
  it('should return a list of document links with correct URLs for a LiquidHtml document', async () => {
56
- uriString = 'file:///path/to/liquid-html-document.liquid';
56
+ uriString = 'file:///app/views/partials/liquid-html-document.liquid';
57
57
  rootUri = 'file:///path/to/project';
58
58
 
59
59
  const liquidHtmlContent = `
@@ -62,7 +62,7 @@ function documentLinksVisitor(
62
62
 
63
63
  const name = node.name as DocumentType;
64
64
 
65
- // render, include, function, theme_render_rc all have a .partial field
65
+ // render, include, function, background, theme_render_rc all have a .partial field
66
66
  if ('partial' in markup && isLiquidString(markup.partial)) {
67
67
  const uri = await documentsLocator.locateOrDefault(
68
68
  root,
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  assertNever,
3
3
  isKnownLiquidFile,
4
+ isSupportedSourceFile,
4
5
  memoize,
5
6
  path,
6
7
  recursiveReadDirectory,
@@ -111,8 +112,7 @@ export class DocumentManager {
111
112
 
112
113
  private set(uri: UriString, source: string, version: number | undefined) {
113
114
  uri = path.normalize(uri);
114
- // We only support json, liquid, graphql, and yaml files.
115
- if (!/\.(json|liquid|graphql|ya?ml)$/.test(uri) || /\.(s?css|js).liquid$/.test(uri)) {
115
+ if (!isSupportedSourceFile(uri)) {
116
116
  return;
117
117
  }
118
118
 
@@ -139,7 +139,7 @@ export class DocumentManager {
139
139
  const filesToLoad = await recursiveReadDirectory(
140
140
  this.fs,
141
141
  rootUri,
142
- ([uri]) => /\.(liquid|json|graphql|ya?ml)$/.test(uri) && !this.sourceCodes.has(uri),
142
+ ([uri]) => isSupportedSourceFile(uri) && !this.sourceCodes.has(uri),
143
143
  );
144
144
 
145
145
  progress.report(10, 'Preloading files');
@@ -20,7 +20,7 @@ describe('Module: BracketsAutoclosingOnTypeFormattingProvider', () => {
20
20
 
21
21
  it('should return a TextEdit to insert a space after "{{" in "{{ }}"', async () => {
22
22
  const params: DocumentOnTypeFormattingParams = {
23
- textDocument: { uri: 'file:///path/to/document.liquid' },
23
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
24
24
  position: Position.create(0, 2),
25
25
  ch: '{',
26
26
  options,
@@ -37,7 +37,7 @@ describe('Module: BracketsAutoclosingOnTypeFormattingProvider', () => {
37
37
 
38
38
  it('should return a TextEdit to insert a space after "{%" in "{% %}"', async () => {
39
39
  const params: DocumentOnTypeFormattingParams = {
40
- textDocument: { uri: 'file:///path/to/document.liquid' },
40
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
41
41
  position: Position.create(0, 2),
42
42
  ch: '%',
43
43
  options,
@@ -54,7 +54,7 @@ describe('Module: BracketsAutoclosingOnTypeFormattingProvider', () => {
54
54
 
55
55
  it('should return a TextEdit to replace and insert characters in "{{ - }}"', async () => {
56
56
  const params: DocumentOnTypeFormattingParams = {
57
- textDocument: { uri: 'file:///path/to/document.liquid' },
57
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
58
58
  position: Position.create(0, 4),
59
59
  ch: '-',
60
60
  options,
@@ -71,7 +71,7 @@ describe('Module: BracketsAutoclosingOnTypeFormattingProvider', () => {
71
71
 
72
72
  it('should return a TextEdit to replace and insert characters in "{% - %}"', async () => {
73
73
  const params: DocumentOnTypeFormattingParams = {
74
- textDocument: { uri: 'file:///path/to/document.liquid' },
74
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
75
75
  position: Position.create(0, 4),
76
76
  ch: '-',
77
77
  options,
@@ -13,7 +13,7 @@ describe('Module: HtmlElementAutoclosingOnTypeFormattingProvider', () => {
13
13
  let documentManager: DocumentManager;
14
14
  let onTypeFormattingProvider: OnTypeFormattingProvider;
15
15
  let setCursorPositionSpy: SetCursorPosition;
16
- const uri = 'file:///path/to/document.liquid';
16
+ const uri = 'file:///app/views/partials/document.liquid';
17
17
 
18
18
  beforeEach(() => {
19
19
  setCursorPositionSpy = vi.fn(async () => {}) as SetCursorPosition;
@@ -161,7 +161,10 @@ describe('Module: LiquidObjectHoverProvider', async () => {
161
161
  { source, relativePath },
162
162
  expect.stringContaining(`## ${object}`),
163
163
  );
164
- await expect(provider).to.hover({ source, relativePath: 'file.liquid' }, null);
164
+ await expect(provider).to.hover(
165
+ { source, relativePath: 'app/views/layouts/main.liquid' },
166
+ null,
167
+ );
165
168
  }
166
169
  });
167
170
 
@@ -16,7 +16,7 @@ describe('Module: EmptyHtmlTagLinkedRangesProvider', () => {
16
16
 
17
17
  it('should return null for non-existent documents', async () => {
18
18
  const params: LinkedEditingRangeParams = {
19
- textDocument: { uri: 'file:///path/to/non-existent-document.liquid' },
19
+ textDocument: { uri: 'file:///app/views/partials/non-existent-document.liquid' },
20
20
  position: Position.create(0, 0),
21
21
  };
22
22
 
@@ -26,7 +26,7 @@ describe('Module: EmptyHtmlTagLinkedRangesProvider', () => {
26
26
 
27
27
  it('should return null for non-empty HTML tags', async () => {
28
28
  const params: LinkedEditingRangeParams = {
29
- textDocument: { uri: 'file:///path/to/document.liquid' },
29
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
30
30
  position: Position.create(0, 0),
31
31
  };
32
32
 
@@ -38,7 +38,7 @@ describe('Module: EmptyHtmlTagLinkedRangesProvider', () => {
38
38
 
39
39
  it('should return linked editing ranges for empty HTML tags', async () => {
40
40
  const params: LinkedEditingRangeParams = {
41
- textDocument: { uri: 'file:///path/to/document.liquid' },
41
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
42
42
  position: Position.create(0, 1), // position within the empty tag
43
43
  };
44
44
 
@@ -62,7 +62,7 @@ describe('Module: EmptyHtmlTagLinkedRangesProvider', () => {
62
62
 
63
63
  it('should return null for positions not within empty HTML tags', async () => {
64
64
  const params: LinkedEditingRangeParams = {
65
- textDocument: { uri: 'file:///path/to/document.liquid' },
65
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
66
66
  position: Position.create(0, 0), // position outside the tag
67
67
  };
68
68
 
@@ -7,7 +7,7 @@ import { htmlElementNameWordPattern } from '../wordPattern';
7
7
  import { TextDocument } from 'vscode-languageserver-textdocument';
8
8
 
9
9
  describe('Module: HtmlTagNameLinkedRangesProvider', () => {
10
- const uri = 'file:///path/to/document.liquid';
10
+ const uri = 'file:///app/views/partials/document.liquid';
11
11
  let documentManager: DocumentManager;
12
12
  let provider: LinkedEditingRangesProvider;
13
13
  let params: LinkedEditingRangeParams;
@@ -23,7 +23,7 @@ describe('HtmlTagNameRenameProvider', () => {
23
23
 
24
24
  it('returns null when the cursor is not over an HTML tag name', async () => {
25
25
  const params = {
26
- textDocument: { uri: 'file:///path/to/document.liquid' },
26
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
27
27
  position: Position.create(0, 0),
28
28
  newName: 'new-name',
29
29
  };
@@ -34,7 +34,7 @@ describe('HtmlTagNameRenameProvider', () => {
34
34
 
35
35
  it('returns the correct workspace edit when renaming an HTML tag name', async () => {
36
36
  const params = {
37
- textDocument: { uri: 'file:///path/to/document.liquid' },
37
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
38
38
  position: Position.create(0, 2),
39
39
  newName: 'new-name',
40
40
  };
@@ -59,7 +59,7 @@ describe('HtmlTagNameRenameProvider', () => {
59
59
 
60
60
  it('also works on complext liquid + text html tag names', async () => {
61
61
  const params = {
62
- textDocument: { uri: 'file:///path/to/document.liquid' },
62
+ textDocument: { uri: 'file:///app/views/partials/document.liquid' },
63
63
  position: Position.create(0, 2),
64
64
  newName: 'new-name',
65
65
  };