yaml-language-server 1.2.2 → 1.3.0
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 +25 -0
- package/README.md +10 -1
- package/lib/esm/languageserver/handlers/settingsHandlers.js +4 -2
- package/lib/esm/languageserver/handlers/settingsHandlers.js.map +1 -1
- package/lib/esm/languageservice/parser/ast-converter.js +9 -1
- package/lib/esm/languageservice/parser/ast-converter.js.map +1 -1
- package/lib/esm/languageservice/parser/jsonParser07.d.ts +2 -2
- package/lib/esm/languageservice/parser/jsonParser07.js +74 -25
- package/lib/esm/languageservice/parser/jsonParser07.js.map +1 -1
- package/lib/esm/languageservice/parser/yaml-documents.d.ts +0 -1
- package/lib/esm/languageservice/parser/yaml-documents.js +11 -11
- package/lib/esm/languageservice/parser/yaml-documents.js.map +1 -1
- package/lib/esm/languageservice/services/documentSymbols.js +3 -2
- package/lib/esm/languageservice/services/documentSymbols.js.map +1 -1
- package/lib/esm/languageservice/services/yamlCodeActions.d.ts +1 -0
- package/lib/esm/languageservice/services/yamlCodeActions.js +14 -0
- package/lib/esm/languageservice/services/yamlCodeActions.js.map +1 -1
- package/lib/esm/languageservice/services/yamlCodeLens.js +2 -1
- package/lib/esm/languageservice/services/yamlCodeLens.js.map +1 -1
- package/lib/esm/languageservice/services/yamlCompletion.d.ts +2 -0
- package/lib/esm/languageservice/services/yamlCompletion.js +183 -40
- package/lib/esm/languageservice/services/yamlCompletion.js.map +1 -1
- package/lib/esm/languageservice/services/yamlDefinition.d.ts +6 -1
- package/lib/esm/languageservice/services/yamlDefinition.js +23 -17
- package/lib/esm/languageservice/services/yamlDefinition.js.map +1 -1
- package/lib/esm/languageservice/services/yamlHover.js +2 -1
- package/lib/esm/languageservice/services/yamlHover.js.map +1 -1
- package/lib/esm/languageservice/services/yamlLinks.js +2 -1
- package/lib/esm/languageservice/services/yamlLinks.js.map +1 -1
- package/lib/esm/languageservice/services/yamlSchemaService.js +12 -0
- package/lib/esm/languageservice/services/yamlSchemaService.js.map +1 -1
- package/lib/esm/languageservice/services/yamlValidation.js +2 -1
- package/lib/esm/languageservice/services/yamlValidation.js.map +1 -1
- package/lib/esm/languageservice/utils/objects.d.ts +5 -0
- package/lib/esm/languageservice/utils/objects.js +13 -0
- package/lib/esm/languageservice/utils/objects.js.map +1 -1
- package/lib/esm/languageservice/utils/schemaUrls.d.ts +1 -1
- package/lib/esm/languageservice/utils/schemaUrls.js +1 -1
- package/lib/esm/languageservice/yamlLanguageService.d.ts +4 -0
- package/lib/esm/languageservice/yamlLanguageService.js +3 -2
- package/lib/esm/languageservice/yamlLanguageService.js.map +1 -1
- package/lib/esm/server.js +5 -0
- package/lib/esm/server.js.map +1 -1
- package/lib/esm/yamlSettings.d.ts +2 -0
- package/lib/esm/yamlSettings.js +1 -0
- package/lib/esm/yamlSettings.js.map +1 -1
- package/lib/umd/languageserver/handlers/settingsHandlers.js +5 -3
- package/lib/umd/languageserver/handlers/settingsHandlers.js.map +1 -1
- package/lib/umd/languageservice/parser/ast-converter.js +9 -1
- package/lib/umd/languageservice/parser/ast-converter.js.map +1 -1
- package/lib/umd/languageservice/parser/jsonParser07.d.ts +2 -2
- package/lib/umd/languageservice/parser/jsonParser07.js +77 -28
- package/lib/umd/languageservice/parser/jsonParser07.js.map +1 -1
- package/lib/umd/languageservice/parser/yaml-documents.d.ts +0 -1
- package/lib/umd/languageservice/parser/yaml-documents.js +10 -10
- package/lib/umd/languageservice/parser/yaml-documents.js.map +1 -1
- package/lib/umd/languageservice/services/documentSymbols.js +4 -3
- package/lib/umd/languageservice/services/documentSymbols.js.map +1 -1
- package/lib/umd/languageservice/services/yamlCodeActions.d.ts +1 -0
- package/lib/umd/languageservice/services/yamlCodeActions.js +14 -0
- package/lib/umd/languageservice/services/yamlCodeActions.js.map +1 -1
- package/lib/umd/languageservice/services/yamlCodeLens.js +3 -2
- package/lib/umd/languageservice/services/yamlCodeLens.js.map +1 -1
- package/lib/umd/languageservice/services/yamlCompletion.d.ts +2 -0
- package/lib/umd/languageservice/services/yamlCompletion.js +182 -39
- package/lib/umd/languageservice/services/yamlCompletion.js.map +1 -1
- package/lib/umd/languageservice/services/yamlDefinition.d.ts +6 -1
- package/lib/umd/languageservice/services/yamlDefinition.js +26 -20
- package/lib/umd/languageservice/services/yamlDefinition.js.map +1 -1
- package/lib/umd/languageservice/services/yamlHover.js +3 -2
- package/lib/umd/languageservice/services/yamlHover.js.map +1 -1
- package/lib/umd/languageservice/services/yamlLinks.js +3 -2
- package/lib/umd/languageservice/services/yamlLinks.js.map +1 -1
- package/lib/umd/languageservice/services/yamlSchemaService.js +12 -0
- package/lib/umd/languageservice/services/yamlSchemaService.js.map +1 -1
- package/lib/umd/languageservice/services/yamlValidation.js +3 -2
- package/lib/umd/languageservice/services/yamlValidation.js.map +1 -1
- package/lib/umd/languageservice/utils/objects.d.ts +5 -0
- package/lib/umd/languageservice/utils/objects.js +15 -1
- package/lib/umd/languageservice/utils/objects.js.map +1 -1
- package/lib/umd/languageservice/utils/schemaUrls.d.ts +1 -1
- package/lib/umd/languageservice/utils/schemaUrls.js +1 -1
- package/lib/umd/languageservice/yamlLanguageService.d.ts +4 -0
- package/lib/umd/languageservice/yamlLanguageService.js +2 -1
- package/lib/umd/languageservice/yamlLanguageService.js.map +1 -1
- package/lib/umd/server.js +6 -1
- package/lib/umd/server.js.map +1 -1
- package/lib/umd/yamlSettings.d.ts +2 -0
- package/lib/umd/yamlSettings.js +1 -0
- package/lib/umd/yamlSettings.js.map +1 -1
- package/out/server/src/languageserver/handlers/settingsHandlers.js +4 -2
- package/out/server/src/languageserver/handlers/settingsHandlers.js.map +1 -1
- package/out/server/src/languageservice/parser/ast-converter.js +9 -1
- package/out/server/src/languageservice/parser/ast-converter.js.map +1 -1
- package/out/server/src/languageservice/parser/jsonParser07.d.ts +2 -2
- package/out/server/src/languageservice/parser/jsonParser07.js +76 -27
- package/out/server/src/languageservice/parser/jsonParser07.js.map +1 -1
- package/out/server/src/languageservice/parser/yaml-documents.d.ts +0 -1
- package/out/server/src/languageservice/parser/yaml-documents.js +10 -10
- package/out/server/src/languageservice/parser/yaml-documents.js.map +1 -1
- package/out/server/src/languageservice/services/documentSymbols.js +3 -2
- package/out/server/src/languageservice/services/documentSymbols.js.map +1 -1
- package/out/server/src/languageservice/services/yamlCodeActions.d.ts +1 -0
- package/out/server/src/languageservice/services/yamlCodeActions.js +14 -0
- package/out/server/src/languageservice/services/yamlCodeActions.js.map +1 -1
- package/out/server/src/languageservice/services/yamlCodeLens.js +2 -1
- package/out/server/src/languageservice/services/yamlCodeLens.js.map +1 -1
- package/out/server/src/languageservice/services/yamlCompletion.d.ts +2 -0
- package/out/server/src/languageservice/services/yamlCompletion.js +181 -38
- package/out/server/src/languageservice/services/yamlCompletion.js.map +1 -1
- package/out/server/src/languageservice/services/yamlDefinition.d.ts +6 -1
- package/out/server/src/languageservice/services/yamlDefinition.js +25 -19
- package/out/server/src/languageservice/services/yamlDefinition.js.map +1 -1
- package/out/server/src/languageservice/services/yamlHover.js +2 -1
- package/out/server/src/languageservice/services/yamlHover.js.map +1 -1
- package/out/server/src/languageservice/services/yamlLinks.js +2 -1
- package/out/server/src/languageservice/services/yamlLinks.js.map +1 -1
- package/out/server/src/languageservice/services/yamlSchemaService.js +12 -0
- package/out/server/src/languageservice/services/yamlSchemaService.js.map +1 -1
- package/out/server/src/languageservice/services/yamlValidation.js +2 -1
- package/out/server/src/languageservice/services/yamlValidation.js.map +1 -1
- package/out/server/src/languageservice/utils/objects.d.ts +5 -0
- package/out/server/src/languageservice/utils/objects.js +15 -1
- package/out/server/src/languageservice/utils/objects.js.map +1 -1
- package/out/server/src/languageservice/utils/schemaUrls.d.ts +1 -1
- package/out/server/src/languageservice/utils/schemaUrls.js +1 -1
- package/out/server/src/languageservice/yamlLanguageService.d.ts +4 -0
- package/out/server/src/languageservice/yamlLanguageService.js +2 -1
- package/out/server/src/languageservice/yamlLanguageService.js.map +1 -1
- package/out/server/src/server.js +5 -0
- package/out/server/src/server.js.map +1 -1
- package/out/server/src/yamlSettings.d.ts +2 -0
- package/out/server/src/yamlSettings.js +1 -0
- package/out/server/src/yamlSettings.js.map +1 -1
- package/out/server/test/autoCompletion.test.js +410 -74
- package/out/server/test/autoCompletion.test.js.map +1 -1
- package/out/server/test/autoCompletionFix.test.js +219 -3
- package/out/server/test/autoCompletionFix.test.js.map +1 -1
- package/out/server/test/code-action-schema.test.d.ts +1 -0
- package/out/server/test/code-action-schema.test.js +99 -0
- package/out/server/test/code-action-schema.test.js.map +1 -0
- package/out/server/test/defaultSnippets.test.js +3 -3
- package/out/server/test/defaultSnippets.test.js.map +1 -1
- package/out/server/test/hover.test.js +70 -0
- package/out/server/test/hover.test.js.map +1 -1
- package/out/server/test/integration.test.js +1 -1
- package/out/server/test/jsonParser.test.js +23 -13
- package/out/server/test/jsonParser.test.js.map +1 -1
- package/out/server/test/objects.test.js +16 -0
- package/out/server/test/objects.test.js.map +1 -1
- package/out/server/test/schema.test.js +18 -0
- package/out/server/test/schema.test.js.map +1 -1
- package/out/server/test/yamlDefinition.test.js +8 -2
- package/out/server/test/yamlDefinition.test.js.map +1 -1
- package/out/server/test/yamlParser.test.js +10 -0
- package/out/server/test/yamlParser.test.js.map +1 -1
- package/out/server/test/yamlSchemaService.test.js +21 -0
- package/out/server/test/yamlSchemaService.test.js.map +1 -1
- package/package.json +8 -6
|
@@ -66,7 +66,7 @@ describe('Auto Completion Tests', () => {
|
|
|
66
66
|
completion
|
|
67
67
|
.then(function (result) {
|
|
68
68
|
assert.equal(result.items.length, 1);
|
|
69
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('name', 'name:
|
|
69
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('name', 'name: ', 0, 0, 0, 0, 10, 2, {
|
|
70
70
|
documentation: '',
|
|
71
71
|
}));
|
|
72
72
|
})
|
|
@@ -86,7 +86,7 @@ describe('Auto Completion Tests', () => {
|
|
|
86
86
|
completion
|
|
87
87
|
.then(function (result) {
|
|
88
88
|
assert.equal(result.items.length, 1);
|
|
89
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('name', 'name:
|
|
89
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('name', 'name: ', 0, 0, 0, 2, 10, 2, {
|
|
90
90
|
documentation: '',
|
|
91
91
|
}));
|
|
92
92
|
})
|
|
@@ -140,8 +140,7 @@ describe('Auto Completion Tests', () => {
|
|
|
140
140
|
properties: {
|
|
141
141
|
name: {
|
|
142
142
|
type: 'string',
|
|
143
|
-
|
|
144
|
-
default: '\"yaml\"',
|
|
143
|
+
default: '"yaml"',
|
|
145
144
|
},
|
|
146
145
|
},
|
|
147
146
|
});
|
|
@@ -158,8 +157,7 @@ describe('Auto Completion Tests', () => {
|
|
|
158
157
|
properties: {
|
|
159
158
|
name: {
|
|
160
159
|
type: 'string',
|
|
161
|
-
|
|
162
|
-
default: '\"yaml\"',
|
|
160
|
+
default: '"yaml"',
|
|
163
161
|
},
|
|
164
162
|
},
|
|
165
163
|
});
|
|
@@ -331,6 +329,63 @@ describe('Auto Completion Tests', () => {
|
|
|
331
329
|
})
|
|
332
330
|
.then(done, done);
|
|
333
331
|
});
|
|
332
|
+
it('Autocomplete without default value - not required', () => __awaiter(this, void 0, void 0, function* () {
|
|
333
|
+
const languageSettingsSetup = new serviceSetup_1.ServiceSetup().withCompletion();
|
|
334
|
+
languageSettingsSetup.languageSettings.disableDefaultProperties = true;
|
|
335
|
+
languageService.configure(languageSettingsSetup.languageSettings);
|
|
336
|
+
languageService.addSchema(testHelper_1.SCHEMA_ID, {
|
|
337
|
+
type: 'object',
|
|
338
|
+
properties: {
|
|
339
|
+
scripts: {
|
|
340
|
+
type: 'object',
|
|
341
|
+
properties: {
|
|
342
|
+
sample: {
|
|
343
|
+
type: 'string',
|
|
344
|
+
default: 'test',
|
|
345
|
+
},
|
|
346
|
+
objectSample: {
|
|
347
|
+
type: 'object',
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
});
|
|
353
|
+
const content = '';
|
|
354
|
+
const result = yield parseSetup(content, 0);
|
|
355
|
+
chai_1.expect(result.items.length).to.be.equal(1);
|
|
356
|
+
chai_1.expect(result.items[0]).to.deep.equal(verifyError_1.createExpectedCompletion('scripts', 'scripts:\n ', 0, 0, 0, 0, 10, 2, {
|
|
357
|
+
documentation: '',
|
|
358
|
+
}));
|
|
359
|
+
}));
|
|
360
|
+
it('Autocomplete without default value - required', () => __awaiter(this, void 0, void 0, function* () {
|
|
361
|
+
const languageSettingsSetup = new serviceSetup_1.ServiceSetup().withCompletion();
|
|
362
|
+
languageSettingsSetup.languageSettings.disableDefaultProperties = true;
|
|
363
|
+
languageService.configure(languageSettingsSetup.languageSettings);
|
|
364
|
+
languageService.addSchema(testHelper_1.SCHEMA_ID, {
|
|
365
|
+
type: 'object',
|
|
366
|
+
properties: {
|
|
367
|
+
scripts: {
|
|
368
|
+
type: 'object',
|
|
369
|
+
properties: {
|
|
370
|
+
sample: {
|
|
371
|
+
type: 'string',
|
|
372
|
+
default: 'test',
|
|
373
|
+
},
|
|
374
|
+
objectSample: {
|
|
375
|
+
type: 'object',
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
required: ['sample', 'objectSample'],
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
const content = '';
|
|
383
|
+
const result = yield parseSetup(content, 0);
|
|
384
|
+
chai_1.expect(result.items.length).to.be.equal(1);
|
|
385
|
+
chai_1.expect(result.items[0]).to.deep.equal(verifyError_1.createExpectedCompletion('scripts', 'scripts:\n sample: ${1:test}\n objectSample:\n $2', 0, 0, 0, 0, 10, 2, {
|
|
386
|
+
documentation: '',
|
|
387
|
+
}));
|
|
388
|
+
}));
|
|
334
389
|
it('Autocomplete second key in middle of file', (done) => {
|
|
335
390
|
languageService.addSchema(testHelper_1.SCHEMA_ID, {
|
|
336
391
|
type: 'object',
|
|
@@ -552,7 +607,7 @@ describe('Auto Completion Tests', () => {
|
|
|
552
607
|
completion
|
|
553
608
|
.then(function (result) {
|
|
554
609
|
assert.equal(result.items.length, 1);
|
|
555
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('top', 'top:\n prop1:
|
|
610
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('top', 'top:\n prop1: ', 2, 2, 2, 2, 10, 2, {
|
|
556
611
|
documentation: '',
|
|
557
612
|
}));
|
|
558
613
|
})
|
|
@@ -566,7 +621,7 @@ describe('Auto Completion Tests', () => {
|
|
|
566
621
|
completion
|
|
567
622
|
.then(function (result) {
|
|
568
623
|
assert.equal(result.items.length, 1);
|
|
569
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('top', 'top:\n prop1:
|
|
624
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('top', 'top:\n prop1: ', 0, 2, 0, 2, 10, 2, {
|
|
570
625
|
documentation: '',
|
|
571
626
|
}));
|
|
572
627
|
})
|
|
@@ -580,19 +635,19 @@ describe('Auto Completion Tests', () => {
|
|
|
580
635
|
completion
|
|
581
636
|
.then(function (result) {
|
|
582
637
|
assert.equal(result.items.length, 3);
|
|
583
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('prop1', 'prop1:
|
|
638
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('prop1', 'prop1: ', 0, 2, 0, 2, 10, 2, {
|
|
584
639
|
documentation: '',
|
|
585
640
|
}));
|
|
586
|
-
assert.deepEqual(result.items[1], verifyError_1.createExpectedCompletion('prop2', 'prop2:
|
|
641
|
+
assert.deepEqual(result.items[1], verifyError_1.createExpectedCompletion('prop2', 'prop2: ', 0, 2, 0, 2, 10, 2, {
|
|
587
642
|
documentation: '',
|
|
588
643
|
}));
|
|
589
|
-
assert.deepEqual(result.items[2], verifyError_1.createExpectedCompletion('prop3', 'prop3:
|
|
644
|
+
assert.deepEqual(result.items[2], verifyError_1.createExpectedCompletion('prop3', 'prop3: ', 0, 2, 0, 2, 10, 2, {
|
|
590
645
|
documentation: '',
|
|
591
646
|
}));
|
|
592
647
|
})
|
|
593
648
|
.then(done, done);
|
|
594
649
|
});
|
|
595
|
-
it('Provide the
|
|
650
|
+
it('Provide the 2 types when one is provided', (done) => {
|
|
596
651
|
const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json'));
|
|
597
652
|
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
598
653
|
const content = '- prop1:\n ';
|
|
@@ -600,10 +655,27 @@ describe('Auto Completion Tests', () => {
|
|
|
600
655
|
completion
|
|
601
656
|
.then(function (result) {
|
|
602
657
|
assert.equal(result.items.length, 2);
|
|
603
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('prop2', 'prop2:
|
|
658
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('prop2', 'prop2: ', 1, 2, 1, 2, 10, 2, {
|
|
659
|
+
documentation: '',
|
|
660
|
+
}));
|
|
661
|
+
assert.deepEqual(result.items[1], verifyError_1.createExpectedCompletion('prop3', 'prop3: ', 1, 2, 1, 2, 10, 2, {
|
|
662
|
+
documentation: '',
|
|
663
|
+
}));
|
|
664
|
+
})
|
|
665
|
+
.then(done, done);
|
|
666
|
+
});
|
|
667
|
+
it('Provide the 2 types when one is provided and the second is typed', (done) => {
|
|
668
|
+
const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json'));
|
|
669
|
+
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
670
|
+
const content = '- prop1:\n p';
|
|
671
|
+
const completion = parseSetup(content, content.length);
|
|
672
|
+
completion
|
|
673
|
+
.then(function (result) {
|
|
674
|
+
assert.equal(result.items.length, 2);
|
|
675
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('prop2', 'prop2: ', 1, 2, 1, 3, 10, 2, {
|
|
604
676
|
documentation: '',
|
|
605
677
|
}));
|
|
606
|
-
assert.deepEqual(result.items[1], verifyError_1.createExpectedCompletion('prop3', 'prop3:
|
|
678
|
+
assert.deepEqual(result.items[1], verifyError_1.createExpectedCompletion('prop3', 'prop3: ', 1, 2, 1, 3, 10, 2, {
|
|
607
679
|
documentation: '',
|
|
608
680
|
}));
|
|
609
681
|
})
|
|
@@ -655,7 +727,7 @@ describe('Auto Completion Tests', () => {
|
|
|
655
727
|
const content = '';
|
|
656
728
|
const completion = yield parseSetup(content, 0);
|
|
657
729
|
chai_1.expect(completion.items.length).to.be.equal(1);
|
|
658
|
-
chai_1.expect(completion.items[0]).to.deep.equal(verifyError_1.createExpectedCompletion('test: colon', '"test: colon":\n
|
|
730
|
+
chai_1.expect(completion.items[0]).to.deep.equal(verifyError_1.createExpectedCompletion('test: colon', '"test: colon":\n ', 0, 0, 0, 0, 10, 2, {
|
|
659
731
|
documentation: '',
|
|
660
732
|
}));
|
|
661
733
|
}));
|
|
@@ -677,7 +749,7 @@ describe('Auto Completion Tests', () => {
|
|
|
677
749
|
const content = '';
|
|
678
750
|
const completion = yield parseSetup(content, 0);
|
|
679
751
|
chai_1.expect(completion.items.length).to.be.equal(1);
|
|
680
|
-
chai_1.expect(completion.items[0]).to.deep.equal(verifyError_1.createExpectedCompletion('test:colon', 'test:colon:\n
|
|
752
|
+
chai_1.expect(completion.items[0]).to.deep.equal(verifyError_1.createExpectedCompletion('test:colon', 'test:colon:\n ', 0, 0, 0, 0, 10, 2, {
|
|
681
753
|
documentation: '',
|
|
682
754
|
}));
|
|
683
755
|
}));
|
|
@@ -699,7 +771,7 @@ describe('Auto Completion Tests', () => {
|
|
|
699
771
|
const content = '';
|
|
700
772
|
const completion = yield parseSetup(content, 0);
|
|
701
773
|
chai_1.expect(completion.items.length).to.be.equal(1);
|
|
702
|
-
chai_1.expect(completion.items[0]).to.deep.equal(verifyError_1.createExpectedCompletion(':colon', ':colon:\n
|
|
774
|
+
chai_1.expect(completion.items[0]).to.deep.equal(verifyError_1.createExpectedCompletion(':colon', ':colon:\n ', 0, 0, 0, 0, 10, 2, {
|
|
703
775
|
documentation: '',
|
|
704
776
|
}));
|
|
705
777
|
}));
|
|
@@ -738,7 +810,7 @@ describe('Auto Completion Tests', () => {
|
|
|
738
810
|
completion
|
|
739
811
|
.then(function (result) {
|
|
740
812
|
assert.equal(result.items.length, 1);
|
|
741
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('name', 'name:
|
|
813
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('name', 'name: ', 1, 4, 1, 4, 10, 2, {
|
|
742
814
|
documentation: '',
|
|
743
815
|
}));
|
|
744
816
|
})
|
|
@@ -766,8 +838,8 @@ describe('Auto Completion Tests', () => {
|
|
|
766
838
|
completion
|
|
767
839
|
.then(function (result) {
|
|
768
840
|
assert.equal(result.items.length, 1);
|
|
769
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('- (array item)', '-
|
|
770
|
-
documentation: 'Create an item of an array',
|
|
841
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('- (array item)', '- ', 1, 2, 1, 3, 9, 2, {
|
|
842
|
+
documentation: { kind: 'markdown', value: 'Create an item of an array\n ```\n- \n```' },
|
|
771
843
|
}));
|
|
772
844
|
})
|
|
773
845
|
.then(done, done);
|
|
@@ -797,8 +869,8 @@ describe('Auto Completion Tests', () => {
|
|
|
797
869
|
completion
|
|
798
870
|
.then(function (result) {
|
|
799
871
|
assert.equal(result.items.length, 1);
|
|
800
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('- (array item)', '-
|
|
801
|
-
documentation: 'Create an item of an array',
|
|
872
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('- (array item)', '- ', 2, 2, 2, 2, 9, 2, {
|
|
873
|
+
documentation: { kind: 'markdown', value: 'Create an item of an array\n ```\n- \n```' },
|
|
802
874
|
}));
|
|
803
875
|
})
|
|
804
876
|
.then(done, done);
|
|
@@ -828,8 +900,8 @@ describe('Auto Completion Tests', () => {
|
|
|
828
900
|
completion
|
|
829
901
|
.then(function (result) {
|
|
830
902
|
assert.equal(result.items.length, 1);
|
|
831
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('- (array item)', '-
|
|
832
|
-
documentation: 'Create an item of an array',
|
|
903
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('- (array item)', '- ', 1, 0, 1, 0, 9, 2, {
|
|
904
|
+
documentation: { kind: 'markdown', value: 'Create an item of an array\n ```\n- \n```' },
|
|
833
905
|
}));
|
|
834
906
|
})
|
|
835
907
|
.then(done, done);
|
|
@@ -856,7 +928,7 @@ describe('Auto Completion Tests', () => {
|
|
|
856
928
|
completion
|
|
857
929
|
.then(function (result) {
|
|
858
930
|
assert.equal(result.items.length, 1);
|
|
859
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('name', 'name:
|
|
931
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('name', 'name: ', 1, 4, 1, 5, 10, 2, {
|
|
860
932
|
documentation: '',
|
|
861
933
|
}));
|
|
862
934
|
})
|
|
@@ -887,7 +959,7 @@ describe('Auto Completion Tests', () => {
|
|
|
887
959
|
completion
|
|
888
960
|
.then(function (result) {
|
|
889
961
|
assert.equal(result.items.length, 1);
|
|
890
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('email', 'email:
|
|
962
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('email', 'email: ', 2, 4, 2, 4, 10, 2, {
|
|
891
963
|
documentation: '',
|
|
892
964
|
}));
|
|
893
965
|
})
|
|
@@ -918,7 +990,7 @@ describe('Auto Completion Tests', () => {
|
|
|
918
990
|
completion
|
|
919
991
|
.then(function (result) {
|
|
920
992
|
assert.equal(result.items.length, 1);
|
|
921
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('email', 'email:
|
|
993
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('email', 'email: ', 2, 3, 2, 3, 10, 2, {
|
|
922
994
|
documentation: '',
|
|
923
995
|
}));
|
|
924
996
|
})
|
|
@@ -952,7 +1024,7 @@ describe('Auto Completion Tests', () => {
|
|
|
952
1024
|
completion
|
|
953
1025
|
.then(function (result) {
|
|
954
1026
|
assert.equal(result.items.length, 1);
|
|
955
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('load', 'load:
|
|
1027
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('load', 'load: ', 2, 0, 2, 0, 10, 2, {
|
|
956
1028
|
documentation: '',
|
|
957
1029
|
}));
|
|
958
1030
|
})
|
|
@@ -1029,7 +1101,7 @@ describe('Auto Completion Tests', () => {
|
|
|
1029
1101
|
.then(function (result) {
|
|
1030
1102
|
assert.equal(result.items.length, 1);
|
|
1031
1103
|
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('- (array item)', '- name: ${1:test}', 3, 4, 3, 4, 9, 2, {
|
|
1032
|
-
documentation: 'Create an item of an array',
|
|
1104
|
+
documentation: { kind: 'markdown', value: 'Create an item of an array\n ```\n- name: test\n```' },
|
|
1033
1105
|
}));
|
|
1034
1106
|
})
|
|
1035
1107
|
.then(done, done);
|
|
@@ -1332,6 +1404,43 @@ describe('Auto Completion Tests', () => {
|
|
|
1332
1404
|
})
|
|
1333
1405
|
.then(done, done);
|
|
1334
1406
|
});
|
|
1407
|
+
it('Autocomplete should suggest prop with const value', (done) => {
|
|
1408
|
+
languageService.addSchema(testHelper_1.SCHEMA_ID, {
|
|
1409
|
+
type: 'object',
|
|
1410
|
+
properties: {
|
|
1411
|
+
fruit: {
|
|
1412
|
+
const: 'Apple',
|
|
1413
|
+
},
|
|
1414
|
+
},
|
|
1415
|
+
});
|
|
1416
|
+
const content = '';
|
|
1417
|
+
const completion = parseSetup(content, 0);
|
|
1418
|
+
completion
|
|
1419
|
+
.then(function (result) {
|
|
1420
|
+
assert.equal(result.items.length, 1);
|
|
1421
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('fruit', 'fruit: Apple', 0, 0, 0, 0, 10, 2, {
|
|
1422
|
+
documentation: '',
|
|
1423
|
+
}));
|
|
1424
|
+
})
|
|
1425
|
+
.then(done, done);
|
|
1426
|
+
});
|
|
1427
|
+
it('Should insert quotation value if there is special char', () => __awaiter(this, void 0, void 0, function* () {
|
|
1428
|
+
languageService.addSchema(testHelper_1.SCHEMA_ID, {
|
|
1429
|
+
type: 'object',
|
|
1430
|
+
properties: {
|
|
1431
|
+
from: {
|
|
1432
|
+
type: 'string',
|
|
1433
|
+
const: '@test',
|
|
1434
|
+
},
|
|
1435
|
+
},
|
|
1436
|
+
});
|
|
1437
|
+
const content = 'from: ';
|
|
1438
|
+
const completion = yield parseSetup(content, content.length);
|
|
1439
|
+
chai_1.expect(completion.items.length).equal(1);
|
|
1440
|
+
chai_1.expect(completion.items[0]).to.deep.equal(verifyError_1.createExpectedCompletion('@test', '"@test"', 0, 6, 0, 6, 12, 2, {
|
|
1441
|
+
documentation: undefined,
|
|
1442
|
+
}));
|
|
1443
|
+
}));
|
|
1335
1444
|
});
|
|
1336
1445
|
describe('Indentation Specific Tests', function () {
|
|
1337
1446
|
it('Indent should be considered with position relative to slash', (done) => {
|
|
@@ -1341,8 +1450,8 @@ describe('Auto Completion Tests', () => {
|
|
|
1341
1450
|
const completion = parseSetup(content, content.lastIndexOf('he') + 2);
|
|
1342
1451
|
completion
|
|
1343
1452
|
.then(function (result) {
|
|
1344
|
-
assert.equal(result.items.length,
|
|
1345
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('helm', 'helm:\n name:
|
|
1453
|
+
assert.equal(result.items.length, 2);
|
|
1454
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('helm', 'helm:\n name: ', 1, 4, 1, 6, 10, 2, {
|
|
1346
1455
|
documentation: '',
|
|
1347
1456
|
}));
|
|
1348
1457
|
})
|
|
@@ -1355,8 +1464,8 @@ describe('Auto Completion Tests', () => {
|
|
|
1355
1464
|
const completion = parseSetup(content, content.lastIndexOf('he') + 2);
|
|
1356
1465
|
completion
|
|
1357
1466
|
.then(function (result) {
|
|
1358
|
-
assert.equal(result.items.length,
|
|
1359
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('helm', 'helm:\n name:
|
|
1467
|
+
assert.equal(result.items.length, 2);
|
|
1468
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('helm', 'helm:\n name: ', 1, 14, 1, 16, 10, 2, {
|
|
1360
1469
|
documentation: '',
|
|
1361
1470
|
}));
|
|
1362
1471
|
})
|
|
@@ -1369,8 +1478,8 @@ describe('Auto Completion Tests', () => {
|
|
|
1369
1478
|
const completion = parseSetup(content, content.lastIndexOf('he') + 2);
|
|
1370
1479
|
completion
|
|
1371
1480
|
.then(function (result) {
|
|
1372
|
-
assert.equal(result.items.length,
|
|
1373
|
-
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('helm', 'helm:\n \t name:
|
|
1481
|
+
assert.equal(result.items.length, 2);
|
|
1482
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('helm', 'helm:\n \t name: ', 1, 16, 1, 18, 10, 2, {
|
|
1374
1483
|
documentation: '',
|
|
1375
1484
|
}));
|
|
1376
1485
|
})
|
|
@@ -1770,8 +1879,8 @@ describe('Auto Completion Tests', () => {
|
|
|
1770
1879
|
const content = ' \n\n\n';
|
|
1771
1880
|
const completion = yield parseSetup(content, 3);
|
|
1772
1881
|
chai_1.expect(completion.items).lengthOf(2);
|
|
1773
|
-
chai_1.expect(completion.items[0]).eql(verifyError_1.createExpectedCompletion('kind', 'kind:
|
|
1774
|
-
chai_1.expect(completion.items[1]).eql(verifyError_1.createExpectedCompletion('name', 'name:
|
|
1882
|
+
chai_1.expect(completion.items[0]).eql(verifyError_1.createExpectedCompletion('kind', 'kind: ', 2, 0, 2, 0, 10, vscode_languageserver_1.InsertTextFormat.Snippet, { documentation: '' }));
|
|
1883
|
+
chai_1.expect(completion.items[1]).eql(verifyError_1.createExpectedCompletion('name', 'name: ', 2, 0, 2, 0, 10, vscode_languageserver_1.InsertTextFormat.Snippet, { documentation: '' }));
|
|
1775
1884
|
}));
|
|
1776
1885
|
it('should not provide additional ":" on existing property completion', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1777
1886
|
languageService.addSchema(testHelper_1.SCHEMA_ID, {
|
|
@@ -1785,7 +1894,7 @@ describe('Auto Completion Tests', () => {
|
|
|
1785
1894
|
});
|
|
1786
1895
|
const content = 'kind: 111\n';
|
|
1787
1896
|
const completion = yield parseSetup(content, 3);
|
|
1788
|
-
chai_1.expect(completion.items).lengthOf(
|
|
1897
|
+
chai_1.expect(completion.items).lengthOf(2);
|
|
1789
1898
|
chai_1.expect(completion.items[0]).eql(verifyError_1.createExpectedCompletion('kind', 'kind', 0, 0, 0, 4, 10, vscode_languageserver_1.InsertTextFormat.Snippet, { documentation: '' }));
|
|
1790
1899
|
}));
|
|
1791
1900
|
it('should not provide additional ":" on existing property completion when try to complete partial property', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1800,7 +1909,7 @@ describe('Auto Completion Tests', () => {
|
|
|
1800
1909
|
});
|
|
1801
1910
|
const content = 'ki: 111\n';
|
|
1802
1911
|
const completion = yield parseSetup(content, 1);
|
|
1803
|
-
chai_1.expect(completion.items).lengthOf(
|
|
1912
|
+
chai_1.expect(completion.items).lengthOf(2);
|
|
1804
1913
|
chai_1.expect(completion.items[0]).eql(verifyError_1.createExpectedCompletion('kind', 'kind', 0, 0, 0, 2, 10, vscode_languageserver_1.InsertTextFormat.Snippet, { documentation: '' }));
|
|
1805
1914
|
}));
|
|
1806
1915
|
it('should use markdownDescription for property completion', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1817,8 +1926,8 @@ describe('Auto Completion Tests', () => {
|
|
|
1817
1926
|
});
|
|
1818
1927
|
const content = 'kin';
|
|
1819
1928
|
const completion = yield parseSetup(content, 1);
|
|
1820
|
-
chai_1.expect(completion.items).lengthOf(
|
|
1821
|
-
chai_1.expect(completion.items[0]).eql(verifyError_1.createExpectedCompletion('kind', 'kind:
|
|
1929
|
+
chai_1.expect(completion.items).lengthOf(2);
|
|
1930
|
+
chai_1.expect(completion.items[0]).eql(verifyError_1.createExpectedCompletion('kind', 'kind: ', 0, 0, 0, 3, 10, vscode_languageserver_1.InsertTextFormat.Snippet, {
|
|
1822
1931
|
documentation: {
|
|
1823
1932
|
kind: vscode_languageserver_1.MarkupKind.Markdown,
|
|
1824
1933
|
value: '**kind** (string)\n\nKind is a string value representing the REST resource this object represents.',
|
|
@@ -1909,86 +2018,313 @@ describe('Auto Completion Tests', () => {
|
|
|
1909
2018
|
}));
|
|
1910
2019
|
});
|
|
1911
2020
|
describe('Array completion', () => {
|
|
1912
|
-
it('Simple array object completion with "-" without any item', () =>
|
|
2021
|
+
it('Simple array object completion with "-" without any item', (done) => {
|
|
1913
2022
|
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
|
|
1914
2023
|
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
1915
2024
|
const content = 'test_simpleArrayObject:\n -';
|
|
1916
2025
|
const completion = parseSetup(content, content.length);
|
|
1917
|
-
completion
|
|
2026
|
+
completion
|
|
2027
|
+
.then(function (result) {
|
|
1918
2028
|
assert.equal(result.items.length, 1);
|
|
1919
2029
|
assert.equal(result.items[0].label, '- (array item)');
|
|
1920
|
-
})
|
|
1921
|
-
|
|
1922
|
-
|
|
2030
|
+
})
|
|
2031
|
+
.then(done, done);
|
|
2032
|
+
});
|
|
2033
|
+
it('Simple array object completion without "-" after array item', (done) => {
|
|
1923
2034
|
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
|
|
1924
2035
|
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
1925
2036
|
const content = 'test_simpleArrayObject:\n - obj1:\n name: 1\n ';
|
|
1926
2037
|
const completion = parseSetup(content, content.length);
|
|
1927
|
-
completion
|
|
2038
|
+
completion
|
|
2039
|
+
.then(function (result) {
|
|
1928
2040
|
assert.equal(result.items.length, 1);
|
|
1929
2041
|
assert.equal(result.items[0].label, '- (array item)');
|
|
1930
|
-
})
|
|
1931
|
-
|
|
1932
|
-
|
|
2042
|
+
})
|
|
2043
|
+
.then(done, done);
|
|
2044
|
+
});
|
|
2045
|
+
it('Simple array object completion with "-" after array item', (done) => {
|
|
1933
2046
|
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
|
|
1934
2047
|
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
1935
2048
|
const content = 'test_simpleArrayObject:\n - obj1:\n name: 1\n -';
|
|
1936
2049
|
const completion = parseSetup(content, content.length);
|
|
1937
|
-
completion
|
|
2050
|
+
completion
|
|
2051
|
+
.then(function (result) {
|
|
1938
2052
|
assert.equal(result.items.length, 1);
|
|
1939
2053
|
assert.equal(result.items[0].label, '- (array item)');
|
|
1940
|
-
})
|
|
1941
|
-
|
|
1942
|
-
|
|
2054
|
+
})
|
|
2055
|
+
.then(done, done);
|
|
2056
|
+
});
|
|
2057
|
+
it('Array anyOf two objects completion with "- " without any item', (done) => {
|
|
1943
2058
|
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
|
|
1944
2059
|
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
1945
2060
|
const content = 'test_array_anyOf_2objects:\n - ';
|
|
1946
2061
|
const completion = parseSetup(content, content.length);
|
|
1947
|
-
completion
|
|
1948
|
-
|
|
2062
|
+
completion
|
|
2063
|
+
.then(function (result) {
|
|
2064
|
+
assert.equal(result.items.length, 4);
|
|
1949
2065
|
assert.equal(result.items[0].label, 'obj1');
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2066
|
+
assert.equal(result.items[0].kind, 10);
|
|
2067
|
+
assert.equal(result.items[1].label, 'obj1');
|
|
2068
|
+
assert.equal(result.items[1].kind, 7);
|
|
2069
|
+
})
|
|
2070
|
+
.then(done, done);
|
|
2071
|
+
});
|
|
2072
|
+
it('Array anyOf two objects completion with "-" without any item', (done) => {
|
|
1953
2073
|
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
|
|
1954
2074
|
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
1955
2075
|
const content = 'test_array_anyOf_2objects:\n -';
|
|
1956
2076
|
const completion = parseSetup(content, content.length);
|
|
1957
|
-
completion
|
|
2077
|
+
completion
|
|
2078
|
+
.then(function (result) {
|
|
1958
2079
|
assert.equal(result.items.length, 2);
|
|
1959
|
-
assert.equal(result.items[0].label, '- (array item)
|
|
1960
|
-
})
|
|
1961
|
-
|
|
1962
|
-
|
|
2080
|
+
assert.equal(result.items[0].label, '- (array item) obj1');
|
|
2081
|
+
})
|
|
2082
|
+
.then(done, done);
|
|
2083
|
+
});
|
|
2084
|
+
it('Array anyOf two objects completion without "-" after array item', (done) => {
|
|
1963
2085
|
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
|
|
1964
2086
|
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
1965
2087
|
const content = 'test_array_anyOf_2objects:\n - obj1:\n name: 1\n ';
|
|
1966
2088
|
const completion = parseSetup(content, content.length);
|
|
1967
|
-
completion
|
|
2089
|
+
completion
|
|
2090
|
+
.then(function (result) {
|
|
1968
2091
|
assert.equal(result.items.length, 2);
|
|
1969
|
-
assert.equal(result.items[0].label, '- (array item)
|
|
1970
|
-
})
|
|
1971
|
-
|
|
1972
|
-
|
|
2092
|
+
assert.equal(result.items[0].label, '- (array item) obj1');
|
|
2093
|
+
})
|
|
2094
|
+
.then(done, done);
|
|
2095
|
+
});
|
|
2096
|
+
it('Array anyOf two objects completion with "-" after array item', (done) => {
|
|
1973
2097
|
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
|
|
1974
2098
|
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
1975
2099
|
const content = 'test_array_anyOf_2objects:\n - obj1:\n name: 1\n -';
|
|
1976
2100
|
const completion = parseSetup(content, content.length);
|
|
1977
|
-
completion
|
|
2101
|
+
completion
|
|
2102
|
+
.then(function (result) {
|
|
1978
2103
|
assert.equal(result.items.length, 2);
|
|
1979
|
-
assert.equal(result.items[0].label, '- (array item)
|
|
1980
|
-
})
|
|
1981
|
-
|
|
2104
|
+
assert.equal(result.items[0].label, '- (array item) obj1');
|
|
2105
|
+
})
|
|
2106
|
+
.then(done, done);
|
|
2107
|
+
});
|
|
1982
2108
|
it('Array anyOf two objects completion indentation', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1983
2109
|
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
|
|
1984
2110
|
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
1985
2111
|
const content = 'test_array_anyOf_2objects:\n - obj';
|
|
1986
2112
|
const completion = yield parseSetup(content, content.length);
|
|
1987
|
-
chai_1.expect(completion.items.length).is.equal(
|
|
2113
|
+
chai_1.expect(completion.items.length).is.equal(4);
|
|
1988
2114
|
const obj1 = completion.items.find((it) => it.label === 'obj1');
|
|
1989
2115
|
chai_1.expect(obj1).is.not.undefined;
|
|
1990
2116
|
chai_1.expect(obj1.textEdit.newText).equal('obj1:\n ');
|
|
1991
2117
|
}));
|
|
2118
|
+
it('Autocomplete key in nested object while typing', (done) => {
|
|
2119
|
+
languageService.addSchema(testHelper_1.SCHEMA_ID, {
|
|
2120
|
+
type: 'object',
|
|
2121
|
+
properties: {
|
|
2122
|
+
parent: {
|
|
2123
|
+
type: 'object',
|
|
2124
|
+
properties: {
|
|
2125
|
+
child: {
|
|
2126
|
+
type: 'object',
|
|
2127
|
+
properties: {
|
|
2128
|
+
prop: {
|
|
2129
|
+
type: 'string',
|
|
2130
|
+
default: 'test',
|
|
2131
|
+
},
|
|
2132
|
+
},
|
|
2133
|
+
},
|
|
2134
|
+
},
|
|
2135
|
+
},
|
|
2136
|
+
},
|
|
2137
|
+
});
|
|
2138
|
+
const content = 'parent:\n child:\n p';
|
|
2139
|
+
const completion = parseSetup(content, content.length);
|
|
2140
|
+
completion
|
|
2141
|
+
.then(function (result) {
|
|
2142
|
+
assert.strictEqual(result.items.length, 1);
|
|
2143
|
+
assert.deepEqual(result.items[0], verifyError_1.createExpectedCompletion('prop', 'prop: ${1:test}', 2, 4, 2, 5, 10, 2, {
|
|
2144
|
+
documentation: '',
|
|
2145
|
+
}));
|
|
2146
|
+
})
|
|
2147
|
+
.then(done, done);
|
|
2148
|
+
});
|
|
2149
|
+
});
|
|
2150
|
+
describe('Parent Completion', () => {
|
|
2151
|
+
const obj1 = {
|
|
2152
|
+
properties: {
|
|
2153
|
+
type: {
|
|
2154
|
+
const: 'typeObj1',
|
|
2155
|
+
},
|
|
2156
|
+
options: {
|
|
2157
|
+
type: 'object',
|
|
2158
|
+
properties: {
|
|
2159
|
+
label: {
|
|
2160
|
+
type: 'string',
|
|
2161
|
+
},
|
|
2162
|
+
},
|
|
2163
|
+
required: ['label'],
|
|
2164
|
+
},
|
|
2165
|
+
},
|
|
2166
|
+
required: ['type', 'options'],
|
|
2167
|
+
type: 'object',
|
|
2168
|
+
};
|
|
2169
|
+
const obj2 = {
|
|
2170
|
+
properties: {
|
|
2171
|
+
type: {
|
|
2172
|
+
const: 'typeObj2',
|
|
2173
|
+
},
|
|
2174
|
+
options: {
|
|
2175
|
+
type: 'object',
|
|
2176
|
+
properties: {
|
|
2177
|
+
description: {
|
|
2178
|
+
type: 'string',
|
|
2179
|
+
},
|
|
2180
|
+
},
|
|
2181
|
+
required: ['description'],
|
|
2182
|
+
},
|
|
2183
|
+
},
|
|
2184
|
+
required: ['type', 'options'],
|
|
2185
|
+
type: 'object',
|
|
2186
|
+
};
|
|
2187
|
+
it('Should suggest complete object skeleton', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2188
|
+
const schema = {
|
|
2189
|
+
definitions: { obj1, obj2 },
|
|
2190
|
+
anyOf: [
|
|
2191
|
+
{
|
|
2192
|
+
$ref: '#/definitions/obj1',
|
|
2193
|
+
},
|
|
2194
|
+
{
|
|
2195
|
+
$ref: '#/definitions/obj2',
|
|
2196
|
+
},
|
|
2197
|
+
],
|
|
2198
|
+
};
|
|
2199
|
+
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
2200
|
+
const content = '';
|
|
2201
|
+
const result = yield parseSetup(content, content.length);
|
|
2202
|
+
chai_1.expect(result.items.length).equal(4);
|
|
2203
|
+
chai_1.expect(result.items[0]).to.deep.equal(verifyError_1.createExpectedCompletion('type', 'type: typeObj1', 0, 0, 0, 0, 10, 2, { documentation: '' }));
|
|
2204
|
+
chai_1.expect(result.items[1]).to.deep.equal(verifyError_1.createExpectedCompletion('obj1', 'type: typeObj1\noptions:\n label: ', 0, 0, 0, 0, 7, 2, {
|
|
2205
|
+
documentation: {
|
|
2206
|
+
kind: 'markdown',
|
|
2207
|
+
value: '```yaml\ntype: typeObj1\noptions:\n label: \n```',
|
|
2208
|
+
},
|
|
2209
|
+
sortText: '_obj1',
|
|
2210
|
+
}));
|
|
2211
|
+
chai_1.expect(result.items[2]).to.deep.equal(verifyError_1.createExpectedCompletion('options', 'options:\n label: ', 0, 0, 0, 0, 10, 2, { documentation: '' }));
|
|
2212
|
+
chai_1.expect(result.items[3]).to.deep.equal(verifyError_1.createExpectedCompletion('obj2', 'type: typeObj2\noptions:\n description: ', 0, 0, 0, 0, 7, 2, {
|
|
2213
|
+
documentation: {
|
|
2214
|
+
kind: 'markdown',
|
|
2215
|
+
value: '```yaml\ntype: typeObj2\noptions:\n description: \n```',
|
|
2216
|
+
},
|
|
2217
|
+
sortText: '_obj2',
|
|
2218
|
+
}));
|
|
2219
|
+
}));
|
|
2220
|
+
it('Should suggest complete object skeleton - array', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2221
|
+
const schema = {
|
|
2222
|
+
definitions: { obj1, obj2 },
|
|
2223
|
+
items: {
|
|
2224
|
+
anyOf: [
|
|
2225
|
+
{
|
|
2226
|
+
$ref: '#/definitions/obj1',
|
|
2227
|
+
},
|
|
2228
|
+
{
|
|
2229
|
+
$ref: '#/definitions/obj2',
|
|
2230
|
+
},
|
|
2231
|
+
],
|
|
2232
|
+
},
|
|
2233
|
+
type: 'array',
|
|
2234
|
+
};
|
|
2235
|
+
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
2236
|
+
const content = '- ';
|
|
2237
|
+
const result = yield parseSetup(content, content.length);
|
|
2238
|
+
chai_1.expect(result.items.length).equal(4);
|
|
2239
|
+
chai_1.expect(result.items[0]).to.deep.equal(verifyError_1.createExpectedCompletion('type', 'type: typeObj1', 0, 2, 0, 2, 10, 2, { documentation: '' }));
|
|
2240
|
+
chai_1.expect(result.items[1]).to.deep.equal(verifyError_1.createExpectedCompletion('obj1', 'type: typeObj1\n options:\n label: ', 0, 2, 0, 2, 7, 2, {
|
|
2241
|
+
documentation: {
|
|
2242
|
+
kind: 'markdown',
|
|
2243
|
+
value: '```yaml\n type: typeObj1\n options:\n label: \n```',
|
|
2244
|
+
},
|
|
2245
|
+
sortText: '_obj1',
|
|
2246
|
+
}));
|
|
2247
|
+
chai_1.expect(result.items[2]).to.deep.equal(verifyError_1.createExpectedCompletion('options', 'options:\n label: ', 0, 2, 0, 2, 10, 2, { documentation: '' }));
|
|
2248
|
+
chai_1.expect(result.items[3]).to.deep.equal(verifyError_1.createExpectedCompletion('obj2', 'type: typeObj2\n options:\n description: ', 0, 2, 0, 2, 7, 2, {
|
|
2249
|
+
documentation: {
|
|
2250
|
+
kind: 'markdown',
|
|
2251
|
+
value: '```yaml\n type: typeObj2\n options:\n description: \n```',
|
|
2252
|
+
},
|
|
2253
|
+
sortText: '_obj2',
|
|
2254
|
+
}));
|
|
2255
|
+
}));
|
|
2256
|
+
it('Should agregate suggested text without duplicities in insertText', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2257
|
+
const schema = {
|
|
2258
|
+
definitions: { obj1, obj2 },
|
|
2259
|
+
anyOf: [
|
|
2260
|
+
{
|
|
2261
|
+
$ref: '#/definitions/obj1',
|
|
2262
|
+
},
|
|
2263
|
+
{
|
|
2264
|
+
$ref: '#/definitions/obj1',
|
|
2265
|
+
},
|
|
2266
|
+
],
|
|
2267
|
+
};
|
|
2268
|
+
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
2269
|
+
const content = '';
|
|
2270
|
+
const result = yield parseSetup(content, content.length);
|
|
2271
|
+
chai_1.expect(result.items.length).equal(3);
|
|
2272
|
+
chai_1.expect(result.items[1]).to.deep.equal(verifyError_1.createExpectedCompletion('obj1', 'type: typeObj1\noptions:\n label: ', 0, 0, 0, 0, 7, 2, {
|
|
2273
|
+
documentation: {
|
|
2274
|
+
kind: 'markdown',
|
|
2275
|
+
value: '```yaml\ntype: typeObj1\noptions:\n label: \n```',
|
|
2276
|
+
},
|
|
2277
|
+
sortText: '_obj1',
|
|
2278
|
+
}));
|
|
2279
|
+
}));
|
|
2280
|
+
it('Should suggest rest of the parent object', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2281
|
+
const schema = {
|
|
2282
|
+
definitions: { obj1 },
|
|
2283
|
+
$ref: '#/definitions/obj1',
|
|
2284
|
+
};
|
|
2285
|
+
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
2286
|
+
const content = 'type: typeObj1\n';
|
|
2287
|
+
const result = yield parseSetup(content, content.length);
|
|
2288
|
+
chai_1.expect(result.items.length).equal(2);
|
|
2289
|
+
chai_1.expect(result.items[1]).to.deep.equal(verifyError_1.createExpectedCompletion('obj1', 'options:\n label: ', 1, 0, 1, 0, 7, 2, {
|
|
2290
|
+
documentation: {
|
|
2291
|
+
kind: 'markdown',
|
|
2292
|
+
value: '```yaml\noptions:\n label: \n```',
|
|
2293
|
+
},
|
|
2294
|
+
sortText: '_obj1',
|
|
2295
|
+
}));
|
|
2296
|
+
}));
|
|
2297
|
+
it('Should reindex $x', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2298
|
+
const schema = {
|
|
2299
|
+
properties: {
|
|
2300
|
+
options: {
|
|
2301
|
+
type: 'object',
|
|
2302
|
+
properties: {
|
|
2303
|
+
label: {
|
|
2304
|
+
type: 'string',
|
|
2305
|
+
},
|
|
2306
|
+
},
|
|
2307
|
+
required: ['label'],
|
|
2308
|
+
},
|
|
2309
|
+
prop1: {
|
|
2310
|
+
type: 'string',
|
|
2311
|
+
},
|
|
2312
|
+
},
|
|
2313
|
+
required: ['type', 'options', 'prop1'],
|
|
2314
|
+
type: 'object',
|
|
2315
|
+
};
|
|
2316
|
+
languageService.addSchema(testHelper_1.SCHEMA_ID, schema);
|
|
2317
|
+
const content = '';
|
|
2318
|
+
const result = yield parseSetup(content, content.length);
|
|
2319
|
+
chai_1.expect(result.items.length).equal(3);
|
|
2320
|
+
chai_1.expect(result.items[1]).to.deep.equal(verifyError_1.createExpectedCompletion('object', 'options:\n label: $1\nprop1: $2', 0, 0, 0, 0, 7, 2, {
|
|
2321
|
+
documentation: {
|
|
2322
|
+
kind: 'markdown',
|
|
2323
|
+
value: '```yaml\noptions:\n label: \nprop1: \n```',
|
|
2324
|
+
},
|
|
2325
|
+
sortText: '_object',
|
|
2326
|
+
}));
|
|
2327
|
+
}));
|
|
1992
2328
|
});
|
|
1993
2329
|
});
|
|
1994
2330
|
//# sourceMappingURL=autoCompletion.test.js.map
|