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


TypeScript Model.createFromString方法代码示例

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


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

示例1: test

	test('Cannot use "<?php" as user snippet prefix anymore, #26275', async function () {
		snippetService = new SimpleSnippetService([{
			prefix: '<?php',
			codeSnippet: 'insert me',
			name: '',
			description: '',
			source: ''
		}]);

		const provider = new SnippetSuggestProvider(modeService, snippetService);

		let model = Model.createFromString('\t<?php', undefined, modeService.getLanguageIdentifier('fooLang'));
		let result = await provider.provideCompletionItems(model, new Position(1, 7));
		assert.equal(result.suggestions.length, 1);
		model.dispose();

		model = Model.createFromString('\t<?', undefined, modeService.getLanguageIdentifier('fooLang'));
		result = await provider.provideCompletionItems(model, new Position(1, 4));
		assert.equal(result.suggestions.length, 1);
		model.dispose();

		model = Model.createFromString('a<?', undefined, modeService.getLanguageIdentifier('fooLang'));
		result = await provider.provideCompletionItems(model, new Position(1, 4));
		assert.equal(result.suggestions.length, 0);
		model.dispose();
	});
开发者ID:armanio123,项目名称:vscode,代码行数:26,代码来源:snippetsService.test.ts

示例2: test

	test('editor variables, file/dir', function () {

		assert.equal(resolver.resolve('TM_FILENAME'), 'text.txt');
		if (!isWindows) {
			assert.equal(resolver.resolve('TM_DIRECTORY'), '/foo/files');
			assert.equal(resolver.resolve('TM_FILEPATH'), '/foo/files/text.txt');
		}

		resolver = new EditorSnippetVariableResolver(
			Model.createFromString('', undefined, undefined, URI.parse('http://www.pb.o/abc/def/ghi')),
			new Selection(1, 1, 1, 1)
		);
		assert.equal(resolver.resolve('TM_FILENAME'), 'ghi');
		if (!isWindows) {
			assert.equal(resolver.resolve('TM_DIRECTORY'), '/abc/def');
			assert.equal(resolver.resolve('TM_FILEPATH'), '/abc/def/ghi');
		}

		resolver = new EditorSnippetVariableResolver(
			Model.createFromString('', undefined, undefined, URI.parse('mem:fff.ts')),
			new Selection(1, 1, 1, 1)
		);
		assert.equal(resolver.resolve('TM_DIRECTORY'), '');
		assert.equal(resolver.resolve('TM_FILEPATH'), 'fff.ts');

	});
开发者ID:hungys,项目名称:vscode,代码行数:26,代码来源:snippetVariables.test.ts

