当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript TextModel.createFromString方法代码示例

本文整理汇总了TypeScript中vs/editor/common/model/textModel.TextModel.createFromString方法的典型用法代码示例。如果您正苦于以下问题:TypeScript TextModel.createFromString方法的具体用法?TypeScript TextModel.createFromString怎么用?TypeScript TextModel.createFromString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vs/editor/common/model/textModel.TextModel的用法示例。


在下文中一共展示了TextModel.createFromString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: setup

	setup(function () {

		model = TextModel.createFromString('FOO\nbar\BAR\nfoo', undefined, undefined, URI.parse('foo:bar/path'));
		registration = CompletionProviderRegistry.register({ pattern: 'bar/path', scheme: 'foo' }, {
			provideCompletionItems() {
				return {
					incomplete: false,
					suggestions: [{
						label: 'aaa',
						kind: CompletionItemKind.Snippet,
						insertText: 'aaa'
					}, {
						label: 'zzz',
						kind: CompletionItemKind.Snippet,
						insertText: 'zzz'
					}, {
						label: 'fff',
						kind: CompletionItemKind.Property,
						insertText: 'fff'
					}]
				};
			}
		});
	});
开发者ID:DonJayamanne,项目名称:vscode,代码行数:24,代码来源:suggest.test.ts

示例2: setup

	setup(() => {
		let _lineIndex = 0;
		const tokenizationSupport: modes.ITokenizationSupport = {
			getInitialState: () => NULL_STATE,
			tokenize: undefined,
			tokenize2: (line: string, state: modes.IState): TokenizationResult2 => {
				let tokens = _tokens[_lineIndex++];

				let result = new Uint32Array(2 * tokens.length);
				for (let i = 0; i < tokens.length; i++) {
					result[2 * i] = tokens[i].startIndex;
					result[2 * i + 1] = (
						tokens[i].value << modes.MetadataConsts.FOREGROUND_OFFSET
					);
				}
				return new TokenizationResult2(result, state);
			}
		};
		const LANGUAGE_ID = 'modelModeTest1';
		languageRegistration = modes.TokenizationRegistry.register(LANGUAGE_ID, tokenizationSupport);
		model = TextModel.createFromString(_text.join('\n'), undefined, new modes.LanguageIdentifier(LANGUAGE_ID, 0));
		// force tokenization
		model.forceTokenization(model.getLineCount());
	});
开发者ID:AllureFer,项目名称:vscode,代码行数:24,代码来源:splitLinesCollection.test.ts

示例3: test

	test('normalizeIndentation 2', () => {
		let model = TextModel.createFromString('',
			{
				detectIndentation: false,
				tabSize: 4,
				insertSpaces: true,
				trimAutoWhitespace: true,
				defaultEOL: DefaultEndOfLine.LF
			}
		);

		assert.equal(model.normalizeIndentation('\ta'), '    a');
		assert.equal(model.normalizeIndentation('    a'), '    a');
		assert.equal(model.normalizeIndentation('   a'), '   a');
		assert.equal(model.normalizeIndentation('  a'), '  a');
		assert.equal(model.normalizeIndentation(' a'), ' a');
		assert.equal(model.normalizeIndentation('a'), 'a');
		assert.equal(model.normalizeIndentation(' \t   a'), '        a');
		assert.equal(model.normalizeIndentation(' \t  a'), '       a');
		assert.equal(model.normalizeIndentation(' \t a'), '      a');
		assert.equal(model.normalizeIndentation(' \ta'), '     a');

		model.dispose();
	});
开发者ID:SeanKilleen,项目名称:vscode,代码行数:24,代码来源:textModel.test.ts

示例4: test

	test('nope', () => {
		let model = TextModel.createFromString('hello world!');
		assert.equal(model.mightContainRTL(), false);
	});
开发者ID:Chan-PH,项目名称:vscode,代码行数:4,代码来源:textModel.test.ts

