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


TypeScript ITokenizationSupport.getInitialState方法代码示例

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


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

示例1: _actualColorize

function _actualColorize(lines: string[], tabSize: number, tokenizationSupport: ITokenizationSupport): string {
	let html: string[] = [];
	let state = tokenizationSupport.getInitialState();

	for (let i = 0, length = lines.length; i < length; i++) {
		let line = lines[i];
		let tokenizeResult = tokenizationSupport.tokenize2(line, state, 0);
		LineTokens.convertToEndOffset(tokenizeResult.tokens, line.length);
		let lineTokens = new LineTokens(tokenizeResult.tokens, line);
		const isBasicASCII = ViewLineRenderingData.isBasicASCII(line, /* check for basic ASCII */true);
		const containsRTL = ViewLineRenderingData.containsRTL(line, isBasicASCII, /* check for RTL */true);
		let renderResult = renderViewLine(new RenderLineInput(
			false,
			line,
			isBasicASCII,
			containsRTL,
			0,
			lineTokens.inflate(),
			[],
			tabSize,
			0,
			-1,
			'none',
			false,
			false
		));

		html = html.concat(renderResult.html);
		html.push('<br/>');

		state = tokenizeResult.endState;
	}

	return html.join('');
}
开发者ID:costincaraivan,项目名称:vscode,代码行数:35,代码来源:colorizer.ts

示例2: _tokenizeToString

function _tokenizeToString(text: string, tokenizationSupport: ITokenizationSupport): string {
	let result = `<div class="monaco-tokenized-source">`;
	let lines = text.split(/\r\n|\r|\n/);
	let currentState = tokenizationSupport.getInitialState();
	for (let i = 0, len = lines.length; i < len; i++) {
		let line = lines[i];

		if (i > 0) {
			result += `<br/>`;
		}

		let tokenizationResult = tokenizationSupport.tokenize2(line, currentState, 0);
		let lineTokens = new LineTokens(tokenizationResult.tokens, line);
		let viewLineTokens = lineTokens.inflate();

		let startOffset = 0;
		for (let j = 0, lenJ = viewLineTokens.length; j < lenJ; j++) {
			const viewLineToken = viewLineTokens[j];
			result += `<span class="${viewLineToken.getType()}">${strings.escape(line.substring(startOffset, viewLineToken.endIndex))}</span>`;
			startOffset = viewLineToken.endIndex;
		}

		currentState = tokenizationResult.endState;
	}

	result += `</div>`;
	return result;
}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:28,代码来源:textToHtmlTokenizer.ts

示例3: _actualColorize

function _actualColorize(lines: string[], tabSize: number, tokenizationSupport: ITokenizationSupport): string {
	let html: string[] = [];
	let state = tokenizationSupport.getInitialState();

	for (let i = 0, length = lines.length; i < length; i++) {
		let line = lines[i];
		let tokenizeResult = tokenizationSupport.tokenize2(line, state, 0);
		let lineTokens = new LineTokens(tokenizeResult.tokens, line);
		let renderResult = renderViewLine(new RenderLineInput(
			false,
			line,
			true/* check for RTL */,
			0,
			lineTokens.inflate(),
			[],
			tabSize,
			0,
			-1,
			'none',
			false,
			false
		));

		html = html.concat(renderResult.html);
		html.push('<br/>');

		state = tokenizeResult.endState;
	}

	return html.join('');
}
开发者ID:Chan-PH,项目名称:vscode,代码行数:31,代码来源:colorizer.ts

示例4: _actualColorize

function _actualColorize(lines: string[], tabSize: number, tokenizationSupport: ITokenizationSupport): string {
	let html: string[] = [];
	let state = tokenizationSupport.getInitialState();

	for (let i = 0, length = lines.length; i < length; i++) {
		let line = lines[i];

		let tokenizeResult = tokenizationSupport.tokenize(line, state);

		let renderResult = renderLine(new RenderLineInput(
			line,
			tabSize,
			0,
			-1,
			'none',
			false,
			new LineParts(tokenizeResult.tokens.map(t => new ViewLineToken(t.startIndex, t.type)), line.length + 1)
		));

		html = html.concat(renderResult.output);
		html.push('<br/>');

		state = tokenizeResult.endState;
	}

	return html.join('');
}
开发者ID:StateFarmIns,项目名称:vscode,代码行数:27,代码来源:colorizer.ts

示例5: _actualColorize

function _actualColorize(lines: string[], tabSize: number, tokenizationSupport: ITokenizationSupport): string {
	let html: string[] = [];
	let state = tokenizationSupport.getInitialState();
	let colorMap = TokenizationRegistry.getColorMap();

	for (let i = 0, length = lines.length; i < length; i++) {
		let line = lines[i];
		let tokenizeResult = tokenizationSupport.tokenize2(line, state, 0);
		let lineTokens = new LineTokens(colorMap, tokenizeResult.tokens, line);
		let renderResult = renderLine(new RenderLineInput(
			line,
			tabSize,
			0,
			-1,
			'none',
			false,
			new LineParts(lineTokens.inflate(), line.length + 1)
		));

		html = html.concat(renderResult.output);
		html.push('<br/>');

		state = tokenizeResult.endState;
	}

	return html.join('');
}
开发者ID:fs814,项目名称:vscode,代码行数:27,代码来源:colorizer.ts

示例6: _tokenizeLines

function _tokenizeLines(text: string, tokenizationSupport: ITokenizationSupport, emitToken: IEmitTokenFunc, emitNewLine: IEmitNewLineFunc): void {
	var lines = text.split(/\r\n|\r|\n/);
	var currentState = tokenizationSupport.getInitialState();
	for (var i = 0; i < lines.length; i++) {
		currentState = _tokenizeLine(lines[i], tokenizationSupport, emitToken, currentState);

		// Keep new lines
		if (i < lines.length - 1) {
			emitNewLine();
		}
	}
}
开发者ID:GYGit,项目名称:vscode,代码行数:12,代码来源:textToHtmlTokenizer.ts

示例7: constructor

	constructor(languageIdentifier: LanguageIdentifier, tokenizationSupport: ITokenizationSupport) {
		this.languageIdentifier = languageIdentifier;
		this.tokenizationSupport = tokenizationSupport;
		this._tokens = [];
		if (this.tokenizationSupport) {
			let initialState: IState = null;
			try {
				initialState = this.tokenizationSupport.getInitialState();
			} catch (e) {
				onUnexpectedError(e);
				this.tokenizationSupport = null;
			}

			if (initialState) {
				this._tokens[0] = new ModelLineTokens(initialState);
			}
		}

		this._invalidLineStartIndex = 0;
		this._lastState = null;
	}
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:21,代码来源:textModelTokens.ts


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