示例3: test

	test('Bug 18276:[editor] Indentation broken when selection is empty', () => {

		let model = Model.createFromString(
			[
				'function baz() {'
			].join('\n'),
			{
				defaultEOL: DefaultEndOfLine.LF,
				detectIndentation: false,
				insertSpaces: false,
				tabSize: 4,
				trimAutoWhitespace: true
			}
		);

		withTestCodeEditor(null, { model: model }, (editor, cursor) => {
			let indentLinesAction = new IndentLinesAction();
			editor.setPosition(new Position(1, 2));

			indentLinesAction.run(null, editor);
			assert.equal(model.getLineContent(1), '\tfunction baz() {');
			assert.deepEqual(editor.getSelection(), new Selection(1, 3, 1, 3));

			CoreEditingCommands.Tab.runEditorCommand(null, editor, null);
			assert.equal(model.getLineContent(1), '\tf\tunction baz() {');
		});

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

示例4: assertRanges

	function assertRanges(lines: string[], expected:IFoldingRange[]): void {
		let model = Model.createFromString(lines.join('\n'));
		let actual = computeRanges(model);
		actual.sort((r1, r2) => r1.startLineNumber - r2.startLineNumber);
		assert.deepEqual(actual, expected);
		model.dispose();
	}
开发者ID:1Hgm,项目名称:vscode,代码行数:7,代码来源:indentRanges.test.ts

示例5: testViewModel

export function testViewModel(text: string[], options: MockCodeEditorCreationOptions, callback: (viewModel: ViewModel, model: Model) => void): void {
	const EDITOR_ID = 1;

	let configuration = new TestConfiguration(options);

	let model = Model.createFromString(text.join('\n'));

	let factory = new CharacterHardWrappingLineMapperFactory(
		configuration.editor.wrappingInfo.wordWrapBreakBeforeCharacters,
		configuration.editor.wrappingInfo.wordWrapBreakAfterCharacters,
		configuration.editor.wrappingInfo.wordWrapBreakObtrusiveCharacters
	);

	let linesCollection = new SplitLinesCollection(
		model,
		factory,
		model.getOptions().tabSize,
		configuration.editor.wrappingInfo.wrappingColumn,
		configuration.editor.fontInfo.typicalFullwidthCharacterWidth / configuration.editor.fontInfo.typicalHalfwidthCharacterWidth,
		configuration.editor.wrappingInfo.wrappingIndent
	);

	let viewModel = new ViewModel(
		linesCollection,
		EDITOR_ID,
		configuration,
		model
	);

	callback(viewModel, model);

	viewModel.dispose();
	model.dispose();
	configuration.dispose();
}
开发者ID:wangcheng678,项目名称:vscode,代码行数:35,代码来源:testViewModel.ts

示例6: test

	test('_computeEdits EOL changed', function () {

		const model = Model.createFromString(
			[
				'This is line one', //16
				'and this is line number two', //27
				'it is followed by #3', //20
				'and finished with the fourth.', //29
			].join('\n')
		);

		const textSource = TextSource.fromString(
			[
				'This is line one', //16
				'and this is line number two', //27
				'it is followed by #3', //20
				'and finished with the fourth.', //29
			].join('\r\n'),
			DefaultEndOfLine.LF
		);

		const actual = ModelServiceImpl._computeEdits(model, textSource);

		assert.deepEqual(actual, []);
	});
开发者ID:SeanKilleen,项目名称:vscode,代码行数:25,代码来源:modelService.test.ts

示例7: Position

		}).then(result => {
			assert.equal(result.suggestions.length, 1);
			model.dispose();

			model = Model.createFromString('a<?', undefined, modeService.getLanguageIdentifier('fooLang'));
			return provider.provideCompletionItems(model, new Position(1, 4));
		}).then(result => {
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:7,代码来源:snippetsService.test.ts

示例8: test

	test('issue #16922: Clicking on link doesn\'t seem to do anything', () => {
		var model = Model.createFromString([
			'Hello world,',
			'How are you?',
			'Fine.',
			'Good.',
		].join('\n'));

		model.deltaDecorations([], [
			{ range: new Range(1, 1, 1, 1), options: { className: '1' } },
			{ range: new Range(1, 13, 1, 13), options: { className: '2' } },
			{ range: new Range(2, 1, 2, 1), options: { className: '3' } },
			{ range: new Range(2, 1, 2, 4), options: { className: '4' } },
			{ range: new Range(2, 8, 2, 13), options: { className: '5' } },
			{ range: new Range(3, 1, 4, 6), options: { className: '6' } },
			{ range: new Range(1, 1, 3, 6), options: { className: 'x1' } },
			{ range: new Range(2, 5, 2, 8), options: { className: 'x2' } },
			{ range: new Range(1, 1, 2, 8), options: { className: 'x3' } },
			{ range: new Range(2, 5, 3, 1), options: { className: 'x4' } },
		]);

		let inRange = model.getDecorationsInRange(new Range(2, 6, 2, 6));

		let inRangeClassNames = inRange.map(d => d.options.className);
		inRangeClassNames.sort();
		assert.deepEqual(inRangeClassNames, ['x1', 'x2', 'x3', 'x4']);

		model.dispose();
	});
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:29,代码来源:modelDecorations.test.ts


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