示例5: setup

	setup(() => {
		var text = ['This text has some  words. '];
		thisModel = TextModel.createFromString(text.join('\n'));
	});
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:4,代码来源:model.test.ts

示例6: test

	test('Bug 13333:Model should line break on lonely CR too', () => {
		var model = TextModel.createFromString('Hello\rWorld!\r\nAnother line');
		assert.equal(model.getLineCount(), 3);
		assert.equal(model.getValue(), 'Hello\r\nWorld!\r\nAnother line');
		model.dispose();
	});
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:6,代码来源:model.test.ts

示例7: test

	test('Limit by nesting level', async () => {
		let lines = [
			/* 1*/	'{',
			/* 2*/	'  A',
			/* 3*/	'  {',
			/* 4*/	'    {',
			/* 5*/	'      B',
			/* 6*/	'    }',
			/* 7*/	'    {',
			/* 8*/	'      A',
			/* 9*/	'      {',
			/* 10*/	'         A',
			/* 11*/	'      }',
			/* 12*/	'      {',
			/* 13*/	'        {',
			/* 14*/	'          {',
			/* 15*/	'             A',
			/* 16*/	'          }',
			/* 17*/	'        }',
			/* 18*/	'      }',
			/* 19*/	'    }',
			/* 20*/	'  }',
			/* 21*/	'}',
			/* 22*/	'{',
			/* 23*/	'  A',
			/* 24*/	'}',
		];

		let r1 = r(1, 20);  //0
		let r2 = r(3, 19);  //1
		let r3 = r(4, 5);   //2
		let r4 = r(7, 18);  //2
		let r5 = r(9, 10);  //3
		let r6 = r(12, 17); //4
		let r7 = r(13, 16); //5
		let r8 = r(14, 15); //6
		let r9 = r(22, 23); //0

		let model = TextModel.createFromString(lines.join('\n'));
		let ranges = [r1, r2, r3, r4, r5, r6, r7, r8, r9];
		let providers = [new TestFoldingRangeProvider(model, ranges)];

		async function assertLimit(maxEntries: number, expectedRanges: IndentRange[], message: string) {
			let indentRanges = await new SyntaxRangeProvider(model, providers, maxEntries).compute(CancellationToken.None);
			let actual: IndentRange[] = [];
			if (indentRanges) {
				for (let i = 0; i < indentRanges.length; i++) {
					actual.push({ start: indentRanges.getStartLineNumber(i), end: indentRanges.getEndLineNumber(i) });
				}
			}
			assert.deepEqual(actual, expectedRanges, message);
		}

		await assertLimit(1000, [r1, r2, r3, r4, r5, r6, r7, r8, r9], '1000');
		await assertLimit(9, [r1, r2, r3, r4, r5, r6, r7, r8, r9], '9');
		await assertLimit(8, [r1, r2, r3, r4, r5, r6, r7, r9], '8');
		await assertLimit(7, [r1, r2, r3, r4, r5, r6, r9], '7');
		await assertLimit(6, [r1, r2, r3, r4, r5, r9], '6');
		await assertLimit(5, [r1, r2, r3, r4, r9], '5');
		await assertLimit(4, [r1, r2, r3, r9], '4');
		await assertLimit(3, [r1, r2, r9], '3');
		await assertLimit(2, [r1, r9], '2');
		await assertLimit(1, [r1], '1');
		await assertLimit(0, [], '0');
	});
开发者ID:DonJayamanne,项目名称:vscode,代码行数:65,代码来源:syntaxFold.test.ts

示例8: test

	test('removeAllDecorationsWithOwnerId can be called after model dispose', () => {
		let model = TextModel.createFromString('asd');
		model.dispose();
		model.removeAllDecorationsWithOwnerId(1);
	});
开发者ID:AllureFer,项目名称:vscode,代码行数:5,代码来源:modelDecorations.test.ts

