• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript modes.ITokenizationSupport类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _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:1Hgm,项目名称:vscode,代码行数:12,代码来源:textToHtmlTokenizer.ts


示例2: _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,
			true,
			line,
			false,
			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:developers23,项目名称:vscode,代码行数:37,代码来源:colorizer.ts


示例3: 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


示例4: _tokenizeText

	public _tokenizeText(buffer: ITextBuffer, text: string, state: IState): TokenizationResult2 {
		let r: TokenizationResult2 = null;

		try {
			r = this.tokenizationSupport.tokenize2(text, state, 0);
		} catch (e) {
			onUnexpectedError(e);
		}

		if (!r) {
			r = nullTokenize2(this.languageIdentifier.id, text, state, 0);
		}
		return r;
	}
开发者ID:AllureFer,项目名称:vscode,代码行数:14,代码来源:textModelTokens.ts


示例5: _updateTokensUntilLine

	public _updateTokensUntilLine(buffer: ITextBuffer, eventBuilder: ModelTokensChangedEventBuilder, lineNumber: number): void {
		if (!this.tokenizationSupport) {
			this._invalidLineStartIndex = buffer.getLineCount();
			return;
		}

		const linesLength = buffer.getLineCount();
		const endLineIndex = lineNumber - 1;

		// Validate all states up to and including endLineIndex
		for (let lineIndex = this._invalidLineStartIndex; lineIndex <= endLineIndex; lineIndex++) {
			const endStateIndex = lineIndex + 1;
			const text = buffer.getLineContent(lineIndex + 1);
			const lineStartState = this._getState(lineIndex);

			let r: TokenizationResult2 | null = null;

			try {
				// Tokenize only the first X characters
				let freshState = lineStartState!.clone();
				r = this.tokenizationSupport.tokenize2(text, freshState, 0);
			} catch (e) {
				onUnexpectedError(e);
			}

			if (!r) {
				r = nullTokenize2(this.languageIdentifier.id, text, lineStartState, 0);
			}
			this._setTokens(this.languageIdentifier.id, lineIndex, text.length, r.tokens);
			eventBuilder.registerChangedTokens(lineIndex + 1);
			this._setIsInvalid(lineIndex, false);

			if (endStateIndex < linesLength) {
				const previousEndState = this._getState(endStateIndex);
				if (previousEndState !== null && r.endState.equals(previousEndState)) {
					// The end state of this line remains the same
					let nextInvalidLineIndex = lineIndex + 1;
					while (nextInvalidLineIndex < linesLength) {
						if (this._isInvalid(nextInvalidLineIndex)) {
							break;
						}
						if (nextInvalidLineIndex + 1 < linesLength) {
							if (this._getState(nextInvalidLineIndex + 1) === null) {
								break;
							}
						} else {
							if (this._lastState === null) {
								break;
							}
						}
						nextInvalidLineIndex++;
					}
					this._invalidLineStartIndex = Math.max(this._invalidLineStartIndex, nextInvalidLineIndex);
					lineIndex = nextInvalidLineIndex - 1; // -1 because the outer loop increments it
				} else {
					this._setState(endStateIndex, r.endState);
				}
			} else {
				this._lastState = r.endState;
			}
		}
		this._invalidLineStartIndex = Math.max(this._invalidLineStartIndex, endLineIndex + 1);
	}
开发者ID:DonJayamanne,项目名称:vscode,代码行数:63,代码来源:textModelTokens.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript modes.LinkProvider类代码示例发布时间:2022-05-25
下一篇:
TypeScript modes.ISuggestSupport类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap