Refresh master with initial release/0.24 snapshot (#332)

* Initial port of release/0.24 source code

* Fix additional headers

* Fix a typo in launch.json
This commit is contained in:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -359,3 +359,179 @@ suite('TextModelWithTokens regression tests', () => {
registration.dispose();
});
});
suite('TextModel.getLineIndentGuide', () => {
function assertIndentGuides(lines: [number, string][]): void {
let text = lines.map(l => l[1]).join('\n');
let model = Model.createFromString(text);
let actualIndents = model.getLinesIndentGuides(1, model.getLineCount());
let actual: [number, string][] = [];
for (let line = 1; line <= model.getLineCount(); line++) {
actual[line - 1] = [actualIndents[line - 1], model.getLineContent(line)];
}
// let expected = lines.map(l => l[0]);
assert.deepEqual(actual, lines);
model.dispose();
}
test('getLineIndentGuide one level', () => {
assertIndentGuides([
[0, 'A'],
[1, ' A'],
[1, ' A'],
[1, ' A'],
]);
});
test('getLineIndentGuide two levels', () => {
assertIndentGuides([
[0, 'A'],
[1, ' A'],
[1, ' A'],
[1, ' A'],
[1, ' A'],
]);
});
test('getLineIndentGuide three levels', () => {
assertIndentGuides([
[0, 'A'],
[1, ' A'],
[1, ' A'],
[2, ' A'],
[0, 'A'],
]);
});
test('getLineIndentGuide decreasing indent', () => {
assertIndentGuides([
[1, ' A'],
[1, ' A'],
[0, 'A'],
]);
});
test('getLineIndentGuide Java', () => {
assertIndentGuides([
/* 1*/[0, 'class A {'],
/* 2*/[1, ' void foo() {'],
/* 3*/[1, ' console.log(1);'],
/* 4*/[1, ' console.log(2);'],
/* 5*/[1, ' }'],
/* 6*/[1, ''],
/* 7*/[1, ' void bar() {'],
/* 8*/[1, ' console.log(3);'],
/* 9*/[1, ' }'],
/*10*/[0, '}'],
/*11*/[0, 'interface B {'],
/*12*/[1, ' void bar();'],
/*13*/[0, '}'],
]);
});
test('getLineIndentGuide Javadoc', () => {
assertIndentGuides([
[0, '/**'],
[1, ' * Comment'],
[1, ' */'],
[0, 'class A {'],
[1, ' void foo() {'],
[1, ' }'],
[0, '}'],
]);
});
test('getLineIndentGuide Whitespace', () => {
assertIndentGuides([
[0, 'class A {'],
[1, ''],
[1, ' void foo() {'],
[1, ' '],
[2, ' return 1;'],
[1, ' }'],
[1, ' '],
[0, '}'],
]);
});
test('getLineIndentGuide Tabs', () => {
assertIndentGuides([
[0, 'class A {'],
[1, '\t\t'],
[1, '\tvoid foo() {'],
[2, '\t \t//hello'],
[2, '\t return 2;'],
[1, ' \t}'],
[1, ' '],
[0, '}'],
]);
});
test('getLineIndentGuide checker.ts', () => {
assertIndentGuides([
/* 1*/[0, '/// <reference path="binder.ts"/>'],
/* 2*/[0, ''],
/* 3*/[0, '/* @internal */'],
/* 4*/[0, 'namespace ts {'],
/* 5*/[1, ' let nextSymbolId = 1;'],
/* 6*/[1, ' let nextNodeId = 1;'],
/* 7*/[1, ' let nextMergeId = 1;'],
/* 8*/[1, ' let nextFlowId = 1;'],
/* 9*/[1, ''],
/*10*/[1, ' export function getNodeId(node: Node): number {'],
/*11*/[2, ' if (!node.id) {'],
/*12*/[3, ' node.id = nextNodeId;'],
/*13*/[3, ' nextNodeId++;'],
/*14*/[2, ' }'],
/*15*/[2, ' return node.id;'],
/*16*/[1, ' }'],
/*17*/[0, '}'],
]);
});
test('issue #8425 - Missing indentation lines for first level indentation', () => {
assertIndentGuides([
[1, '\tindent1'],
[2, '\t\tindent2'],
[2, '\t\tindent2'],
[1, '\tindent1'],
]);
});
test('issue #8952 - Indentation guide lines going through text on .yml file', () => {
assertIndentGuides([
[0, 'properties:'],
[1, ' emailAddress:'],
[2, ' - bla'],
[2, ' - length:'],
[3, ' max: 255'],
[0, 'getters:'],
]);
});
test('issue #11892 - Indent guides look funny', () => {
assertIndentGuides([
[0, 'function test(base) {'],
[1, '\tswitch (base) {'],
[2, '\t\tcase 1:'],
[3, '\t\t\treturn 1;'],
[2, '\t\tcase 2:'],
[3, '\t\t\treturn 2;'],
[1, '\t}'],
[0, '}'],
]);
});
test('issue #12398 - Problem in indent guidelines', () => {
assertIndentGuides([
[2, '\t\t.bla'],
[3, '\t\t\tlabel(for)'],
[0, 'include script'],
]);
});
});