示例9: test

	test('hasRanges', () => {
		let lines = [
		/* 1*/	'/**',
		/* 2*/	' * Comment',
		/* 3*/	' */',
		/* 4*/	'class A {',
		/* 5*/	'  void foo() {',
		/* 6*/	'    if (true) {',
		/* 7*/	'      //hello',
		/* 8*/	'    }',
		/* 9*/	'  }',
		/* 10*/	'}'];

		let textModel = TextModel.createFromString(lines.join('\n'));
		let foldingModel = new FoldingModel(textModel, new TestDecorationProvider(textModel));
		let hiddenRangeModel = new HiddenRangeModel(foldingModel);

		assert.equal(hiddenRangeModel.hasRanges(), false);

		let ranges = computeRanges(textModel, false, void 0);
		foldingModel.update(ranges);

		foldingModel.toggleCollapseState([foldingModel.getRegionAtLine(1)!, foldingModel.getRegionAtLine(6)!]);
		assertRanges(hiddenRangeModel.hiddenRanges, [r(2, 3), r(7, 7)]);

		assert.equal(hiddenRangeModel.hasRanges(), true);
		assert.equal(hiddenRangeModel.isHidden(1), false);
		assert.equal(hiddenRangeModel.isHidden(2), true);
		assert.equal(hiddenRangeModel.isHidden(3), true);
		assert.equal(hiddenRangeModel.isHidden(4), false);
		assert.equal(hiddenRangeModel.isHidden(5), false);
		assert.equal(hiddenRangeModel.isHidden(6), false);
		assert.equal(hiddenRangeModel.isHidden(7), true);
		assert.equal(hiddenRangeModel.isHidden(8), false);
		assert.equal(hiddenRangeModel.isHidden(9), false);
		assert.equal(hiddenRangeModel.isHidden(10), false);

		foldingModel.toggleCollapseState([foldingModel.getRegionAtLine(4)!]);
		assertRanges(hiddenRangeModel.hiddenRanges, [r(2, 3), r(5, 9)]);

		assert.equal(hiddenRangeModel.hasRanges(), true);
		assert.equal(hiddenRangeModel.isHidden(1), false);
		assert.equal(hiddenRangeModel.isHidden(2), true);
		assert.equal(hiddenRangeModel.isHidden(3), true);
		assert.equal(hiddenRangeModel.isHidden(4), false);
		assert.equal(hiddenRangeModel.isHidden(5), true);
		assert.equal(hiddenRangeModel.isHidden(6), true);
		assert.equal(hiddenRangeModel.isHidden(7), true);
		assert.equal(hiddenRangeModel.isHidden(8), true);
		assert.equal(hiddenRangeModel.isHidden(9), true);
		assert.equal(hiddenRangeModel.isHidden(10), false);

		foldingModel.toggleCollapseState([foldingModel.getRegionAtLine(1)!, foldingModel.getRegionAtLine(6)!, foldingModel.getRegionAtLine(4)!]);
		assertRanges(hiddenRangeModel.hiddenRanges, []);
		assert.equal(hiddenRangeModel.hasRanges(), false);
		assert.equal(hiddenRangeModel.isHidden(1), false);
		assert.equal(hiddenRangeModel.isHidden(2), false);
		assert.equal(hiddenRangeModel.isHidden(3), false);
		assert.equal(hiddenRangeModel.isHidden(4), false);
		assert.equal(hiddenRangeModel.isHidden(5), false);
		assert.equal(hiddenRangeModel.isHidden(6), false);
		assert.equal(hiddenRangeModel.isHidden(7), false);
		assert.equal(hiddenRangeModel.isHidden(8), false);
		assert.equal(hiddenRangeModel.isHidden(9), false);
		assert.equal(hiddenRangeModel.isHidden(10), false);

	});
开发者ID:DonJayamanne,项目名称:vscode,代码行数:67,代码来源:hiddenRangeModel.test.ts


注:本文中的vs/editor/common/model/textModel.TextModel.createFromString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。